Full-Service Internet Marketing & Web Development | WebMail
Call us Toll-Free:
1-800-218-1525
Email us

Setting up password protection for your directories

Kyle Deneen, 05-16-2008
Protecting a directory on your website with HTTP Authentication can be done in a few easy steps.

First, you need to create a user/password combination using a program called htpasswd. We have a script created that allows you to do just that with ease. Simply go to this url and type in your username and password to get the encrypted user/pass you will need to place into a file.

http://www.softwareprojects.com/serv...tehtpasswd.php

After that you have to create a file under the directory you want protected and place that encrypted username/password into it, we will call it htaccessfile in this example. At that point you are ready to make changes to the conf file.

Once you have your username and password encrypted, you would access the 'nginx.conf' file in your root website directory. This file tells our webserver how to treat the files/directories on your page. It is in here that you will make the necessary changes to enable password protection on whichever directory you may want. You need to add several lines to your 'nginx.conf':

location ^~ /protectthisdirectory/ {
root /home/mydomain.com/htdocs;
index index.php index.html index.htm *;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /home/mydomain.com/htdocs/$fastcgi_script_name;
include /etc/nginx/fastcgi_top.conf;
fastcgi_param DOCUMENT_ROOT /home/mydomain.com/htdocs/;
include /etc/nginx/fastcgi_bottom.conf;
if ($uri ~ \.php$)
{
fastcgi_pass 127.0.0.1:8888;
}
auth_basic "Restricted";
auth_basic_user_file /home/mydomain.com/htdocs/protectthisdirectory/htaccessfile;
}

In the above example, you would replace 'mydomain.com' with your domain, 'protectthisdirectory' with the directory you are tying to place a password on, and 'htaccessfile' with the name of your password file.

Once you make these changes, our system will automatically refresh the web-server and password protection would be enabled within about 2 minutes.
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Enjoyed this post?

Subscribe Now to receive new posts via Email as soon as they come out.

Post your comments












Note: No link spamming! If your message contains link/s, it will NOT be published on the site before manually approved by one of our moderators.


About us  |  Contact us  |  Privacy  |  Terms & Conditions  |  Affiliates

© 2008 Software Projects Inc. (SPI)
Thursday, August 21st, 2008
Page generated in 0.345 seconds