4

On my Apache 2.x server at home, I have a number of virtual directories. I've set up my router so that I can access Apache from the internet. I need to keep one of those virtual dirs (/private) from being accessed outside my home network LAN. So given /private, how do I configure Apache to only serve requests to /private from 192.168.4.x?

chaos
  • 122,029
  • 33
  • 303
  • 309
user86282
  • 55
  • 1
  • 3

1 Answers1

10
<Directory /users/me/private>
    Order deny,allow
    Allow from 192.168.4
    Deny from all
</Directory>
chaos
  • 122,029
  • 33
  • 303
  • 309
  • I tried the following: Alias /private /users/me/private Order allow,deny Allow from 192.168.4 Deny from all I restarted Apache yet I still can access the site via the Internet. I tested it using my smartphone browser running on the Verizon network. ?? – user86282 Apr 02 '09 at 16:28
  • Use the actual system pathname to the directory, /users/me/private, in the Directory config, or use a Location instead. – chaos Apr 02 '09 at 16:59
  • Using the actual path now give me a '403 Forbidden' error from both outside and inside of my network: You don't have permission to access /private on this server. – user86282 Apr 02 '09 at 17:25
  • Sorry, wrote the Order directive wrong. Should be deny,allow. Edited to fix. – chaos Apr 02 '09 at 17:31
  • (I do that sometimes since the semantics of the Order directive are the exact opposite of what they seem to me like they should be.) – chaos Apr 02 '09 at 17:32
  • How about if you want /private to be password protected instead? nvm: https://wiki.apache.org/httpd/PasswordBasicAuth – Pablo Dec 02 '14 at 16:01