My iOS app is currently accessing domain A via http POST but I would like to forward all requests to domain B.
If I use the usual rewrite ^/(.*)$ http://mydomain/$1 permanent;
the POST data seems to get lost.
How can I pass HTTP POST data to a different domain using NginX?
Try using the reverse proxy support instead. An example
location
section would be:This example will pass through all requests to this
server
block to a second server running onlocalhost:8080
. This preservesPOST
's and should also preserve other request types too if it ever becomes an issue.The issue is that external redirects will never resend
POST
data. This is written into the HTTP spec (check the 3xx section). Any client that does do this is violating the spec.I'm fairly sure that most browsers implement this by simply forcing the redirected request to be a
GET
request. Theoretically, the spec does allow for a browser that would ask the user whether to redirect thePOST
data, but I'm unaware of any that currently do.You can also achieve this in Nginx but using the
mirror
plugin notrewrite
: