I have nginx configured to
be my externally visible webserver which talks to a backend over HTTP.
The scenario I want to achieve
is:
- Client makes HTTP
request to nginx which is redirect to the same URL but over
HTTPS - nginx proxies request over HTTP to the
backend - nginx receives response from backend over
HTTP. - nginx passes this back to the client over
HTTPS
My
current config (where backend is configured correctly) is:
/>
server {
listen
80;
server_name localhost;
location ~ .*
{
proxy_pass http://backend;
proxy_redirect
http://backend https://$host;
proxy_set_header Host $host;
}
}
My problem is the
response to the client (step 4) is sent over HTTP not HTTPS. Any
ideas?
Answer
The type of proxy you are trying to set up
is called a reverse proxy. A quick search for reverse proxy nginx got me this
page:
href="http://intranation.com/entries/2008/09/using-nginx-reverse-proxy/"
rel="noreferrer">http://intranation.com/entries/2008/09/using-nginx-reverse-proxy/
In
addition to adding some useful features like an X-Forwarded-For header (which will give
your app visibility into the actual source IP), it specifically
does:
proxy_redirect
off
Good luck!
:)
Comments
Post a Comment