# Can't get http authentication to work

**URL:** <https://www.ruby-forum.com/t/cant-get-http-authentication-to-work/245903>\
**Category:** NGINX\
**Created:** [July 26, 2013, 7:23pm UTC](https://www.ruby-forum.com/t/cant-get-http-authentication-to-work/245903 "2013-07-26T19:23:39Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rafa\_F](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/958977/32.png) [@Rafa\_F](https://www.ruby-forum.com/u/Rafa_F)\
**Post date:** [July 26, 2013, 7:23pm UTC](https://www.ruby-forum.com/t/cant-get-http-authentication-to-work/245903/1 "2013-07-26T19:23:39Z")

</div>

Hi, I’m trying to implement HTTP authentication as outlined in this  
article

> **[How To Set Up HTTP Authentication With Nginx On Ubuntu 12.10 | DigitalOcean](https://www.digitalocean.com/community/tutorials/how-to-set-up-http-authentication-with-nginx-on-ubuntu-12-10)**
>
> Use this tutorial to setup HTTP Authentication with Nginx on Ubuntu 12.10.

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.

Any ideas what I might be doing wrong? Thanks if you can help

upstream unicorn {  
server unix:/tmp/unicorn.remotepg.sock fail\_timeout=0;  
}

server {  
listen 80 default deferred;

# server\_name [example.com](http://example.com);

root /home/michael/apps/remotepg/current/public;

location ^~ /assets/ {  
gzip\_static on;  
expires max;  
add\_header Cache-Control public;  
}

try\_files $uri/index.html $uri @unicorn;  
location @unicorn {  
proxy\_set\_header X-Forwarded-For $proxy\_add\_x\_forwarded\_for;  
proxy\_set\_header Host $http\_host;  
proxy\_redirect off;  
proxy\_pass [http://unicorn](http://unicorn);  
auth\_basic “Restricted”;  
auth\_basic\_user\_file  
/home/michael/apps/remotepg/current/public/.htpasswd;  
}

error\_page 500 502 503 504 /500.html;  
client\_max\_body\_size 4G;  
keepalive\_timeout 10;  
}
