Proxy_pass를 사용할 때 Nginx에서 301을 보냅니다.

Proxy_pass를 사용할 때 Nginx에서 301을 보냅니다.

AWS에서 호스팅되는 웹사이트가 있습니다.www.example.com. Wix myblog.wixsite.com/blog에 블로그를 만들었습니다. 이제 myblog.wixsite.com/blog의 콘텐츠를 표시하고 싶습니다.www.example.com/blog. 그래서 나는 그것을 시도하고 달성하기 위해 다음 Nginx conf를 사용했습니다.

location /blog/ {
          sub_filter 'http://myblog.wixsite.com/' 'https://$http_host/blog/';
          sub_filter 'https://myblog.wixsite.com/' 'https://$http_host/blog/';
          sub_filter 'href="/posts/' 'href="/blog/';
          sub_filter 'href="/category/' 'href="/blog/category/';
          sub_filter 'href="/authors/' 'href="/blog/authors/';
          sub_filter 'href="/recent/' 'href="/blog/recent/';

          proxy_ssl_verify off;
          proxy_set_header Host "myblog.wixsite.com";
          proxy_set_header X-Forwarded-Host "";
          proxy_set_header X-Forwarded-For "";
          proxy_set_header Accept-Encoding "";
          proxy_set_header Cookie "";

          proxy_pass http://myblog.wixsite.com/blog/;

          proxy_redirect ~^(http://[^/]+)(/.+)$ https://$http_host$2;
        }

이제 내가 쳤을 때www.example.com/blog, Nginx가 나를 다음으로 리디렉션합니다.https://myblog.wixsite.com/blog/콘텐츠를 표시하는 대신www.example.com/blog그 자체. 또한 proxy_pass http://myblog.wixsite.com/blog/;변경 을 시도했지만 proxy_pass https://myblog.wixsite.com/blog/; 다음 오류가 발생하기 시작했습니다.

*532 SSL_do_handshake() failed (SSL: error:14077438:SSL routines:SSL23_GET_SERVER_HELLO:tlsv1 alert internal error) while SSL handshaking to upstream, client: <redacted>, server: www.example.com, request: "GET /blog/ HTTP/2.0", upstream: "https://myblog.wixsite.com/blog/", host: "www.example.com"

나는 며칠 동안 아무런 결과도 얻지 못했습니다. 누군가 내가 뭘 잘못하고 있는지 제안할 수 있나요?

답변1

사용하거나proxy_redirect또는 변경

proxy_pass http://myblog.wixsite.com/blog/; to 
proxy_pass https://myblog.wixsite.com/blog/;

프로토콜 httpshttp. Wix 블로그는 어쨌든 HTTPS로 제공됩니다.

답변2

리디렉션을 보내는 것은 nginx가 아니라 https://myblog.wixsite.com/blog/리디렉션을 보내는 웹사이트이며, nginx는 사이트에서 받는 응답만 프록시합니다.

관련 정보