Turn basic authentication on and off for specific HTTP user agent

hide nginx-forum at nginx.us
Mon Nov 26 08:24:20 UTC 2012


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: http://forum.nginx.org/read.php?2,233214,233214#msg-233214



More information about the nginx mailing list