我一直在寻找并尝试apache 2.2.15服务器的httpd.conf文件上的不同配置,但我找不到解决问题的方法。所以我把它贴在这里是为了得到一位大师的帮助。
我在CentOS 6.7服务器上的/etc/httpd/conf/httpd.conf上有这个配置。
Listen 80
Listen 8080
<VirtualHost *:8080>
ServerName example.com (Corrected after the comment)
DocumentRoot /var/www/dbgui
ErrorLog logs/dbgui-8080-error_log
<Directory /var/www/dbgui>
AllowOverride All
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerName example.com
DocumentRoot /var/www/laravel/public
ErrorLog logs/example-80-error_log
<Directory /var/www/laravel>
AllowOverride All
</Directory>
</VirtualHost>
当我浏览到http://example.com我得到了Laravel页面(如预期),但当我浏览到http://example.com:8080我得到"连接超时"。
我已经在IP表上打开了8080的端口
output of netstat -nltup
tcp 0 0 :::8080 :::* LISTEN 13097/httpd
tcp 0 0 :::80 :::* LISTEN 13097/httpd
和
Output of iptables -L -nv
0 0 ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp dpt:8080
669 41648 ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp dpt:80
我在日志里什么也没看到。尽管apache似乎在监听8080端口,但没有任何东西通过并记录到8080端口。
有什么解决这个问题的建议吗?
感谢大家的帮助。经过大量的研究和尝试,就在扔椅子之前,我终于解决了这个问题在确保iptables具有正确的tcp/8080打开端口和协议之后接下来,仔细检查VirtualHost设置是否正确,以及上述设置是否正确。我所做的下一件事是通过将selinux全部禁用或设置为允许模式来确保它不会阻塞端口8080。
#semanage port -l | grep http
http_cache_port_t tcp 3128, 8080, 8118, 8123, 10001-10010
http_cache_port_t udp 3130
http_port_t tcp 80, 81, 443, 488, 8008, 8009, 8443, 9000
pegasus_http_port_t tcp 5988
pegasus_https_port_t tcp 5989
可以看出,端口8080列在http_cache_port_t中,现在请确保selinux不会阻止
#setsebool -P httpd_can_network_memcache 1
然后列出它以确保它设置为"on"或"1"
# getsebool httpd_can_network_memcache
上面的命令都没有解决问题,当我调查日志/var/log/audit/audit.log
和/var/log/httpd/access_log以及/var/log/httpd/error_log
时,我没有发现任何与端口8080有关的错误在那之后,我开始认为这没有意义,因为一切都配置正确,但我无法通过。所以我只看了一下iptables的输出:
#iptables -L -nv
0 0 ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp dpt:8080
25 1316 ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp dpt:80
24 1240 ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp dpt:443
它显示0个数据包和0个字节通过服务器。我发现这个网站
http://www.yougetsignal.com/tools/open-ports/
它显示端口8080被阻塞。在万不得已的情况下,我把椅子举在空中:),我联系了ISP,被告知服务器前面有防火墙,8080端口被封锁,当他们打开它时,我放下了椅子,因为我终于可以访问了。
端口不应该是ServerName
指令的一部分。
请从ServerName
指令中删除端口,如下所示:
<VirtualHost *:8080>
ServerName example.com
DocumentRoot /var/www/dbgui
ErrorLog logs/dbgui-8080-error_log
<Directory /var/www/dbgui>
AllowOverride All
</Directory>
</VirtualHost>
请参阅apache.org上的示例以获取参考
您应该检查NameVirtualHost
参数,以确保可以从您的ip/端口组合中猜到虚拟主机