Reverse proxy from HTTPS to HTTP from an unknown source location

speedfirst nginx-forum at
Sat Jul 23 03:32:46 UTC 2011

normally, your backend server should do the redirect in a relative URL,
unless you really want to redirect to another host. That's something


In this way, the backend server will send redirect URL with the HOST
header specified in the request. In your case, it should be:

   Location: http://mybackendserver:8080/redirectTo/anotherPath

If you don't use "proxy_add_header Host xxxx", nginx will the argument
specified in "proxy_pass" as the Host to the backend. And in this case,
the config:

   proxy_redirect default;

   proxy_redirect http://mybackendserver:8080/      /;

will automatically handle everything.

If you insist to let the backend server do the FULL URL redirection, you
have to manually specify all possible proxy_redirect like this:

   proxy_redirect <FULL URL 1> /;
   proxy_redirect <FULL URL 2> /;

By the way, the first argument of "proxy_redirect" doesn't support var.
If you specify a var, nginx doesn't recognize it, and doesn't report an
error too. It just considers it as literal.

Posted at Nginx Forum:,212823,212827#msg-212827

More information about the nginx mailing list