LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 12-18-2018, 05:27 AM   #1
catiewong
Member
 
Registered: Aug 2018
Posts: 190

Rep: Reputation: Disabled
nginx deny specific directory


is there anyone have experience to config nginx web server

if I would like to deny a specific directory for user to access (eg . forbidden user to access /web/dir1 and /web/dir2 , other directory could be access ) , what can I do ?

thanks
 
Old 12-18-2018, 06:12 AM   #2
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 12,630

Rep: Reputation: 1808Reputation: 1808Reputation: 1808Reputation: 1808Reputation: 1808Reputation: 1808Reputation: 1808Reputation: 1808Reputation: 1808Reputation: 1808Reputation: 1808
Quote:
Originally Posted by catiewong View Post
is there anyone have experience to config nginx web server

if I would like to deny a specific directory for user to access (eg . forbidden user to access /web/dir1 and /web/dir2 , other directory could be access ) , what can I do ?

thanks
You can try the following:
Code:
location ~ ^/web/(dir1|dir2) {
 deny all;
}
Regards
 
Old 12-19-2018, 05:19 AM   #3
catiewong
Member
 
Registered: Aug 2018
Posts: 190

Original Poster
Rep: Reputation: Disabled
Thanks

If I have the following two requirement , would advise how to do it .

1) deny file which are .jpg and .png extension .
2) add header to the url which the url is .html
 
Old 12-19-2018, 06:52 AM   #4
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 12,630

Rep: Reputation: 1808Reputation: 1808Reputation: 1808Reputation: 1808Reputation: 1808Reputation: 1808Reputation: 1808Reputation: 1808Reputation: 1808Reputation: 1808Reputation: 1808
Quote:
Originally Posted by catiewong View Post
Thanks

If I have the following two requirement , would advise how to do it .

1) deny file which are .jpg and .png extension .
2) add header to the url which the url is .html
Did you made any effort on this by your own? I guess not, so please next time try to do things by yourself and ask for help only when stuck, posting what have you done, the errors you got, etc...

For now try the following, but next time I would like to see some effort from you:
Code:
location ~* ^.+\.(jpg|png) {  
 deny all;
}
location ~* ^.+\.html {
add_header  My-HTML-Header "This is a HTML Header";
}
Regards
 
  


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
Debian 8-NFS-Deny access to specific IP to specific "share" directory george102 Linux - Server 0 06-13-2016 05:45 AM
find specific named directory while excluding specific named directory sharky Linux - Newbie 6 01-17-2014 12:29 PM
squid proxy server configuration in rhel5 and deny deny accessing websites renjindd Linux - Newbie 1 09-09-2012 09:58 AM
how to deny user from accessing FTP service using /etc/hosts.deny in redhat 6 raasukutty Linux - Security 6 01-19-2012 05:32 PM
never_direct deny all vs. always_direct deny all simplyrahul Linux - General 1 02-16-2005 03:42 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 03:35 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration