Conditional http auth

Eugaia ngx.eugaia at gmail.com
Sat Dec 4 18:41:48 MSK 2010


Hi,

On 04/12/2010 13:18, agentzh wrote:
> 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 ;)
I've not tested it, but I had a quick look at the code and it appears 
that auth_basic doesn't accept variables (yet), so regardless of the 
setting mechanism, I don't think it will work.

Adding variable support to auth_basic, though, could be useful it seems.

Cheers,

Marcus.



More information about the nginx mailing list