Nginx를 SSL 프록시로 사용할 때 try_files 지시문으로 혼합 콘텐츠 문제를 방지하시겠습니까?

Nginx를 SSL 프록시로 사용할 때 try_files 지시문으로 혼합 콘텐츠 문제를 방지하시겠습니까?

저는 Nginx를 사용하여 포트 443에서 수신 대기하는 도커 컨테이너 내에서 SSL 프록시 역할을 하고 있습니다. 프록시는 올바르게 작동하고 포트 80(다른 컨테이너 내부에 있음)의 다른 Nginx 인스턴스 업스트림으로 트래픽을 올바르게 라우팅합니다.

혼합 콘텐츠 문제가 발생했는데, 적절한 해결 방법이 무엇인지 잘 모르겠습니다.

다음과 같이 폴더를 겨냥한 요청(후행 슬래시 없음)은 https://example.com/mediafiles/bar두 번째 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

관련 정보