.htaccess protection with nginx
Posted by Dhaval Parikh on Jan 21, 2009 |
Hey just recently had a requirement where in I had to set password for my website. It was a ruby on rails website and I had to set .htaccess for it. I knew how to setup .htaccess for apache but with nginx (that our site was using as webserver) I didnt knew what to do.
Then I figured out the solution
Open nginx.conf file. Search for the location word you might see multiple location configuration. But put the code below in the root location
auth_basic "RESTRICTED ACCESS";
auth_basic_user_file /path/to/htpasswd/file
For ruby on rails it will be generally in
the public folder of your rails app.
If you havent generated the htpassword
yet pls do it using the following command
htpasswd -b -c htpasswd username password
Hope this will be useful to you if you
are caught in the same situation as me.
Njoi protecting the site

[...] .htaccess protection with nginx | Dhaval Parikh blog.dhavalparikh.co.in/2009/01/htaccess-protection-with-nginx – view page – cached Hey just recently had a requirement where in I had to set password for my website. It was a ruby on rails website and I had to set .htaccess for it. I knew how — From the page [...]
Thank you! Very usefull.