
私は、ポート 443 でリッスンしている Docker コンテナ内で SSL プロキシとして機能する Nginx を使用しています。プロキシは正常に動作し、トラフィックをポート 80 (別のコンテナ内にある) のアップストリームの別の Nginx インスタンスに適切にルーティングします。
混合コンテンツの問題が発生していますが、適切な修正方法がわかりません。
次のようなフォルダーを対象としたリクエスト (末尾のスラッシュなし) は、https://example.com/mediafiles/bar
2 番目の NginX インスタンスに適切にルーティングされます。
ただし、http URL (応答ヘッダー) に対して 301 が返されます。
$ 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
おそらく、この一般的な try_files 構成が原因です (編集: どうやらリダイレクトを発行していないようです)。
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;
}
完全なアップストリーム設定をここに投稿しました:https://gist.github.com/mgcrea/f149d0481ad1fa1c2207
関連するプロキシ設定は次のとおりです。https://gist.github.com/mgcrea/26ef92026a20ccc22226
http リソースへのこの 301 は、混合コンテンツ エラーをトリガーします。
混合コンテンツ: 'https://example.com' は HTTPS 経由で読み込まれましたが、安全でないリソースを要求しました 'http://example.com/mediafiles/bar/'。このリクエストはブロックされました。コンテンツは HTTPS 経由で提供する必要があります。
何か案は?
関連があるようです:https://stackoverflow.com/questions/15555428/nginx-causes-301-redirect-if-theres-no-trailing-slash