aris
1
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.
Posted at Nginx Forum:
hide
2
On Mon, Nov 26, 2012 at 03:24:20AM -0500, hide wrote:
#…
}
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;
}
}