Welcome! Log In Create A New Profile

Advanced

Re: Allow access to only a specific user from a htpasswd file

Dave Hayes
August 08, 2011 12:02AM
Leigh Dyer <lsd@wootangent.net> writes:
> I've tried testing the value of $remote_user -- this is what I have at
> the moment:
> location /foo {
> auth_basic "Foo";
> auth_basic_user_file "foo-htpasswd";

> if ($remote_user = "leigh") {
> proxy_pass http://127.0.0.1:19000;
> }
> }
> This mostly works, but if you log in with an account other than "leigh"
> that's in the password file, the browser returns a 404 and no longer
> prompts for login details.

Just a suggestion, and I'm by no means an expert, but I may have begun
to learn how if blocks really work. Try this:

location /foo {
auth_basic "Foo";
auth_basic_user_file "foo-htpasswd";
proxy_pass http://127.0.0.1:19000;
if ($remote_user != "leigh") {
return 403;
}
}

and see if that helps.
--
Dave Hayes - Consultant - Altadena CA, USA - dave@jetcafe.org
>>> The opinions expressed above are entirely my own <<<

It's easier to fight for one's principles than to live up to them.


_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

Allow access to only a specific user from a htpasswd file

Leigh Dyer August 07, 2011 10:40PM

Re: Allow access to only a specific user from a htpasswd file

Dave Hayes August 08, 2011 12:02AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

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