Proxy HTTPS requests to a HTTP backend with NGINX.

Posted by Mike on Server Fault See other posts from Server Fault or by Mike
Published on 2010-05-26T09:28:02Z Indexed on 2010/05/26 9:33 UTC
Read the original article Hit count: 243

Filed under:
|

I have nginx configured to be my externally visible webserver which talks to a backend over HTTP.

The scenario I want to achieve is:

  1. Client makes HTTPS request to nginx
  2. nginx proxies request over HTTP to the backend
  3. nginx receives response from backend over HTTP.
  4. 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?

© Server Fault or respective owner

Related posts about nginx

Related posts about https