我使用proxy_ajp来连接Apache 和 Tomcat 然后发现我的一切都很正常,但是发现可以再本机通过localhost(127.0.0.1)访问,但是不能通过IP访问。
查了各方面资料,对在这个问题的搜索过程中出现的各种回答都试过了,没有一个能解决我问题的回答。最后发现问题在这:
在httped.conf中我们打开了#Include conf/extra/httpd-vhosts.conf这个配置,但是在extra/httpd-vhosts.conf这个问题件中虚拟主机添加错误:
<VirtualHost *:80>
ServerAdmin liangdongfairy@126.com
ServerName 127.0.0.1 //这里,应该配置为自己的实际IP,负责不能通过IP来访问服务器,提示错误404
ServerAlias localhost
ProxyPass / balancer://cluster/ stickysession=jsessionid nofailover=On
ProxyPassReverse / balancer://cluster/
ErrorLog "logs/lbtest-error.log"
CustomLog "logs/lbtest-access.log" common
</VirtualHost>
改为自己的IP,问题迎刃而解,另外在这里特别感谢一篇文章的作者,非常感谢。
zyycaesar
blog:http://zyycaesar.iteye.com/
希望有人和我一样碰到这种问题,可以根据这个思路来解决。