I'm using Nginx to act as an SSL proxy inside a docker container listening on port 443. The proxy correctly works and properly routes trafic to another Nginx instance upstream on port 80 (that lives inside another container).
I'm encountering mixed content issues, and I'm not sure what would be the proper fix:
A request aimed at a folder (but without the trailing slash) like: https://example.com/mediafiles/bar
gets properly routed to the second NginX instance.
However it gets a 301 to an http url (response headers):
$ curl -IL https://example.com/mediafiles/bar
HTTP/1.1 301 Moved Permanently
Server: nginx
Date: Mon, 15 Jun 2015 15:16:29 GMT
Content-Type: text/html
Content-Length: 178
Connection: keep-alive
Location: http://example.com/mediafiles/bar/
X-UA-Compatible: IE=Edge,chrome=1
HTTP/1.1 301 Moved Permanently
Server: nginx
Date: Mon, 15 Jun 2015 15:16:29 GMT
Content-Type: text/html
Content-Length: 178
Connection: keep-alive
Location: https://example.com/mediafiles/bar/
HTTP/1.1 200 OK
Server: nginx
Date: Mon, 15 Jun 2015 15:16:29 GMT
Content-Type: text/html; charset=utf-8
Content-Length: 1786
Connection: keep-alive
Vary: Accept-Encoding
Last-Modified: Wed, 18 Mar 2015 23:09:35 GMT
Vary: Accept-Encoding
ETag: "550a05af-6fa"
Accept-Ranges: bytes
X-UA-Compatible: IE=Edge,chrome=1
Probably caused by this common try_files config (EDIT: apparently it's not issuing redirects).
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ /index.php?$args;
}
I've posted the full upstream config here: https://gist.github.com/mgcrea/f149d0481ad1fa1c2207
And the relevant proxy config here: https://gist.github.com/mgcrea/26ef92026a20ccc22226
This 301 to an http resource triggers a mixed content error:
Mixed Content: The page at 'https://example.com' was loaded over HTTPS, but requested an insecure resource 'http://example.com/mediafiles/bar/'. This request has been blocked; the content must be served over HTTPS.
Any ideas?
Seems to be related: https://stackoverflow.com/questions/15555428/nginx-causes-301-redirect-if-theres-no-trailing-slash