使用有效/无效的IPconfigurationhttpd

我们的服务器必须有networking接口。 首先有一个有效的IP,我们运行httpd,第二个有一个内部IP(192.168.XX)。 更多信息在下面列出

# cat /etc/hosts 127.0.0.1 localhost.localdomain localhost 192.168.1.5 srv1 # cat /etc/httpd/conf/httpd.conf ... <VirtualHost *:80> ServerAdmin [email protected] DocumentRoot /var/www/html/munin ServerName 124.205.99.114 ErrorLog logs/dummy-host.example.com-error_log CustomLog logs/dummy-host.example.com-access_log common <Directory /var/www/html/munin> Satisfy any </Directory> </VirtualHost> 

当我重启httpd时,我看到一个警告

 # /etc/init.d/httpd restart Stopping httpd: [ OK ] Starting httpd: httpd: Could not reliably determine the server's fully qualified domain name, using 192.168.1.5 for ServerName [ OK ] 

您可能会说这只是一个警告,但是当我在networking浏览器中inputIP地址时,index.html文件没有显示,我得到了The connection has timed out

更新:

似乎警告与“超时”问题无关。 iptables -nvL的输出如下所示

 # iptables -nvL Chain INPUT (policy ACCEPT 0 packets, 0 bytes) pkts bytes target prot opt in out source destination 1334K 146M ACCEPT all -- * * 0.0.0.0/0 0.0.0.0/0 state RELATED,ESTABLISHED 17 736 ACCEPT icmp -- * * 0.0.0.0/0 0.0.0.0/0 1259 486K ACCEPT all -- lo * 0.0.0.0/0 0.0.0.0/0 964 56148 ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:22 5 300 ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:2049 60244 7018K REJECT all -- * * 0.0.0.0/0 0.0.0.0/0 reject-with icmp-host-prohibited Chain FORWARD (policy ACCEPT 0 packets, 0 bytes) pkts bytes target prot opt in out source destination 0 0 REJECT all -- * * 0.0.0.0/0 0.0.0.0/0 reject-with icmp-host-prohibited Chain OUTPUT (policy ACCEPT 1183K packets, 1247M bytes) pkts bytes target prot opt in out source destination 

更新2:

我用这个命令允许端口80

 iptables -A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT 

可以用这个输出validation

 # iptables -nvL Chain INPUT (policy ACCEPT 0 packets, 0 bytes) pkts bytes target prot opt in out source destination .... 61165 7150K REJECT all -- * * 0.0.0.0/0 0.0.0.0/0 reject-with icmp-host-prohibited 0 0 ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:80 

我重新启动了服务networkhttpd但仍然无法在浏览器中打开index.html。

我会build议编辑你的httpd.conf文件并设置:

 ServerName 192.168.1.5:80 

另外,在iptables ,你没有规定在端口80上允许状态NEW

 iptables -A INPUT -p tcp --dport 80 -m state --state NEW -j ACCEPT 

您已经拥有RELATED,ESTABLISHED状态。

警告来自于在/ etc / hosts文件中没有与192.168.1.5关联的fqdn条目。 连接超时问题是别的。 也许你有防火墙规则禁止对主机的甜食。 用iptables -nvL检查一下