How do I get nginx to issue 301 requests to HTTPS location, when SSL handled by a load-balancer?
Posted
by
growse
on Server Fault
See other posts from Server Fault
or by growse
Published on 2012-11-15T14:28:39Z
Indexed on
2012/11/20
5:01 UTC
Read the original article
Hit count: 417
I've noticed that there's functionality enabled in nginx by default, whereby a url request without a trailing slash for a directory which exists in the filesystem automatically has a slash added through a 301
redirect.
E.g. if the directory css
exists within my root, then requesting http://example.com/css
will result in a 301 to http://example.com/css/
.
However, I have another site where the SSL is offloaded by a load-balancer. In this case, when I request https://example.com/css
, nginx issues a 301 redirect to http://example.com/css/
, despite the fact that the HTTP_X_FORWARDED_PROTO
header is set to https
by the load balancer.
Is this an nginx bug? Or a config setting I've missed somewhere?
© Server Fault or respective owner