프런트 엔드 서버로 nginx를 사용하고 백엔드로 tomcat을 사용합니다. 클라이언트는 https 구성표를 통해 내 사이트에 액세스합니다. 예를 들어 :nginx를 역방향 프록시로 사용하는 잘못된 리디렉션 체계
https://example.com/app/test
Nginx에이를 수신하고이 지역의 주소를 통해에 바람둥이 요청을 전달합니다
http://localhost:8080/app/test
내의 nginx의 구성 :
location/{
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forward-For $remote_addr;
proxy_set_header X-Forward-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forward-Proto $scheme;
proxy_pass http://localhost:8080;
}
이 잘 작동합니다. 그러나 리디렉션 (http 302)을 사용하려고하면 항상 https가 http로 바뀝니다.
이response.sendRedirect("/app/redirect-test");
내가 기대하는 브라우저 리디렉션하는 것입니다 : 이것은 내 리디렉션 코드
https://example.com/app/redirect-test
를하지만 항상로 브라우저를 리디렉션 :
http://example.com/app/redirect-test.
나는 또한 헤더를 기록 이 문제를 추적하려면
host : example.com
x-real-ip : 180.168.202.246
x-forward-for : 180.168.202.246
x-forward-proto : https
connection : close
......
그러나 나는 아직도 알 수 없다. request.getRequestURL()을 기록하려고하면 다음과 같은 결과가 나타납니다.
http://example.com/app/test
이 문제를 어떻게 해결할 수 있습니까?
을 Forward-For는 X-Forwarded- 이고 X-Forward-Proto는 X-Forwarded-Proto 여야합니다. 그러나 문제를 해결 한 후에도 문제는 여전히 존재합니다. – guogangj