You are not logged in.

#1 2009-01-10 04:39:53

void.pointer
Member
From: Dallas, TX
Registered: 2008-07-30
Posts: 239

[SOLVED] Apache & 2 document roots: Is this possible?

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

#2 2009-01-10 13:19:39

luca
Member
From: Rome
Registered: 2005-10-30
Posts: 280

Re: [SOLVED] Apache & 2 document roots: Is this possible?

Hi void.pointer,
I think you can use htaccess, see this article:
http://perishablepress.com/press/2007/1 … ected-site

Offline

#3 2009-01-10 13:23:23

DonVla
Member
From: Bonn, Germany
Registered: 2007-06-07
Posts: 997

Re: [SOLVED] Apache & 2 document roots: Is this possible?

void.pointer wrote:

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

#4 2009-01-10 13:50:37

Xyne
Administrator/PM
Registered: 2008-08-03
Posts: 6,963
Website

Re: [SOLVED] Apache & 2 document roots: Is this possible?

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 StuffForum EtiquetteCommunity Ethos - Arch is not for everyone

Offline

#5 2009-01-10 15:28:16

void.pointer
Member
From: Dallas, TX
Registered: 2008-07-30
Posts: 239

Re: [SOLVED] Apache & 2 document roots: Is this possible?

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 smile

Offline

Board footer

Powered by FluxBB