LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 08-26-2016, 06:30 AM   #1
R.N.RAM KANNAN
LQ Newbie
 
Registered: Oct 2009
Posts: 28

Rep: Reputation: 0
Smile apache deny access to subdirectories


Hi All,

In Apache i want to deny all files under /opt/ram directory.

I searched in google and tried the below commands but it did'nt work.

I tried the below did'nt work for me

<Directory /opt/ram/*>
Order allow,deny
deny from all
</Directory>

I tried the below did'nt work for me

<Directory /opt/ram>
<Files *.key>
Deny from all
</Files>

Also tried filesmatch also

Can you please help me on this.

My goal is to restrict all files under /opt/ram directory

Under /opt/ram directory i have files private.key,ram.cr etc...

Can you please help me on this.

Thanks in advance
 
Old 08-26-2016, 06:44 AM   #2
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,163
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
Hi,

The easiest way to achieve this is to run:
Code:
chmod -x /opt/ram
If you want to do it the apache way use:
Code:
<Directory /opt/ram>
Order allow,deny
deny from all
</Directory>
Regards
 
Old 08-26-2016, 07:15 AM   #3
R.N.RAM KANNAN
LQ Newbie
 
Registered: Oct 2009
Posts: 28

Original Poster
Rep: Reputation: 0
Hi

Thanks

I tried the below as you suggested.

<Directory /opt/ram>
Order allow,deny
deny from all
</Directory>


If i access https://ecare.com/opt/ram/ iam getting the below

Forbidden

You don't have permission to access /opt/ram/ on this server.

If i access https://ecare.com/opt/ram/private.key iam able to view the private key in the web page.


I should not able to access the files under /opt/ram directory.

My goal is that if i access the url https://ecare.com/opt/ram/private.key i should get the Forbidden page


Can you please help on this

Thanks
 
Old 08-26-2016, 07:35 AM   #4
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,163
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
Quote:
If i access https://ecare.com/opt/ram/private.key iam able to view the private key in the web page.
What is the DocumentRoot?
You need to use the whole path to the directory you want to deny access, including the docroot part:
Assuming the DocumentRoot is "/var/www", then you should use:
Code:
<Directory /var/www/opt/ram>
Order allow,deny
deny from all
</Directory>
 
Old 08-26-2016, 09:06 AM   #5
R.N.RAM KANNAN
LQ Newbie
 
Registered: Oct 2009
Posts: 28

Original Poster
Rep: Reputation: 0
Hi

Thanks

/opt/ram is a full path
 
Old 08-26-2016, 03:02 PM   #6
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,163
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
Quote:
Originally Posted by R.N.RAM KANNAN View Post
Hi

Thanks

/opt/ram is a full path
I don't get it. If it's the full path, then why you use https://ecare.com/opt/ram? It should be just https://ecare.com

Anyway as I told you in my 1st post, better remove the execute bit from the directory in question, so apache cannot descend in it:
Code:
chmod -x /opt/ram
 
Old 08-29-2016, 03:31 AM   #7
R.N.RAM KANNAN
LQ Newbie
 
Registered: Oct 2009
Posts: 28

Original Poster
Rep: Reputation: 0
Hi bathory,

After removing chmod -x /opt/ram execute permission iam unable access https://ecare.com/opt/ram

Thanks a lot for your assistance
 
  


Reply



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 On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Apache - how to deny access to a file tikit Linux - Server 2 11-11-2009 03:53 AM
Apache2 > "order allow,deny" to allow subdirectories cbonar Linux - Server 13 10-27-2007 03:08 PM
Access allow and deny to APACHE & SSH longnam Solaris / OpenSolaris 5 03-02-2007 07:59 AM
Apache - 403 Forbidden - Access to Subdirectories dieter Linux - Networking 2 03-25-2004 12:51 PM
Can't access /mnt can access subdirectories pboggio Mandriva 7 10-05-2003 07:58 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 05:52 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration