I have set up a virtual host (
sub.domain.com) on my local network server that is accessible from inside and from outside via port forwarding in my router. I would like to add an additional directory
sub.domain.com/only_local that can not be accessed from outside.
Using (Apache version 2.4.10 on a debian machine)
<Directory /var/www/only_local> AllowOverride None Require host localhost Require ip 127.0.0.1 Require ip 192.168.1 </Directory>
allows me to restrict external access. In this case, however, I can connect to the page only using the local address
192.168.1.10/only_local. Trying to open
sub.domain.com/only_local (from the local network!) yields
403 Forbidden, which is inconvenient, as domain names are much more catchy than ip addresses and my TLS certificates are valid for
As far as I understood this post this restriction is intended, as the server receives a connection request that seems to come from the external network due to address translation.
So what do I have to do, in order to obtain an exclusively locally accessible webpage that can be loaded using a domain name?