apache的proxy代理总访问后端web的第一个虚拟主机
问题,如题。怎么折腾都是一直访问第一个虚拟主机,后来找到问题所在。是我配置的不对。错误配置是这样的:<VirtualHost *>
ServerName www.test.com
CustomLog "/dev/null" combined
ProxyRequests Off
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
ProxyPass / http://192.168.13.111/
ProxyPassReverse / 192.168.13.111/
</VirtualHost> 问题出在了: ProxyPass / http://192.168.13.111/
要改成这样: ProxyPass / http://www.test.com/
所以正确的配置是这样的:<VirtualHost *>
ServerName www.test.com
CustomLog "/dev/null" combined
ProxyRequests Off
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
ProxyPass / http://www.test.com/
ProxyPassReverse / 192.168.13.111/
</VirtualHost> 另外需要注意的是,需要在/etc/hosts 中加一条记录
192.168.13.111 www.test.com
ServerName www.test.com
CustomLog "/dev/null" combined
ProxyRequests Off
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
ProxyPass / http://192.168.13.111/
ProxyPassReverse / 192.168.13.111/
</VirtualHost>
要改成这样: ProxyPass / http://www.test.com/
所以正确的配置是这样的:
ServerName www.test.com
CustomLog "/dev/null" combined
ProxyRequests Off
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
ProxyPass / http://www.test.com/
ProxyPassReverse / 192.168.13.111/
</VirtualHost>
192.168.13.111 www.test.com
none