使用AJP和Tomcat 302重定向的Apache反向代理

使用AJP和Tomcat 302重定向的Apache反向代理,apache,reverse-proxy,http-status-code-302,ajp,tomcat8.5,Apache,Reverse Proxy,Http Status Code 302,Ajp,Tomcat8.5,我对这一点完全没有想法,我想我需要寻求对ApacheHTTPD(2.4)和Tomcat(8.5)有很好理解的人的帮助 我有一个SpringMVC4Web应用程序,当我绕过代理访问它时,它工作得非常好,但是,每当我通过代理访问导致302重定向的链接时,它就会失败 直接使用时,我会被重定向到正确的路径,因此我知道不是web应用程序向客户端提供了错误的URL。但是,通过代理,我被重定向到一个位置,该位置似乎在URL前面加上上下文路径,而上下文路径已经存在!因此,它出现了两次,因此有一个不存在的URL请

我对这一点完全没有想法,我想我需要寻求对ApacheHTTPD(2.4)和Tomcat(8.5)有很好理解的人的帮助

我有一个SpringMVC4Web应用程序,当我绕过代理访问它时,它工作得非常好,但是,每当我通过代理访问导致302重定向的链接时,它就会失败

直接使用时,我会被重定向到正确的路径,因此我知道不是web应用程序向客户端提供了错误的URL。但是,通过代理,我被重定向到一个位置,该位置似乎在URL前面加上上下文路径,而上下文路径已经存在!因此,它出现了两次,因此有一个不存在的URL请求

当我查看Tomcat的访问日志时,我可以看到它在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对使用AJP连接器的HTTPD的响应。当直接访问页面时,它通过HTTP连接器进行访问,工作正常。我更新了我的HTTPD配置以使用HTTP连接器,并为302重定向获得相同的结果

如您所见,每个重定向都会导致404。我是否必须以某种方式更改Tomcat的配置

目前,我的HTTPD配置如下所示(端口9009是正确的,因为我有多个Tomcat安装):


我错过了什么?

我知道这已经很旧了,但我确实在不久前解决了它,所以我认为发布我的修复程序是值得的-不确定它是否是“正确”的方式,但它似乎在去年完成了这项工作

# 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

我知道这是非常古老的现在,但我确实解决了一段时间前,所以认为这将是值得张贴我的修复-不知道它是否是'正确'的方式,但它似乎已经完成了去年的工作

# 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