Welcome! Log In Create A New Profile

Advanced

Re: auth_basic error nginx: [emerg] "auth_basic" directive is not allowed here in

Maxim Dounin
October 15, 2014 08:10AM
Hello!

On Wed, Oct 15, 2014 at 07:55:07AM -0400, shambler81 wrote:

> http://nginx.org/ru/docs/http/ngx_http_auth_basic_module.html
> По документации все должно работать вот так:
>
> if ($host ~ "(dev|pma).example.com" ) {
> auth_basic "Website development";
> auth_basic_user_file /var/www/domain.com/www/dev/authfile;
> }
>
>
> Но оно выдает: auth_basic error nginx: [emerg] "auth_basic" directive is not
> allowed here in

Документация говорит, что директиву auth_basic можно использовать
в контексте "http, server, location, limit_except". Использовать
к контексте if директиву auth_basic нельзя.

[...]

> ПОЧЕМУ ?

http://wiki.nginx.org/IfIsEvil

Правильное решение в данном случае - отдельный блок server{}.

В общем случае - директива auth_basic понимает переменные, и
соответственно там можно написать "Closed site" или "off" в
зависимости от ранее проверенных условий.

--
Maxim Dounin
http://nginx.org/

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

auth_basic error nginx: [emerg] "auth_basic" directive is not allowed here in

shambler81 October 15, 2014 07:55AM

Re: auth_basic error nginx: [emerg] "auth_basic" directive is not allowed here in

Maxim Dounin October 15, 2014 08:10AM

Re: auth_basic error nginx: [emerg] "auth_basic" directive is not allowed here in

shambler81 October 15, 2014 08:51AM

Re: auth_basic error nginx: [emerg] "auth_basic" directive is not allowed here in

Maxim Dounin October 15, 2014 09:48AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

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