You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by ML <ma...@MailNewsRSS.com> on 2009/07/13 20:37:05 UTC

[users@httpd] Directory Permssions

Hello All,

I am confused about directory permissions inside of my wwwroot/

I am using name-based virtual hosting and I have y web root as /var/ 
www/html

All of my websites are inside /var/www/html in their own directories.

How can I i have a directory protected from crawlers indexing it? What  
is the right permission set?

How can I have a directory that apache can use, but nobody can browse  
to?

The reason is that I have PHP/MySQL Setup and I store all of my MySQL  
connection information and queries in a directory and I dont want  
people 'finding' this by simple browsing the website or using a web  
grabber to take a copy of the whole site.

Can anyone provide insight?

-Jason

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] Directory Permssions

Posted by Drew Tomlinson <dr...@mykitchentable.net>.
ML wrote:
> Hi Tom,
>
>>> Say I have a directory of files that contain my MySQL connection
>>> information, queries, etc, etc.
>>>
>>> How do I prevent people from browsing the directory but allow the
>>> files to still be used when I include them in a page. Say to connect
>>> to MySQL.
>>
>> Don't ever put them inside your document root. Ever. Place them outside,
>> and then include them from within the PHP script which requires it. PHP
>> doesn't give a monkey's where on disk you load things from.
>>
>> Seriously, this is one of the many ways that a developer/server admin
>> can be made to look like a fool. Don't put configuration data inside
>> your document root.
>
> So my root is /var/www/html/<site name>
>
> could I put my MySQL in /var/www/<mysql>/<site name>
> or in /etc/httpd/<mysql>/<site name>
>
> and this would be OK?

You don't even have to break it down that far.  For example, my 
DocumentRoot is:

/www/<site name>

And all my MySQL database files are in:

/var/db/mysql/<database>

Cheers,

Drew

-- 
Be a Great Magician!
Visit The Alchemist's Warehouse

http://www.alchemistswarehouse.com


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] Directory Permssions

Posted by Tom Evans <te...@googlemail.com>.
On Wed, 2009-07-15 at 07:46 -0700, ML wrote:
> Hi Tom,
> 
> >> Say I have a directory of files that contain my MySQL connection
> >> information, queries, etc, etc.
> >>
> >> How do I prevent people from browsing the directory but allow the
> >> files to still be used when I include them in a page. Say to connect
> >> to MySQL.
> >
> > Don't ever put them inside your document root. Ever. Place them  
> > outside,
> > and then include them from within the PHP script which requires it.  
> > PHP
> > doesn't give a monkey's where on disk you load things from.
> >
> > Seriously, this is one of the many ways that a developer/server admin
> > can be made to look like a fool. Don't put configuration data inside
> > your document root.
> 
> So my root is /var/www/html/<site name>
> 
> could I put my MySQL in /var/www/<mysql>/<site name>
> or in /etc/httpd/<mysql>/<site name>
> 
> and this would be OK?
> 
> -Jason
> 

I don't use PHP, so check with their documentation, but yes, that should
be OK. The easiest way is just to try it out and see if it works.
Explicit paths should be easiest.

Cheers

Tom


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] Directory Permssions

Posted by ML <ma...@MailNewsRSS.com>.
Hi Tom,

>> Say I have a directory of files that contain my MySQL connection
>> information, queries, etc, etc.
>>
>> How do I prevent people from browsing the directory but allow the
>> files to still be used when I include them in a page. Say to connect
>> to MySQL.
>
> Don't ever put them inside your document root. Ever. Place them  
> outside,
> and then include them from within the PHP script which requires it.  
> PHP
> doesn't give a monkey's where on disk you load things from.
>
> Seriously, this is one of the many ways that a developer/server admin
> can be made to look like a fool. Don't put configuration data inside
> your document root.

So my root is /var/www/html/<site name>

could I put my MySQL in /var/www/<mysql>/<site name>
or in /etc/httpd/<mysql>/<site name>

and this would be OK?

-Jason


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] Directory Permssions

Posted by Tom Evans <te...@googlemail.com>.
On Tue, 2009-07-14 at 12:45 -0700, ML wrote:
> Hi Doug,
> 
> >> So does that prevent crawling and browsing, but does allow if I  
> >> click a link or include a file it will work?
> >>
> >
> > No, it prevents the directory and all files within from being served  
> > by the webserver at all. Anything else is either half-secure or half- 
> > broken
> >
> > I don't understand what you mean by "crawling", "browsing", and  
> > "include a file". They're really all the same thing: A client (be it  
> > Firefox or GoogleBot) is asking the webserver for something.
> >
> > If you want to prevent the nice robots from asking for something,  
> > you can use a robots.txt file. This will not prevent naughty robots  
> > from asking for something.
> 
> Lets think about this a different way.
> 
> Say I have a directory of files that contain my MySQL connection  
> information, queries, etc, etc.
> 
> How do I prevent people from browsing the directory but allow the  
> files to still be used when I include them in a page. Say to connect  
> to MySQL.
> 
> -Jason
> 
> 

Don't ever put them inside your document root. Ever. Place them outside,
and then include them from within the PHP script which requires it. PHP
doesn't give a monkey's where on disk you load things from.

Seriously, this is one of the many ways that a developer/server admin
can be made to look like a fool. Don't put configuration data inside
your document root.

Cheers

Tom


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] Directory Permssions

Posted by Doug Bell <do...@plainblack.com>.
On Jul 14, 2009, at 2:45 PM, ML wrote:

> Hi Doug,
>
>>> So does that prevent crawling and browsing, but does allow if I  
>>> click a link or include a file it will work?
>>>
>>
>> No, it prevents the directory and all files within from being  
>> served by the webserver at all. Anything else is either half-secure  
>> or half-broken
>>
>> I don't understand what you mean by "crawling", "browsing", and  
>> "include a file". They're really all the same thing: A client (be  
>> it Firefox or GoogleBot) is asking the webserver for something.
>>
>> If you want to prevent the nice robots from asking for something,  
>> you can use a robots.txt file. This will not prevent naughty robots  
>> from asking for something.
>
> Lets think about this a different way.
>
> Say I have a directory of files that contain my MySQL connection  
> information, queries, etc, etc.
>
> How do I prevent people from browsing the directory but allow the  
> files to still be used when I include them in a page. Say to connect  
> to MySQL.


So in this case, you mean "include" a la PHP's include()?

Just because Apache can't serve the file does not mean that Perl, PHP,  
Python, or other things cannot USE the file. Apache's access controls  
only determine what Apache will do with the file when the file is  
requested by a user.

For example, you could use Apache SSI to include a file that the user  
would not be able to see by directly trying to access the file.

Doug Bell -- Senior Developer, Plain Black Corp.
[ http://plainblack.com ]
all that groks is

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] Directory Permssions

Posted by ML <ma...@MailNewsRSS.com>.
Hi Doug,

>> So does that prevent crawling and browsing, but does allow if I  
>> click a link or include a file it will work?
>>
>
> No, it prevents the directory and all files within from being served  
> by the webserver at all. Anything else is either half-secure or half- 
> broken
>
> I don't understand what you mean by "crawling", "browsing", and  
> "include a file". They're really all the same thing: A client (be it  
> Firefox or GoogleBot) is asking the webserver for something.
>
> If you want to prevent the nice robots from asking for something,  
> you can use a robots.txt file. This will not prevent naughty robots  
> from asking for something.

Lets think about this a different way.

Say I have a directory of files that contain my MySQL connection  
information, queries, etc, etc.

How do I prevent people from browsing the directory but allow the  
files to still be used when I include them in a page. Say to connect  
to MySQL.

-Jason


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] Directory Permssions

Posted by Doug Bell <do...@plainblack.com>.
Please don't top post.

On Jul 14, 2009, at 1:00 PM, ML wrote:

> Hi Doug,
>
> So does that prevent crawling and browsing, but does allow if I  
> click a link or include a file it will work?
>

No, it prevents the directory and all files within from being served  
by the webserver at all. Anything else is either half-secure or half- 
broken

I don't understand what you mean by "crawling", "browsing", and  
"include a file". They're really all the same thing: A client (be it  
Firefox or GoogleBot) is asking the webserver for something.

If you want to prevent the nice robots from asking for something, you  
can use a robots.txt file. This will not prevent naughty robots from  
asking for something.

>
> On Jul 13, 2009, at 4:57 PM, Doug Bell wrote:
>
>> On Jul 13, 2009, at 1:37 PM, ML wrote:
>>
>>> Hello All,
>>>
>>> I am confused about directory permissions inside of my wwwroot/
>>>
>>> I am using name-based virtual hosting and I have y web root as / 
>>> var/www/html
>>>
>>> All of my websites are inside /var/www/html in their own  
>>> directories.
>>>
>>> How can I i have a directory protected from crawlers indexing it?  
>>> What is the right permission set?
>>>
>>> How can I have a directory that apache can use, but nobody can  
>>> browse to?
>>>
>>> The reason is that I have PHP/MySQL Setup and I store all of my  
>>> MySQL connection information and queries in a directory and I dont  
>>> want people 'finding' this by simple browsing the website or using  
>>> a web grabber to take a copy of the whole site.
>>>
>>> Can anyone provide insight?
>>
>>
>> To prevent a directory from being served by the webserver, do this:
>>
>> <Directory /path/to/directory>
>>   Order allow,deny
>>   Deny from all
>> </Directory>
>>
>> Put this block in your <VirtualHost> block.
>>
>> Doug Bell -- Senior Developer, Plain Black Corp.
>> [ http://plainblack.com ]
>> all that groks is
>>
>>
>>
>> ---------------------------------------------------------------------
>> The official User-To-User support forum of the Apache HTTP Server  
>> Project.
>> See <URL:http://httpd.apache.org/userslist.html> for more info.
>> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>> "   from the digest: users-digest-unsubscribe@httpd.apache.org
>> For additional commands, e-mail: users-help@httpd.apache.org
>>
>
>
> ---------------------------------------------------------------------
> The official User-To-User support forum of the Apache HTTP Server  
> Project.
> See <URL:http://httpd.apache.org/userslist.html> for more info.
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>  "   from the digest: users-digest-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
>


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] Directory Permssions

Posted by ML <ma...@MailNewsRSS.com>.
Hi Doug,

So does that prevent crawling and browsing, but does allow if I click  
a link or include a file it will work?

-Jason

On Jul 13, 2009, at 4:57 PM, Doug Bell wrote:

> On Jul 13, 2009, at 1:37 PM, ML wrote:
>
>> Hello All,
>>
>> I am confused about directory permissions inside of my wwwroot/
>>
>> I am using name-based virtual hosting and I have y web root as /var/ 
>> www/html
>>
>> All of my websites are inside /var/www/html in their own directories.
>>
>> How can I i have a directory protected from crawlers indexing it?  
>> What is the right permission set?
>>
>> How can I have a directory that apache can use, but nobody can  
>> browse to?
>>
>> The reason is that I have PHP/MySQL Setup and I store all of my  
>> MySQL connection information and queries in a directory and I dont  
>> want people 'finding' this by simple browsing the website or using  
>> a web grabber to take a copy of the whole site.
>>
>> Can anyone provide insight?
>
>
> To prevent a directory from being served by the webserver, do this:
>
> <Directory /path/to/directory>
>    Order allow,deny
>    Deny from all
> </Directory>
>
> Put this block in your <VirtualHost> block.
>
> Doug Bell -- Senior Developer, Plain Black Corp.
> [ http://plainblack.com ]
> all that groks is
>
>
>
> ---------------------------------------------------------------------
> The official User-To-User support forum of the Apache HTTP Server  
> Project.
> See <URL:http://httpd.apache.org/userslist.html> for more info.
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>  "   from the digest: users-digest-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
>


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] Directory Permssions

Posted by Doug Bell <do...@plainblack.com>.
On Jul 13, 2009, at 1:37 PM, ML wrote:

> Hello All,
>
> I am confused about directory permissions inside of my wwwroot/
>
> I am using name-based virtual hosting and I have y web root as /var/ 
> www/html
>
> All of my websites are inside /var/www/html in their own directories.
>
> How can I i have a directory protected from crawlers indexing it?  
> What is the right permission set?
>
> How can I have a directory that apache can use, but nobody can  
> browse to?
>
> The reason is that I have PHP/MySQL Setup and I store all of my  
> MySQL connection information and queries in a directory and I dont  
> want people 'finding' this by simple browsing the website or using a  
> web grabber to take a copy of the whole site.
>
> Can anyone provide insight?


To prevent a directory from being served by the webserver, do this:

<Directory /path/to/directory>
     Order allow,deny
     Deny from all
</Directory>

Put this block in your <VirtualHost> block.

Doug Bell -- Senior Developer, Plain Black Corp.
[ http://plainblack.com ]
all that groks is



---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org