Welcome! Log In Create A New Profile

Advanced

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

October 15, 2014 07:55AM
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
В реалии приходится делать костыль

error_page 555 = @pass;
location @pass {
auth_basic "Unauthorized";
auth_basic_user_file /var/www/dev_htpasswd;
proxy_pass http://dev.zap-dom.ru:82;
proxy_set_header Host dev.zap-dom.ru;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Real-IP $remote_addr;
}

# В location / вписывем условие
if ($http_host ~* "^dev\..*\..{2,8}$"){
return 555;
}

ПОЧЕМУ ?
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: 309
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