Contact SalesSitemapCustomer Login

Go Back   VPSlink Forums > Technical Discussion > HowTo's

Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old 03-08-2009, 05:14 AM
Junior Member
 
Join Date: Mar 2009
Location: India
Posts: 23
Default Password Protect in NGINX

Hello,

I have a problem with the below code, searched a lot, tried a lot of alternatives, but just cannot get it to work.

Code:
# Password Protect important Directories
location ~ /(admincp/|modcp/|includes/|install/) {
auth_basic            "Restricted";
auth_basic_user_file   /home/username/.htpasswd/passwd;
}

The above code works good enough and protects the 4 directories as desired. BUT it does not protect admincp/index.php OR any other file (in any of the folders) if directly opened. For example:-

/admincp -> Is protected
/admincp/ -> Is protected
/admincp/index.php -> Is not protected

What should I do?

Thanks
Reply With Quote
  #2 (permalink)  
Old 03-09-2009, 06:16 PM
Junior Member
 
Join Date: Mar 2009
Location: India
Posts: 23
Default

For the above problem, the password rules when moved above FastCGI rules, solves the problem.
Reply With Quote
  #3 (permalink)  
Old 03-09-2009, 07:09 PM
Administrator
 
Join Date: Dec 2007
Posts: 1,141
Default

The nginx location directive documentation suggests that regular expressions can be used - the following should be sufficient to protect the contents of directories:

Code:
# Password Protect important Directories
location ~ /(admincp/.*|modcp/.*|includes/.*|install/.*) {
auth_basic            "Restricted";
auth_basic_user_file   /home/username/.htpasswd/passwd;
}
Reply With Quote
Reply

Bookmarks

Tags
nginx, nginx password protect

Thread Tools
Display Modes

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 On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off



All times are GMT. The time now is 12:06 AM.


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.2.0