I have setup a Virtual Host with Apache2 with the following configuration:
<VirtualHost *:8080>
ServerName example.com
DocumentRoot /var/www/example.com
</VirtualHost>
It is possible to access the website from the outside.
example.com
But if I enter example.com
from another system in my local network, it opens my router configuration page.
I forwarded my routers port 80 to my servers port 8080 in my network.
But I would like to access the website as well from my other systems in the local network. Is this possible?
Your router probably does not support "NAT loopback", where you access a service on the local network via the WAN IP of the router. Most consumer grade routers do not support NAT loopback.
You only have 2 options:
Change your router to one that does support "NAT loopback".
eg. Which NETGEAR routers support NAT loopback
Access your service via the internal IP address instead. You can override the public DNS using your local HOSTS file.
The way I generally "work around" this and have the site accessible to all machines/devices on the LAN, is to define a local
subdomain (A
record) in the public DNS that points to the local IP address. So when on the LAN I access the site by the subdomain local.example.com
instead.
Related question on Security SE, which goes into more detail about what actually goes on with the network traffic: