VirtualBox和CentOS 6,无法连接到httpd

我试图在Windows 7主机箱上使用CentOS 6 Minimalist Install和VirtualBox 4.1.4r74291在虚拟机中构buildCI服务器。

在你问之前:

  • 目前selinux被禁用(计划一旦这个问题消失后重新启用)
  • 我可以ssh进入它,我可以使用git推/拉它
  • 我甚至可以使用lynx来访问localhost:80和localhost:8080。 (我安装了512MB的内存,所以没有GUI来做任何事情。)
  • 我也可以ping / lynx google.com等

这里有一些命令输出:

ifconfig -a eth1 eth1 Link encap:Ethernet HWaddr 08:00:27:2B:4E:3C inet addr:192.168.1.104 Bcast:192.168.1.255 Mask:255.255.255.0 inet6 addr: fe80::a00:27ff:fe2b:4e3c/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:320629 errors:0 dropped:0 overruns:0 frame:0 TX packets:171826 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:445888239 (425.2 MiB) TX bytes:14540682 (13.8 MiB) nmap localhost Nmap scan report for localhost (127.0.0.1) Host is up (0.0000080s latency). Hostname localhost resolves to 2 IPs. Only scanned 127.0.0.1 Not shown: 994 closed ports PORT STATE SERVICE 22/tcp open ssh 25/tcp open smtp 80/tcp open http 8009/tcp open ajp13 8080/tcp open http-proxy 9418/tcp open git Nmap done: 1 IP address (1 host up) scanned in 0.09 seconds iptables -vL Chain INPUT (policy ACCEPT 0 packets, 0 bytes) pkts bytes target prot opt in out source destination 315K 441M ACCEPT all -- any any anywhere anywhere state RELATED,ESTABLISHED 0 0 ACCEPT icmp -- any any anywhere anywhere 6010 281K ACCEPT all -- lo any anywhere anywhere 4 208 ACCEPT tcp -- any any anywhere anywhere state NEW tcp dpt:ssh 8676 668K REJECT all -- any any anywhere anywhere 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 -- any any anywhere anywhere reject-with icmp-host-prohibited Chain OUTPUT (policy ACCEPT 184K packets, 13M bytes) pkts bytes target prot opt in out source destination netstat -aln | grep 80 tcp 0 0 :::8009 :::* LISTEN tcp 0 0 :::8080 :::* LISTEN tcp 0 0 :::80 :::* LISTEN tcp 0 0 ::ffff:127.0.0.1:8005 :::* LISTEN unix 2 [ ACC ] STREAM LISTENING 8093 public/cleanup unix 3 [ ] STREAM CONNECTED 8099 unix 3 [ ] STREAM CONNECTED 8098 unix 3 [ ] STREAM CONNECTED 8096 unix 3 [ ] STREAM CONNECTED 8095 unix 3 [ ] STREAM CONNECTED 8092 unix 3 [ ] STREAM CONNECTED 8091 unix 3 [ ] STREAM CONNECTED 8089 unix 3 [ ] STREAM CONNECTED 8088 unix 2 [ ] DGRAM 8054 unix 2 [ ] DGRAM 8013 

并从主持人:

 telnet 192.168.1.104 80 Could not open connection to the host, on port 80: Connect failed 

所以,这两个端口是开放的,看起来防火墙允许从外部连接这些端口(但是,老实说,我只是猜测,我不知道如何读取输出)然而,每当我尝试从主机访问Chrome浏览器中的192.168.1.104:(80|8080),我就会得到臭名昭着的:

 Oops! Google Chrome could not connect to 192.168.1.104 

这是可能的,因为我之前用Kubuntu安装(尽pipe如此),我试图移动到一个虚拟机,内存空间更小,安全性更高。

有什么build议么? 需要更多信息? 我现在全都是耳朵。

编辑:

在Janne的回答之后,httpd现在正在侦听192.168.1.104:80 。 因此,我不能再舔本地主机,做一个wget 127.0.0.1给我一个连接拒绝错误。 这是合适的,因为现在我必须使用lynx/wget 192.168.1.104来获得预先得到127.0.0.1(Apache的“It Works!”页面和index.html的下载页面)的结果。)另一个线索,也许?

我没有看到你的iptable4s将允许在端口80上的连接(除了允许在LO上的)的规则尝试打开端口80

 iptables -I INPUT -p tcp -m tcp --dport 80 -j ACCEPT 

要么

 iptables -I INPUT -i eth1 -p tcp -m tcp --dport 80 -j ACCEPT 

如果你想限制访问eth1上的连接。

这是在黑暗中的一个狂野的镜头:我猜你的Apache正在监听127.0.0.1而不是192.168.1.104

如果netstat -tlnp返回Apache正在监听127.0.0.1:80 ,那么它将根本不响应eth1stream量。

请参阅httpd.conf中的Listen指令。 应该说是192.168.1.104:80

编辑:嘿,这一定是关于iptables。 当你说“我可以使用git”时,你的意思是你使用git over ssh吗?

目前你的iptables的input规则似乎只允许新的连接到ssh端口,而不是端口80.尝试添加到您的iptables规则:

 iptables -I INPUT 1 -i eth1 -p tcp -d 0/0 --dport 80 -j ACCEPT