Apache如何作为多个站点的反向代理?

我有我的Apache服务器端口80上运行。

我还有一个在Jetty 8080端口上运行的Geoserver。为了避免JavaScript中的跨域问题,我希望任何来自http://example.com/geoserver请求代理到http://servername:8080/geoserver

我目前正在使用Virtual_host和mod_proxy来做到这一点。 我的httpd.conf有以下代码:

 <VirtualHost *:80> ProxyPass /geoserver http://localhost:8080/geoserver ProxyPassReverse /geoserver http://localhost:8080/geoserver </VirtualHost> 

现在我需要Apache作为另一个在端口5000上使用node.js运行的应用程序的反向代理。如果我在http.conf中添加下面的代码:

 <VirtualHost *:80> ProxyPass /DocHub http://localhost:5000 ProxyPassReverse /DocHub http://localhost:5000 </VirtualHost> 

我在Apache日志中看到以下警告: _default_ VirtualHost overlap on port 80, the first has precedence 。 而对http://example.com/DocHub的请求会给出404错误。

有没有一种方法可以将Apache用作多个站点的反向代理? 有没有另外一种方法来实现我想要做的事情?

这是我得到它的工作。 我不确定这是正确的还是错误的。 也许更有经验的人可以提供input。

而不是将它们保存在单独的VirtualHost标记中,而是将它们放在相同的标记中,如下所示:

 <VirtualHost *:80> ProxyPass /geoserver http://localhost:8080/geoserver ProxyPassReverse /geoserver http://localhost:8080/geoserver ProxyPass /DocHub http://localhost:5000 ProxyPassReverse /DocHub http://localhost:5000 </VirtualHost> 

这似乎是为我工作。