Welcome! Log In Create A New Profile

Advanced

Re: Turn basic authentication on and off for specific HTTP user agent

Ruslan Ermilov
December 10, 2012 08:34AM
On Mon, Nov 26, 2012 at 03:24:20AM -0500, hide wrote:
> Hello All!
>
> Is it possible to turn authentication on and off for a specific user agent
> in some location? When I configure the following
>
> location /specloc/ {
> if ($http_user_agent ~ MSIE) {
> auth_basic "private area";
> auth_basic_user_file /etc/nginx/htpasswd;
> }
> #...
> }
>
> my "nginx -t" prints
>
> nginx: [emerg] "auth_basic" directive is not allowed here in
> /etc/nginx/nginx.conf:75
> nginx: configuration file /etc/nginx/nginx.conf test failed
>
> Thank you if you answer.

http://trac.nginx.org/nginx/changeset/4946/nginx

As of this change, you can do it like this:

map $http_user_agent $realm {
default off;
~MSIE "private area";
}

server {
location /specloc/ {
auth_basic $realm;
auth_basic_user_file /etc/nginx/htpasswd;
}
}

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

Turn basic authentication on and off for specific HTTP user agent

hide November 26, 2012 03:24AM

Re: Turn basic authentication on and off for specific HTTP user agent

Ruslan Ermilov December 10, 2012 08:34AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

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