我有一个Apache 2.2服务器和一个现有的虚拟主机(foo.com)代理内部服务器。
我已经添加了另一个虚拟主机(bar.com),我想代理到不同的内部服务器。
我的vhost.conf文件看起来像这样(减去一些注释和匿名):
# START <VirtualHost *:80> ProxyPreserveHost On ProxyPass / http://foointernal:80/ ProxyPassReverse / http://foointernal:80/ DocumentRoot "E:/Apache/htdocs/foo/" ServerName foo.com ServerAlias foo.com ServerAdmin [email protected] ErrorLog "E:/Apache/logs/foo_error.log" TransferLog "E:/Apache/logs/foo_ccess.log" </VirtualHost> <VirtualHost *:80> ProxyPreserveHost On ProxyPass / http://barinternal:80/ ProxyPassReverse / http://barinternal:80/ DocumentRoot "E:/Apache/htdocs/bar/" ServerName bar.com ServerAlias bar.com ServerAdmin [email protected] ErrorLog "E:/Apache/logs/bar_error.log" TransferLog "E:/Apache/logs/bar_access.log" </VirtualHost> # END
当我在浏览器中打开http://foo.com时,一切正常。 我得到我期望的内部服务器等
当我在浏览器中打开http://bar.com时,我得到了foo.com使用的内部服务器
似乎与代理部分没有任何关系,因为当我注释掉代理*行foo
和bar
的DocumentRoot时,它们仍然是交叉连接的。
为什么以及如何说服Apache 2.2代理服务器?
所呈现的configuration应该工作。 你只能得到第一个虚拟主机,表明其他未显示的东西是错误configuration的。
检查你是否有合适的NameVirtualHost
指令。