2017-03-04 15 views
1

나는이 아이디어를 완전히 가지고 있지 않으며 Apache HTTPD (2.4) 및 Tomcat (8.5)에 대한 이해를 돕기 위해 도움을 요청해야한다고 생각합니다.Tomcat 302에서 AJP를 사용하는 Apache 역방향 프록시

나는 프록시를 거치지 않을 때 완벽하게 작동하는 Spring MVC 4 웹 앱을 가지고있다. 그러나 프록시를 거쳐 302 리다이렉트로 연결되는 링크를 방문 할 때마다 실패한다.

직접가는 올바른 경로로 리디렉션되므로 클라이언트에 잘못된 URL을 다시 제공하는 웹 앱이 아닙니다. 그러나 프록시를 통해 URL을 컨텍스트 경로로 접두어로 표시하는 위치로 리디렉션됩니다. 이미 존재합니다! 그래서 두 번 나타나서 존재하지 않는 URL에 대한 요청이 있습니다!

톰캣의 액세스 로그를 볼 때 302 리디렉션 경로에 컨텍스트 경로 접두사를 붙일 수 있습니다 - 중복 컨텍스트 경로!

80.229.100.100 - - [04/Mar/2017:08:07:54 +0000] "GET /ctxPath/redirect HTTP/1.1" 302 - 
80.229.100.100 - - [04/Mar/2017:08:07:54 +0000] "GET /ctxPath/ctxPath/testUrl HTTP/1.1" 404 986 

이것은 Tomcat의 HTTPD 응답 (AJP 커넥터 사용)이어야합니다. 페이지에 직접 액세스 할 때 HTTP 커넥터를 통해 정상적으로 작동합니다. HTTP 커넥터를 사용하여 302 리디렉션에 대해 동일한 결과를 얻도록 HTTPD 구성을 업데이트했습니다.

그래서 모든 리다이렉션 결과는 404가됩니다. 어떤 방식 으로든 Tomcat의 구성을 변경해야합니까?

현재 내 HTTPD의 설정은 (I 여러 톰캣 설치를 가지고 포트 9009가 올바른지) 다음과 같습니다 : 나는 무엇을 놓치고

ProxyPass/ajp://localhost:9009/ctxPath/ 
ProxyPassReverse/ajp://localhost:9009/ctxPath/ 
ProxyPassReverseCookiePath /ctxPath/

?

답변

0

나는 이것이 아주 오래되었다는 것을 알고있다. 그러나 나는 그것을 얼마 전에 해결 했으므로 내 수정을 게시하는 것이 가치가 있다고 생각했다 - 올바른 방법인지는 모르겠지만, 작년!

# HTTP 302 redirects are not modified by the reverse proxy when using the AJP protocol. 
# https://tomcat.apache.org/connectors-doc/common_howto/proxy.html 
# Or perhaps Tomcat needs further configuration to support a proxy (See Connector config) 
# When sending a redirect, the redirect URL is placed in the 'Location' HTTP response header. 
# When the browser requests the page using the path in the Location header, 
# the proxy will dutifully proxy the request to the backend - which prefixes the context path. 
# This will cause the context path to appear twice and result in a 404. 
# ProxyPassReverse would usually modify the Location HTTP header, but using AJP it 
# appears no to, so take care of this ourselves by removing the context path from the 
# URL in the Location header before passing it back to the client. 
# Spring Security uses redirects during authentication 
Header edit Location /ctxPath/(.*)$ /$1