LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-11-2016, 09:20 AM   #1
gemmajid
Member
 
Registered: Mar 2012
Location: Karachi
Distribution: Ubuntu, RedHat, CentOs,
Posts: 95

Rep: Reputation: Disabled
Apache Directory Restriction


Hello,

I'm using Ubuntu 14.10, I want to restrict my specific apache directory. (Only my wan ip can access the same)

For Example:
/var/www/mysite/public_html/testdirectory/specificdirectory
i want to restrict "specific directory"

Further i have tested .htaccess but no success yet.

Regards,

Majid Hussain
 
Old 04-11-2016, 01:28 PM   #2
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 11,516

Rep: Reputation: 1501Reputation: 1501Reputation: 1501Reputation: 1501Reputation: 1501Reputation: 1501Reputation: 1501Reputation: 1501Reputation: 1501Reputation: 1501Reputation: 1501
Hi,

You can use:
Code:
Require ip x.x.x.x
where x.x.x.x is the ip you want to allow access.
The above snippet can be used either in .htaccess or in apache config

Regards
 
Old 04-12-2016, 05:26 AM   #3
gemmajid
Member
 
Registered: Mar 2012
Location: Karachi
Distribution: Ubuntu, RedHat, CentOs,
Posts: 95

Original Poster
Rep: Reputation: Disabled
thanks for your reply,

i have managed to run .htaccess file and is working fine but it has blocked docs.google.com and i'm unable to view any file.

order deny,allow
deny from all
allow from x.x.x.x
allow from x.x.x.x
allow from x.x.x.x

I have used the above pattern kindly let me know how to unblock docs.googel.com

Regards,

Majid Hussain
 
Old 04-12-2016, 05:35 AM   #4
JJJCR
Senior Member
 
Registered: Apr 2010
Posts: 1,102

Rep: Reputation: 181Reputation: 181
have you tried adding this to your list:

Allow from docs.googel.com
Allow from docs.google.com

or check out this one:
https://httpd.apache.org/docs/curren...ss_compat.html

Last edited by JJJCR; 04-12-2016 at 05:36 AM. Reason: edit
 
Old 04-12-2016, 05:52 AM   #5
gemmajid
Member
 
Registered: Mar 2012
Location: Karachi
Distribution: Ubuntu, RedHat, CentOs,
Posts: 95

Original Poster
Rep: Reputation: Disabled
I have tried the same but no success yet.
 
Old 04-12-2016, 06:37 AM   #6
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 11,516

Rep: Reputation: 1501Reputation: 1501Reputation: 1501Reputation: 1501Reputation: 1501Reputation: 1501Reputation: 1501Reputation: 1501Reputation: 1501Reputation: 1501Reputation: 1501
Quote:
Originally Posted by gemmajid View Post
I have tried the same but no success yet.
You may try the IPs of docs.google.com
Code:
dig docs.google.com +short
74.125.206.102
74.125.206.138
74.125.206.100
74.125.206.139
74.125.206.113
74.125.206.101
 
Old 04-12-2016, 06:45 AM   #7
gemmajid
Member
 
Registered: Mar 2012
Location: Karachi
Distribution: Ubuntu, RedHat, CentOs,
Posts: 95

Original Poster
Rep: Reputation: Disabled
I have tried this but now the issue is that if i unblock these ips or domain name then any one can access the document online without having any restrictions.

For example
www.mysite.com/test/test.doc then by default it will open through docs.google.com and the link will be open from any where. I want to access the link/file only from my isp.

any idea ?

Regards,

Majid Hussain
 
Old 04-12-2016, 07:29 AM   #8
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 11,516

Rep: Reputation: 1501Reputation: 1501Reputation: 1501Reputation: 1501Reputation: 1501Reputation: 1501Reputation: 1501Reputation: 1501Reputation: 1501Reputation: 1501Reputation: 1501
Quote:
For example
www.mysite.com/test/test.doc then by default it will open through docs.google.com and the link will be open from any where. I want to access the link/file only from my isp.

any idea ?
Then I guess you should add password authorization in conjunction with the restricted IPs
 
Old 04-12-2016, 07:40 AM   #9
gemmajid
Member
 
Registered: Mar 2012
Location: Karachi
Distribution: Ubuntu, RedHat, CentOs,
Posts: 95

Original Poster
Rep: Reputation: Disabled
Thanks for your reply, is that possible to block all files extension except for jpg alongwith this ip rules ?
 
Old 04-12-2016, 08:20 AM   #10
gemmajid
Member
 
Registered: Mar 2012
Location: Karachi
Distribution: Ubuntu, RedHat, CentOs,
Posts: 95

Original Poster
Rep: Reputation: Disabled
I want my upload directory to reject all files type except for jpg (means no one can upload certian file type to that directory) and the ip rules remain same.

Is there any way to block file type in directory.
 
Old 04-12-2016, 04:07 PM   #11
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 11,516

Rep: Reputation: 1501Reputation: 1501Reputation: 1501Reputation: 1501Reputation: 1501Reputation: 1501Reputation: 1501Reputation: 1501Reputation: 1501Reputation: 1501Reputation: 1501
Quote:
I want my upload directory to reject all files type except for jpg (means no one can upload certian file type to that directory) and the ip rules remain same.

Is there any way to block file type in directory.
Maybe this:
Code:
Order deny,allow
deny from all
allow from x.x.x.x
<FilesMatch "^.+\.jpg">
allow from all
</FilesMatch>
 
1 members found this post helpful.
Old 04-12-2016, 09:09 PM   #12
JJJCR
Senior Member
 
Registered: Apr 2010
Posts: 1,102

Rep: Reputation: 181Reputation: 181
Thumbs up

Quote:
Originally Posted by bathory View Post
Maybe this:
Code:
Order deny,allow
deny from all
allow from x.x.x.x
<FilesMatch "^.+\.jpg">
allow from all
</FilesMatch>
Cool..you must be playing with Apache all night long..over and over again..hehe..

Would this greedy match work as well to filter the .jpg files: ".*[.]jpg"

Last edited by JJJCR; 04-12-2016 at 09:11 PM. Reason: edit
 
Old 04-13-2016, 02:56 AM   #13
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 11,516

Rep: Reputation: 1501Reputation: 1501Reputation: 1501Reputation: 1501Reputation: 1501Reputation: 1501Reputation: 1501Reputation: 1501Reputation: 1501Reputation: 1501Reputation: 1501
@JJJCR
Quote:
Would this greedy match work as well to filter the .jpg files: ".*[.]jpg"
It will match any character one or more times.
See this for more.

Last edited by bathory; 04-13-2016 at 03:22 AM.
 
Old 04-13-2016, 03:04 AM   #14
gemmajid
Member
 
Registered: Mar 2012
Location: Karachi
Distribution: Ubuntu, RedHat, CentOs,
Posts: 95

Original Poster
Rep: Reputation: Disabled
doesn't work yet. seems like as suggested by bathory user authentication was the ideal solution for my scenario but still playing with apache, will get back if any solution meets my requirement.

Last edited by gemmajid; 04-13-2016 at 03:05 AM.
 
Old 04-13-2016, 03:11 AM   #15
gemmajid
Member
 
Registered: Mar 2012
Location: Karachi
Distribution: Ubuntu, RedHat, CentOs,
Posts: 95

Original Poster
Rep: Reputation: Disabled
what if we can directly restrict apache directory to accept desired extension i.e (doc, xls, xlsx, exe) without involving .htaccess file ?
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 ip access restriction gusrago Linux - Newbie 3 11-10-2010 07:20 PM
[SOLVED] RHEL5 Apache Directory Listing for a directory thorinn Red Hat 8 02-02-2010 10:01 AM
directory restriction on FTP alejandroye Linux - Networking 1 12-03-2006 07:53 PM
Apache Directory Listing Of NFS Mount, cannot view directory list via apache luqmana Linux - Networking 2 12-19-2005 07:03 AM
How do i fix this open_basedir restriction in effect. File is in wrong directory DropHit Linux - Software 2 02-26-2004 07:28 PM


All times are GMT -5. The time now is 12:13 PM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration