Welcome! Log In Create A New Profile

Advanced

can't get http authentication to work

Michael Mitchell
July 26, 2013 01:24PM
Hi, I'm trying to implement HTTP authentication as outlined in this article
https://www.digitalocean.com/community/articles/how-to-set-up-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;
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;
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;
}
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

can't get http authentication to work

Michael Mitchell July 26, 2013 01:24PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 281
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready