Welcome! Log In Create A New Profile

Advanced

Re: Conditional http auth

agentzh
December 04, 2010 06:24AM
On Sat, Dec 4, 2010 at 4:49 AM, Michael Shadle <mike503@gmail.com> wrote:
> Got this idea off IRC, but it looks like variables don't expand:
>
> set $realm "enter your password";
>
> if ($http_via ~* ".somehost.net") {
>        set $realm off;
> }
>
> auth_basic $realm;
> auth_basic_user_file /etc/nginx/confs/htpasswd.test;
>

With the ngx_lua [1] module enabled, it's trivial:

set_by_lua $realm '
if string.match(ngx.var.http_via, ".somehost.net") then
return "off"
else
return "enter your password"
end';

auth_basic $realm;
auth_basic_user_file /etc/nginx/confs/htpasswd.test;

This should have great performance even if you're using Lua ;)

Cheers,
-agentzh

[1] https://github.com/chaoslawful/lua-nginx-module/issues/#issue/8

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

Conditional http auth

mike December 03, 2010 03:58PM

Re: Conditional http auth

Eugaia December 03, 2010 04:06PM

Re: Conditional http auth

mike December 03, 2010 04:08PM

Re: Conditional http auth

Boris Dolgov December 03, 2010 04:10PM

Re: Conditional http auth

mike December 03, 2010 04:14PM

Re: Conditional http auth

mike December 03, 2010 05:10PM

Re: Conditional http auth

Eugaia December 03, 2010 04:26PM

Re: Conditional http auth

agentzh December 04, 2010 06:24AM

Re: Conditional http auth

agentzh December 04, 2010 06:28AM

Re: Conditional http auth

Eugaia December 04, 2010 10:46AM

Re: Conditional http auth

mike December 04, 2010 06:04PM

Re: Conditional http auth

mike December 06, 2010 07:06AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

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