Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Nginx proxy https to http on non standard port?

Tags:

I have nginx configured to proxy https traffic to an http server running on the same machine.

Everything works fine when I configure nginx to listen on / proxy from https port 443. But I really want to listen on a non standard port. When I configure a non standard port, nginx receives the request and sends it to my http server, as it should, but the server is responding with an HTTP redirect back to the browser that tells it to redirect to 'https://server.com/someurl". I mean the redirect url looks good except for it's missing the correct port. Am I missing an HTTP header that I need to be setting in the proxy?

Specifically I'm running an http instance of Tracks; http://getontracks.org. If it matters.

My (working on standard port) nginx server configuration:

location /{
    proxy_pass http://localhost:50000;
    proxy_next_upstream error timeout invalid_header http_500 http_502 http_503;
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto https;
    proxy_redirect off;
}