Proxy with SSL offload and Nginx redirections

Artur nginx at
Thu Jan 24 23:02:32 UTC 2019


In my setup I have a proxy with TLS offload with Nginx as a backend
server (without TLS).

If client asks an url such as https://host/dir, the proxy relays the
request to Nginx as follows : http://host/dir
Nothing strange here, this is an usual behaviour.
Then Nginx sees that there is trailing slash missing and returns a 301
redirect with following location : http://host/dir/
This behaviour is certainly related to the following directive :
try_files $uri $uri/ =404;

I'd prefer that Nginx returns a 301 redirect with tls enabled :

I've currently configured the proxy to set header
X-Forwarded-Proto:https but it does not change anything.

Could you please point me to the right directive so Nginx follows what
is set in X-Forwarded-Proto header ?
Maybe I should use 'absolute_redirect off;' ?


Best regards,

More information about the nginx mailing list