.htaccess protection with nginx
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 siteShare and Enjoy:
- Programming Language:
- Tags:
- Technology:

















Recent comments
1 year 23 weeks ago
1 year 23 weeks ago
1 year 25 weeks ago
1 year 27 weeks ago
1 year 42 weeks ago
1 year 45 weeks ago
1 year 45 weeks ago
1 year 45 weeks ago
1 year 46 weeks ago
1 year 48 weeks ago