<div dir="ltr"><p style="margin:0px 0px 8px;color:rgb(51,51,51);font-family:'Helvetica Neue',Helvetic;font-size:17px;line-height:23px">Hi, I'm trying to implement HTTP authentication as outlined in this article <a href="https://www.digitalocean.com/community/articles/how-to-set-up-http-authentication-with-nginx-on-ubuntu-12-10">https://www.digitalocean.com/community/articles/how-to-set-up-http-authentication-with-nginx-on-ubuntu-12-10</a></p>
<p style="margin:0px 0px 8px;color:rgb(51,51,51);font-family:'Helvetica Neue',Helvetic;font-size:17px;line-height:23px">I went through the early steps in the tutorial where it prompts you to create a password. That was fine. I then added the two auth_basic and auth_basic_user_file lines to the second location block in my nginx.conf (see below) and pushed it to my server (which necessarily restarts the server), but the http authentication isn't happening. I can access my demo rails app without problem.</p>
<p style="margin:0px 0px 8px;color:rgb(51,51,51);font-family:'Helvetica Neue',Helvetic;font-size:17px;line-height:23px">Any ideas what I might be doing wrong? Thanks if you can help</p><p style="margin:0px 0px 8px;color:rgb(51,51,51);font-family:'Helvetica Neue',Helvetic;font-size:17px;line-height:23px">
upstream unicorn { <br>server unix:/tmp/unicorn.remotepg.sock fail_timeout=0; <br>}</p><p style="margin:0px 0px 8px;color:rgb(51,51,51);font-family:'Helvetica Neue',Helvetic;font-size:17px;line-height:23px">server { <br>
listen 80 default deferred; <br># server_name <a href="http://example.com">example.com</a>; <br>root /home/michael/apps/remotepg/current/public;</p><p style="margin:0px 0px 8px;color:rgb(51,51,51);font-family:'Helvetica Neue',Helvetic;font-size:17px;line-height:23px">
location ^~ /assets/ { <br>gzip_static on; <br>expires max; <br>add_header Cache-Control public; <br>}</p><p style="margin:0px 0px 8px;color:rgb(51,51,51);font-family:'Helvetica Neue',Helvetic;font-size:17px;line-height:23px">
try_files $uri/index.html $uri @unicorn; <br>location @unicorn { <br>proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; <br>proxy_set_header Host $http_host; <br>proxy_redirect off; <br>proxy_pass <a href="http://unicorn">http://unicorn</a>; <br>
auth_basic "Restricted"; <br>auth_basic_user_file /home/michael/apps/remotepg/current/public/.htpasswd; <br>}</p><p style="margin:0px 0px 8px;color:rgb(51,51,51);font-family:'Helvetica Neue',Helvetic;font-size:17px;line-height:23px">
error_page 500 502 503 504 /500.html; <br>client_max_body_size 4G; <br>keepalive_timeout 10; <br>}</p></div>