Linux 환경 에서 Nginx SSL+Tomcat 클 러 스 터 를 통 해 request.getScheme()이 올 바른 https 프로 토 콜 과 https 를 가 져 와 http 로 전환 하 는 문 제 를 해결 합 니 다.

nginx ssl+tomcat 후 자바 는 request.getScheme()을 통 해 https 가 아 닌 http 문 제 를 가 져 옵 니 다.해결 방안 은 다음 과 같 습 니 다.
1:Nginx 의 퍼 가기 설정(ssl 모듈 에 추가 해 야 함):
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Scheme $scheme;
proxy_set_header X-Forwarded-Proto  $scheme; 

중점: proxy_set_header X-Forwarded-Proto $scheme;
 
2.Tomcat server.xml 를 설정 한 Engine 모듈 에서 Valve 를 설정 합 니 다.

 
양측의 X-Forward-proto 를 설정 하 는 것 은 실제 사용자 가 보 낸 프로 토 콜 이 http 인지 https 인지 정확하게 식별 하기 위 한 것 이다.
 
3.location 의 프 록 시 설정;
location ^~ /interface {
			index  index.html index.htm index.jsp;
			proxy_pass http://127.0.0.1:8080/interface;
			proxy_redirect http:// https://;
			proxy_connect_timeout 10;
			proxy_read_timeout 10; 
			proxy_send_timeout 10; 
        }

포인트:proxyredirect http:// https://;
이 설정 은 재 설정 을 해결 한 후 https 가 http 로 변 하 는 문제 입 니 다.

좋은 웹페이지 즐겨찾기