LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
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, 04: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, 05:12 AM   #2
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,165
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
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, 04: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, 05:52 AM   #4
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,165
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
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



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 04:45 AM
find specific named directory while excluding specific named directory sharky Linux - Newbie 6 01-17-2014 11:29 AM
squid proxy server configuration in rhel5 and deny deny accessing websites renjindd Linux - Newbie 1 09-09-2012 08:58 AM
how to deny user from accessing FTP service using /etc/hosts.deny in redhat 6 raasukutty Linux - Security 6 01-19-2012 04:32 PM
never_direct deny all vs. always_direct deny all simplyrahul Linux - General 1 02-16-2005 02:42 PM

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

All times are GMT -5. The time now is 02:08 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