Apache http代理和反向代理

时间:2014-11-07 09:38:43

标签: apache proxy reverse-proxy httpserver proxypass

我需要定义两个虚拟主机,它应该将我的请求转发给不同的Web应用程序。 安装appache的PC的IP为:192.168.100.208。 安装应用程序的应用程序服务器的IP是:192.168.100.50

<VirtualHost *:7778>
ServerName 192.168.100.208

ProxyRequests On
ProxyPreserveHost Off
<Proxy *>
    Order allow,deny
    Allow from all
</Proxy>
ProxyErrorOverride On

ProxyPass / http://192.168.100.50:9081/app1/
ProxyPassReverse / http://192.168.100.50:9081/app1/

 <Location>
            Order allow,deny
            Allow from all
</Location>

我需要:

<VirtualHost *:7777>
ServerName 192.168.100.208

ProxyRequests On
ProxyPreserveHost Off
<Proxy *>
    Order allow,deny
    Allow from all
</Proxy>
ProxyErrorOverride On

ProxyPass / http://192.168.100.50:9081/app2/
ProxyPassReverse / http://192.168.100.50:9081/app2/

 <Location>
            Order allow,deny
            Allow from all
</Location>

所以当我输入浏览器时:

192.168.100.208:7778 i should get page from 192.168.100.50:9081/app1

192.168.100.208:7777 i should get page from 192.168.100.50:9081/app2

但上面没有用。错误在哪里?

1 个答案:

答案 0 :(得分:0)

确保还配置了以下内容:

#
# Use name-based virtual hosting.
#
NameVirtualHost *:7778
NameVirtualHost *:7777