Hello,
I am new to nginx.
I have a Rails 3.1 site (with Passenger) that I want to protect from viewing while it is being developed. With Apache, I would create a .htaccess file in the HTML root to force the browser client to prompt for a user/pass. I want to do the same thing in NGINX.
I have created a the file /opt/nginx/conf/htpasswd which contains:
admin:some_md5_password_here
I have the following in /opt/nginx/nginx.conf:
user webdev;
worker_processes 1;
error_log logs/error.log;
events {
worker_connections 1024;
}
http {
passenger_root /usr/lib/ruby/gems/1.9.1/gems/passenger-3.0.7;
passenger_ruby /usr/bin/ruby1.9.1;
include mime.types;
default_type application/octet-stream;
access_log logs/access.log;
sendfile on;
keepalive_timeout 65;
include dev.nginx.conf;
}
Then, inside dev.nginx.conf, I have:
server {
passenger_enabled on;
root /var/www/my_app/public;
rails_env development;
server_name dev.my_domain.com;
location / {
auth_basic "Restricted";
auth_basic_user_file htpasswd;
passenger_enabled on;
}
}
Everything works perfectly, EXCEPT it functions as if NO HTTP AUTH has been set! I am not prompted to enter a user/pass.
The logs show nothing related to any issues.
Why?
Thanks in advance for your help.