ProxyPass整个域到Tomcat,包括root


8

我已经将VirtualHost example.com配置为将所有请求代理到Tomcat服务器

ProxyPass / http://localhost:8088/app
ProxyPassReverse / http://localhost:8088/app

这工作得很好了像URL example.com/page,但对于example.comexample.com/我得到这个重定向响应,这显然会导致什么。

HTTP/1.1 302 Moved Temporarily
Date: Wed, 06 Jul 2011 21:13:37 GMT
Server: Apache-Coyote/1.1             <-- the redirect comes from tomcat
Location: http://example.com/app/     <-- nonsense
...

我该如何解决?最好在Apache配置中。

我正在使用Apache 2和Tomcat 7

Answers:


10

我不确定为什么,但这就是解决方法

ProxyPass / http://localhost:8088/app/
ProxyPassReverse / http://localhost:8088/app/

(在末尾添加了斜线)


8
斜线应始终匹配。来自mod_proxy文档If the first argument ends with a trailing /, the second argument should also end with a trailing / and vice versa. Otherwise the resulting requests to the backend may miss some needed slashes and do not deliver the expected results.
Shane Madden
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.