3

A server on my local network is running Apache2 that hosts a site accessible from the Internet. I can access that site from outside the network just fine, but not from inside it.

That is, I can't access the web site when my Internet connection is provided by the same router that provides Internet access to the web server.

I get the idea this is because the router does not allow two connection on port 80 at the same time, but I could be wrong. Any thoughts?

2 Answers 2

4

The problem is that your router (a home or SoHo one I presume) will not port forward on the internal interface.

What is happening goes along these lines:

  1. PC on your LAN does a DNS lookup for your website and gets your Router's public IP address
  2. Web browser sends its requests on port 80 to your public IP address
  3. Your router gets the request on its internal interface and since it has no port forwarding capability on this interface it either sends it to its own web site or just drops it rather than forwarding it to your webserver.

To get around it you will have to use the local IP address of your webserver - you should put this in your Hosts file so that you can still access it using its URL rather than IP address to allow virtual hosts to work.

For example add the line www.mygreatwebsite.com 192.168.1.10 to your hosts file (naturally inserting your actual details) and use www.mygre... rather than the IP address so that when your browser's HTTP request hits Apache it gets the URL so virtual hosts can work.

2
  • The server is using virtual hosts, so the local IP address just displays Apache's "It Works" page. Do you think it would work if I could set it up to forward connections on the internal interface to the web server? I don't need to access the setup page for the router since it's managed by the ISP and I don't have access to it anyway.
    – fluffels
    Feb 9, 2010 at 11:28
  • Either set it as the default website in Apache or add its IP address to your hosts file so that your browser still sends the URL in its headers - have edited my answer to reflect this Feb 9, 2010 at 11:54
1

It sounds as though the apache web server is not listning for connections on your internal IP address.

If you have a look in your httpd.conf there should be a line called listen with an ip address and port. If you want additional listens just make a new line and enter something like

Listen 192.170.2.5:8000 

Also do you have a firewall installed that might be causing the problem?

2
  • I don't think it's that. When I access the local address I get Apache's default page. This server is using virtual hosts, which is why I don't get the proper web site. There's no firewall installed on the server, but there's one on the router.
    – fluffels
    Feb 9, 2010 at 11:25
  • the firewall should not affect your connection to your server internally. sadly my knowlege of apache is limited but i would hazard a guess that there is something amiss in your config file which is causing the problem
    – Ben Gillam
    Feb 9, 2010 at 11:37

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .