Restrict access to localhost only

This is a discussion on Restrict access to localhost only within the Apache Web Server forums, part of the Web Server and Related Forums category; I want to prevent access to a specific directory with a .htaccess file. Only the local PHP module should be ...


Go Back   Usenet Forums > Web Server and Related Forums > Apache Web Server

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 08-24-2004
Jörg Ellermann
 
Posts: n/a
Default Restrict access to localhost only

I want to prevent access to a specific directory with a .htaccess file. Only the
local PHP module should be allowed to access that directory.

I've put a .htaccess file in the directory:

<Directory />
Order Deny,Allow
Deny from all
Allow from (server's address here)
</Directory>

but it does not seem to work, though. By the way, would "localhost" be a legal
address in this directive?

Thanks,
Jörg
  #2 (permalink)  
Old 08-24-2004
Matt
 
Posts: n/a
Default Re: Restrict access to localhost only

Jörg Ellermann wrote:

> I want to prevent access to a specific directory with a .htaccess file. Only the
> local PHP module should be allowed to access that directory.
>
> I've put a .htaccess file in the directory:
>
> <Directory />
> Order Deny,Allow
> Deny from all
> Allow from (server's address here)
> </Directory>
>
> but it does not seem to work, though. By the way, would "localhost" be a legal
> address in this directive?


Yes, localhost or 127 (as in 127.0.0.1)

<Directory />
Order Deny,Allow
Deny from all
Allow from 127
Allow from example.net
</Directory>

Consider keeping whatever files these are out of the document root, that
is, outside of public_html or whatever.

--
Matt


-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 100,000 Newsgroups - 19 Different Servers! =-----
  #3 (permalink)  
Old 08-24-2004
Jörg Ellermann
 
Posts: n/a
Default Re: Restrict access to localhost only

Matt wrote:

>>I've put a .htaccess file in the directory:
>>
>><Directory />
>>Order Deny,Allow
>>Deny from all
>>Allow from (server's address here)
>></Directory>
>>
>>but it does not seem to work, though.


> Yes, localhost or 127 (as in 127.0.0.1)
>
> <Directory />
> Order Deny,Allow
> Deny from all
> Allow from 127
> Allow from example.net
> </Directory>


Thanks for answering. Although I've already found it - I didn't change the main
server config to allow .htaccess overrides.

BTW, after changing that, the above resulted in a sever error - <Directory> is
not allowed in .htaccess files.

Jörg
  #4 (permalink)  
Old 08-24-2004
Jeppe Uhd
 
Posts: n/a
Default Re: Restrict access to localhost only

Jörg Ellermann wrote:
> Matt wrote:
>
>> <Directory />
>> Order Deny,Allow
>> Deny from all
>> Allow from 127
>> Allow from example.net
>> </Directory>

>
> Thanks for answering. Although I've already found it - I didn't
> change the main server config to allow .htaccess overrides.
>
> BTW, after changing that, the above resulted in a sever error -
> <Directory> is not allowed in .htaccess files.


Well... Think of the .htaccess file as having an implicit "<Directory .>"
:-)

--
MVH Jeppe Uhd - NX http://nx.dk
Webhosting for nørder og andet godtfolk


  #5 (permalink)  
Old 08-27-2004
Erik
 
Posts: n/a
Default Re: Restrict access to localhost only


>BTW, after changing that, the above resulted in a sever error - <Directory> is
>not allowed in .htaccess files.
>


because .htaccess only works for the directory it is IN....


frgr
Erik
  #6 (permalink)  
Old 08-27-2004
Erik
 
Posts: n/a
Default Re: Restrict access to localhost only

On Tue, 24 Aug 2004 01:54:10 +0200, Jörg Ellermann
<j.ellermann@tu-bs.de> wrote:

>I want to prevent access to a specific directory with a .htaccess file. Only the
>local PHP module should be allowed to access that directory.
>
>I've put a .htaccess file in the directory:
>
><Directory />
>Order Deny,Allow
>Deny from all
>Allow from (server's address here)
></Directory>
>
>but it does not seem to work, though. By the way, would "localhost" be a legal
>address in this directive?
>
>Thanks,
>Jörg



watch out: .htaccess is read at each request, so can give a
degradation in performance.
So IMHO it is best used by the maintainer of the directory it is in.
The server owner should put all his stuff in httpd.conf, which is only
accessed on server startup.
..
frgr
Erik
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 02:56 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0