You are not logged in.
Hi,
I realize this is very Apache specific and I should probably be posting this on an apache mailing list, however it's such a hassle to do so. I am hoping that someone has enough expertise with Apache to answer this question here since it would be convenient.
There's a couple of things in my document root that I do not want to be accessible on public domain. In other words, I only want it accessible to my LAN. Other things I want to be accessible on public domain (Internet). Is there any way to accomplish this without having 2 apache daemons running simultaneously on my system? I would prefer to keep the ports the same, but this isn't a requirement. Perhaps I can use .htaccess files to restrict certain subdirectories in my document root to only computers on my local area network?
Help is appreciated, thank you.
Last edited by void.pointer (2009-01-10 15:28:30)
Offline
Hi void.pointer,
I think you can use htaccess, see this article:
http://perishablepress.com/press/2007/1 … ected-site
Offline
There's a couple of things in my document root that I do not want to be accessible on public domain. In other words, I only want it accessible to my LAN. Other things I want to be accessible on public domain (Internet). Is there any way to accomplish this without having 2 apache daemons running simultaneously on my system? I would prefer to keep the ports the same, but this isn't a requirement. Perhaps I can use .htaccess files to restrict certain subdirectories in my document root to only computers on my local area network?
Help is appreciated, thank you.
set up virtual hosts: http://httpd.apache.org/docs/2.0/vhosts/
Offline
luca is right, you can do this with .htaccess files. Here's an example from one of my .htaccess files:
Order Deny,Allow
SetEnvIf Remote_Addr "^127\.0\.0\.1$" trusted
SetEnvIf Remote_Addr "^192\.168\.1\.\d+$" trusted
Allow from env=trusted
Deny from all
This allows connections from my localhost and from computers on my LAN, but not from outside. The match pattern uses Perl's regular expression syntax. Any directory (and subdirectory thereof) with this .htaccess file will not be accessible to anyone outside of my LAN.
Double-check that you've configured Apache to use mod_access (I think it was clear in the configuration file, but google it if you're still not sure). Check http://httpd.apache.org/docs/1.3/mod/mod_access.html for more information on mod_access to get ideas of what you can do with it.
*edit*
Just a quick note on what the "Order Deny,Allow" line is doing: I deny everyone access to the directory, then selectively make exceptions. If I switched the order to "Allow,Deny", "Deny from all" would override my allows.
Last edited by Xyne (2009-01-10 13:53:57)
My Arch Linux Stuff • Forum Etiquette • Community Ethos - Arch is not for everyone
Offline
Thanks for the sample code Xyne, this works perfectly. Oh how I wish I knew Apache a bit better so I could do this all myself
Offline