[英]Can't access virtualhost on CentOS 6 with apache 2.2.15
I have been looking around and trying different configurations on httpd.conf file of apache 2.2.15 server but I could not find a solution to my problem. 我一直在四处寻找并尝试对Apache 2.2.15服务器的httpd.conf文件进行不同的配置,但找不到解决方案。 So I am posting it here to get some help from a Guru.
因此,我将其发布在此处,以寻求Guru的帮助。
I have this configuration on my /etc/httpd/conf/httpd.conf on CentOS 6.7 server. 我在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>
When I browse to http://example.com I get Laravel page (as expected) but when I browse to http://example.com:8080 I get "the connection has time out" . 当我浏览到http://example.com时,我得到了Laravel页面(按预期),但是当我浏览到http://example.com:8080时,我得到了“连接超时”的信息 。
I have already opened the port for 8080 on the IP tables 我已经在IP表上打开了8080的端口
output of netstat -nltup
tcp 0 0 :::8080 :::* LISTEN 13097/httpd
tcp 0 0 :::80 :::* LISTEN 13097/httpd
and 和
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
I don't see anything in the logs. 我没有在日志中看到任何东西。 Although it seems apache is listening on port 8080, nothing gets through and logged for port 8080.
尽管似乎Apache正在监听8080端口,但8080端口并没有通过任何日志记录。
Any suggestion to resolve this problem? 有解决这个问题的建议吗?
The port is not supposed to be part of the ServerName
directive. 该端口不应该是
ServerName
指令的一部分。
Please remove the port from the ServerName
directive like this: 请从
ServerName
指令中删除端口,如下所示:
<VirtualHost *:8080>
ServerName example.com
DocumentRoot /var/www/dbgui
ErrorLog logs/dbgui-8080-error_log
<Directory /var/www/dbgui>
AllowOverride All
</Directory>
</VirtualHost>
See the examples on apache.org for reference 请参阅apache.org上的示例以供参考
您应该检查NameVirtualHost
参数,以确保可以从IP /端口组合中猜出虚拟主机
Thanks guys for your help. 谢谢大家帮助。 After a lot of research and trying different things and just before throwing a chair, I finally resolved it.
经过大量研究并尝试了不同的方法,然后在扔椅子之前,我终于解决了。 Here it is: After making sure iptables has correct opened ports and protocol for tcp/8080 Next, double check the VirtualHost setup is correct and the above setup is correct.
它是这样的:确保iptables正确打开了tcp / 8080的端口和协议后,接下来,再次检查VirtualHost设置是否正确并且上述设置正确。 Next thing I did was made sure selinux is not blocking port 8080 by either disable it all together or set it to permissive mode.
接下来我要做的是确保将全部禁用或将其设置为许可模式,从而确保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
As it can be seen, port 8080 is listed in http_cache_port_t and now make sure selinux does not block that 可以看出,端口8080在http_cache_port_t中列出,现在确保selinux不会阻止该端口
#setsebool -P httpd_can_network_memcache 1
then list it to make sure, it sets to "on" or "1" 然后列出它以确保将其设置为“ on”或“ 1”
# getsebool httpd_can_network_memcache
none of the above commands did not resolve the problem, while I was investigating the logs /var/log/audit/audit.log
and /var/log/httpd/access_log and /var/log/httpd/error_log
I could not find anything wrong related to port 8080 After all that, I started thinking that it does not make sense because everything configured correctly but I cannot get through. 以上所有命令均不能解决问题,而我正在调查日志
/var/log/audit/audit.log
和/ var / log / httpd / access_log和/var/log/httpd/error_log
我什么也找不到与端口8080有关的错误毕竟,我开始认为它没有意义,因为所有配置均正确,但我无法通过。 So I just took a second look at iptables output: 所以我只看了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
Which shows 0 packet and 0 bytes came through the server. 其中显示了0个数据包和0个字节通过服务器。 I found this site
我找到这个网站
http://www.yougetsignal.com/tools/open-ports/
It showed the port 8080 is blocked. 它表明端口8080被阻塞。 While holding the chair in the air as the last resort :), I contacted ISP and I was told there is firewall in front of the server and port 8080 is blocked and when they opened it, I put the chair down because I finally got access.
当最后把椅子举在空中的时候:),我联系了ISP,并被告知服务器前面有防火墙,端口8080被阻止,当他们打开它时,我放下椅子,因为我终于可以访问了。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.