nginx nested location and different basic authentication file

cacrus nginx-forum at nginx.us
Sun Sep 27 08:32:56 UTC 2015


Hi , 

I am trying to setup different authentication based on different strings in
the $request , here is my case . 

        location  /parent/ {
                set $basic_file /nginx/conf/.htpasswd;
                if ($request_uri ~  (visualize|dashboard|settings)){
                set $basic_file /nginx/conf/.dev_pass;
                }
                proxy_pass         http://<some ip and port >/;
                auth_basic "Restricted";
                auth_basic_user_file $basic_file;
        }

I would like  file .htpasswd to be used by default and in case of
$request_uri having (visualize|dashboard|settings) , auth should happen via
.dev_pass .

For some reason the authentication is happening only via  htpasswd  even if
i have (visualize|dashboard|settings) in the URI . 

Any idea , what am i missing?

Posted at Nginx Forum: http://forum.nginx.org/read.php?2,261867,261867#msg-261867



More information about the nginx mailing list