0

I try to open port 81 as a virtualhost. after setting apache, I can CURL localhost:81 from local machine and get response(yes it was listening port 81). However, when visit the same address from remote browser, browser always show TIME OUT error.

I thought it might be due to firewall or selinux, so I disable both of them and try again but still failed. The commands I used to disable selinux and firewall are as below:

to disable selinux:

open /etc/selinux/config and change SELINUX=disabled and then reboot. I use sestatus command to check and output shows it was disabled.

to close iptables:

service iptables stop
chkconfig iptables off

and I close ip6tables either:

service ip6tables stop
chkconfig ip6tables off

I am using CentOS 6.3. Are there other security issues besides selinux and iptables that I didn't notice?

Add more information

I use IP address directly, like 123.123.123.123:81. I don't think it is due to apache conf since I can get response from local server machine through both curl locahlost:81 and curl 123.123.123.123:81.

Netstat result

after running netstat command, I got the

tcp        0      0 :::80                       :::*                        LISTEN      1809/httpd          
tcp        0      0 :::81                       :::*                        LISTEN      1809/httpd  

seems both 80 and 81 are working.

Ifconfig

here is the ifconfig -a result:

eth0  Link encap:Ethernet  HWaddr 00:50:56:9B:24:D6  
      inet addr:101.251.235.162  Bcast:101.251.235.163  Mask:255.255.255.252
      inet6 addr: fe80::250:56ff:fe9b:24d6/64 Scope:Link
      UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
      RX packets:16046 errors:0 dropped:0 overruns:0 frame:0
      TX packets:15092 errors:0 dropped:0 overruns:0 carrier:0
      collisions:0 txqueuelen:1000 
      RX bytes:3370807 (3.2 MiB)  TX bytes:2352380 (2.2 MiB)

lo    Link encap:Local Loopback  
      inet addr:127.0.0.1  Mask:255.0.0.0
      inet6 addr: ::1/128 Scope:Host
      UP LOOPBACK RUNNING  MTU:65536  Metric:1
      RX packets:70 errors:0 dropped:0 overruns:0 frame:0
      TX packets:70 errors:0 dropped:0 overruns:0 carrier:0
      collisions:0 txqueuelen:0 
      RX bytes:19119 (18.6 KiB)  TX bytes:19119 (18.6 KiB)
  • add to the post which address are you using to visit it, and the relevant Apache config. @harry answer seems ok, if it not works you may have got some interaction with IPv6. – Rui F Ribeiro Jan 21 '16 at 7:22
  • it still not work. I added some information. How do you mean interaction with IPv6? – franky Jan 21 '16 at 7:38
  • show ifconfig -a please – Rui F Ribeiro Jan 21 '16 at 7:48
  • too long to put in comments, added to the post already. – franky Jan 21 '16 at 8:03
  • Are you using the same 255.255.255.252 network mask in the client? – Rui F Ribeiro Jan 21 '16 at 8:14
1

First check to make sure that your server is listening on the port you want, not just local host

netstat -plnt

Should give you an output similar to this:

Proto Recv-Q Send-Q Local Address   Foreign Address  State       PID/Program name
tcp        0      0 127.0.1.1:53     0.0.0.0:*       LISTEN      -               
tcp        0      0 10.0.3.1:53      0.0.0.0:*       LISTEN      -               
tcp        0      0 127.0.0.1:631    0.0.0.0:*       LISTEN      -               
tcp        0      0 127.0.0.1:6680   0.0.0.0:*       LISTEN      -       

Check the Local Address column to make sure your server is listening on *:81 or ip.ad.dr.ess:81 and not just localhost:81 or 127.0.0.1:81

If that's the case, check httpd.conf and make sure that the server is set to Listen *:81 and not Listen localhost:81

If you httpd.conf is fine, check your virtual host config too, to make sure your listening to everything

<VirtualHost *:81>
  • you forgot to mention Apache has to be restarted – Rui F Ribeiro Jan 21 '16 at 7:24
  • you can see in my edited post that both 80 and 81 are listened. And I checked httpd.conf again, which has Listen 81 and <VirtualHost *:81>. Still not work :( – franky Jan 21 '16 at 7:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.