LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Apache Directory Restriction (https://www.linuxquestions.org/questions/linux-newbie-8/apache-directory-restriction-4175577173/)

gemmajid 04-11-2016 08:20 AM

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

bathory 04-11-2016 12:28 PM

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

gemmajid 04-12-2016 04:26 AM

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

JJJCR 04-12-2016 04:35 AM

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

gemmajid 04-12-2016 04:52 AM

I have tried the same but no success yet.

bathory 04-12-2016 05:37 AM

Quote:

Originally Posted by gemmajid (Post 5529802)
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


gemmajid 04-12-2016 05:45 AM

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

bathory 04-12-2016 06:29 AM

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

gemmajid 04-12-2016 06:40 AM

Thanks for your reply, is that possible to block all files extension except for jpg alongwith this ip rules ?

gemmajid 04-12-2016 07:20 AM

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.

bathory 04-12-2016 03:07 PM

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>


JJJCR 04-12-2016 08:09 PM

Quote:

Originally Posted by bathory (Post 5530069)
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"

bathory 04-13-2016 01:56 AM

@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.

gemmajid 04-13-2016 02:04 AM

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.

gemmajid 04-13-2016 02:11 AM

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


All times are GMT -5. The time now is 07:30 PM.