The Road to Elysium

August 28, 2009

Password protecting folders with nginx

Filed under: Linux — jorge @ 15:38

Ever wondered how you can password protect a folder and the underlying content with nginx the same way Apache does? Pretty simple.

First create a htpass-file like so:

# htpasswd -b htpass NewUser NewPassword

Edit your site’s configuration file by adding the following lines of code inside the server-block:

location ^~ /secret {
    auth_basic "Restricted";
    auth_basic_user_file /etc/nginx/htpass;
}

And your folder should be password protected. :)

No Comments »

No comments yet.

RSS feed for comments on this post. TrackBack URL

Leave a comment

Powered by WordPress