Welcome! Log In Create A New Profile

Advanced

Basic http authentication

Jerome St-pierre
August 25, 2009 10:50AM
Hi all,

I just finished my first Rails deployment with passenger and nginx
0.6.37 and everything is running. But, I need to protect the whole site
since it is just in staging.

After messing with authenticate_or_request_with_http_digest I found out
this isn't supported in nginx. I thought no big deal, basic
authentication if fine. So I used the apache htpasswd command to create
the password file under the public folder.

But it doesn't seem to work for me and I can't see why. I guess I am
just missing something dumb since I am a rookie Linux user, new to Rails
and I just discovered nginx that seems perfect for my needs.

Here is my minimal nginx server conf:

server {
listen 80;
server_name mywebsite.com;
root /var/www/mywebsite/public;
passenger_enabled on;

location / {
auth_basic "Restricted Access";
auth_basic_user_file /var/www/mywebsite/public/htpasswd;
}
}

It seems to be validating the good password because I am prompted again
with a bad password. But when I enter a valid password I keep getting
403 Forbidden. If I remove the location block I get access to everything
so I don't think it is a Linux permission issue. I also tried adding a
regex (location ^~ /) to match everything under the root without any
success.

Any clue on what's missing? Any other simple suggestion to protect a
site access without any highly sensitive data?

Thanks a lot
--
Posted via http://www.ruby-forum.com/.
Subject Author Posted

Basic http authentication

Jerome St-pierre August 25, 2009 10:50AM

Re: Basic http authentication

Jerome St-pierre August 25, 2009 01:52PM

Re: Basic http authentication

Jerome St-pierre August 25, 2009 03:17PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 295
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