Limiting access to a folder to just localhost?

This is a discussion on Limiting access to a folder to just localhost? within the Linux Web Servers forums, part of the Web Server and Related Forums category; Heya folks, I am trying to limit access to a folder within htdocs, lets call it htdocs/gallery. How do ...


Go Back   Usenet Forums > Web Server and Related Forums > Linux Web Servers

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 01-12-2004
Steve Best
 
Posts: n/a
Default Limiting access to a folder to just localhost?

Heya folks, I am trying to limit access to a folder within htdocs,
lets call it htdocs/gallery. How do I tell the server, via .htaccess,
to only allow the localhost to access the files within htdocs/gallery?

Here is my .htaccess:

<Limit GET POST>
allow from localhost
order deny,allow
deny from ALL
</Limit>

From the logs, it looks like when someone is trying to access a page,
say index.html, it passes the IP visiting the page for authentication,
and therefore it fails. I want only local code to be able to access
files within the directory, to prevent anyone from linking directly to
any files located within htdocs/gallery.

Thanks!
  #2 (permalink)  
Old 01-13-2004
David Efflandt
 
Posts: n/a
Default Re: Limiting access to a folder to just localhost?

On 12 Jan 2004 14:05:14 -0800, Steve Best <steve@technaughty.com> wrote:
> Heya folks, I am trying to limit access to a folder within htdocs,
> lets call it htdocs/gallery. How do I tell the server, via .htaccess,
> to only allow the localhost to access the files within htdocs/gallery?
>
> Here is my .htaccess:
>
><Limit GET POST>
> allow from localhost
> order deny,allow
> deny from ALL
></Limit>


See apache docs for 'Order'. Note that default for Order Allow,Deny
is deny, so it is simply (lose the Limit tags):

Order Allow,Deny
Allow from localhost

Or for any loopback IP could be 'Allow from 127'.

> From the logs, it looks like when someone is trying to access a page,
> say index.html, it passes the IP visiting the page for authentication,
> and therefore it fails. I want only local code to be able to access
> files within the directory, to prevent anyone from linking directly to
> any files located within htdocs/gallery.


I think your 'Order Allow,Deny' might cancel the previous 'allow from
localhost', therefore maybe only the 'deny from all' applies.

First you say localhost, then local code. If you wanted contents of a
directory to only be passed by a script in another directory (and not at
all directly accessible by http) it would be:

Order Allow,Deny
Deny from all

--
David Efflandt - All spam ignored http://www.de-srv.com/
  #3 (permalink)  
Old 01-13-2004
Steve Best
 
Posts: n/a
Default Re: Limiting access to a folder to just localhost?

> I think your 'Order Allow,Deny' might cancel the previous 'allow from
> localhost', therefore maybe only the 'deny from all' applies.
>
> First you say localhost, then local code. If you wanted contents of a
> directory to only be passed by a script in another directory (and not at
> all directly accessible by http) it would be:
>
> Order Allow,Deny
> Deny from all


That doesnt work because even if the image is linked from a page in
htdocs, the request for the image is still coming from the client IP.
Any other suggestions?
  #4 (permalink)  
Old 01-14-2004
David Efflandt
 
Posts: n/a
Default Re: Limiting access to a folder to just localhost?

On 13 Jan 2004 12:11:37 -0800, Steve Best <steve@technaughty.com> wrote:
>> I think your 'Order Allow,Deny' might cancel the previous 'allow from
>> localhost', therefore maybe only the 'deny from all' applies.
>>
>> First you say localhost, then local code. If you wanted contents of a
>> directory to only be passed by a script in another directory (and not at
>> all directly accessible by http) it would be:
>>
>> Order Allow,Deny
>> Deny from all

>
> That doesnt work because even if the image is linked from a page in
> htdocs, the request for the image is still coming from the client IP.
> Any other suggestions?


Define doesn't work. As long as AllowOverride that covers that dir
includes Limit (or All), the above in .htaccess would deny all http access
to that directory (or any subdirectories) from anywhere. Of course local
shell users or CGI scripts of others might be able to access it, depending
upon dir ownership/permissions and whether suexec is being used. But
nothing in that dir would be directly accessible by URL.

--
David Efflandt - All spam ignored http://www.de-srv.com/
 


Thread Tools
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

vB 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 03:41 PM.


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