带有VirtualHost的Apache反向代理不能提供页面

我有一个Apache反向代理将请求移动到一个Tomcat小程序。 configuration类似于:

<VirtualHost 100.100.100.100:80> ProxyPass /AppName/App http://1.1.1.1/AppName/App ProxyPassReverse /AppName/App http://1.1.1.1/AppName/App </VirtualHost> 

我还有一个名为summary.html的页面,它存在于1.1.1.1上:

http://1.1.1.1/AppName/summary.html

当我直接浏览到它,我没有问题查看它,但是如果我试图通过反向代理到那里,我得到一个空白页。 Wireshark向我展示了一个503,但是这个来自Apache反向代理(IP 100.100.100.100),而不是Tomcat(IP 1.1.1.1)。

我应该添加http://1.1.1.1/AppName/到configuration? 怎么样? 我尝试了,但是我得到了一个空白页面,但是这个在浏览器的URL栏上显示了Tomcat的内部IP,所以,不行。

帮助表示赞赏。

谢谢。

编辑:这是从Wireshark转储:

 GET /AppName/ HTTP/1.1 Host: 100.100.100.100 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/534.52.7 (KHTML, like Gecko) Version/5.1.2 Safari/534.52.7 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 Cache-Control: max-age=0 Accept-Language: en-us Accept-Encoding: gzip, deflate Connection: keep-alive HTTP/1.1 404 Not Found Date: Tue, 30 Jan 2012 09:08:51 GMT Server: Apache Content-Length: 1 Connection: close Content-Type: text/html; charset=iso-8859-1 

像这样添加它应该工作得很好:

 <VirtualHost 100.100.100.100:80> ProxyPass /AppName/ http://1.1.1.1/AppName/ ProxyPassReverse /AppName/ http://1.1.1.1/AppName/ </VirtualHost> 

甚至:

 <VirtualHost 100.100.100.100:80> ProxyPass /AppName/summary.html http://1.1.1.1/AppName/summary.html ProxyPassReverse /AppName/summary.html http://1.1.1.1/AppName/summary.html ProxyPass /AppName/App http://1.1.1.1/AppName/App ProxyPassReverse /AppName/App http://1.1.1.1/AppName/App </VirtualHost> 

你可以澄清什么问题发生时,你有这样的configuration? 我不太清楚你的意思是“这个在浏览器的URL栏上显示的是Tomcat的内部IP”。

我会使用重写规则。

http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html#rewriterule

尝试:

 <VirtualHost 100.100.100.100:80> RewriteRule ^/AppName/(.*) http://1.1.1.1/AppName$1 [P] </VirtualHost> 

我怀疑你忘记了“ProxyPreserveHost On”。

如果没有这个指令,你的应用程序将与HTTP“Host:1.1.1.1”标题进行联系,而当你直接浏览时,会看到“Host:the.domain.com”。