Not an nginx expert but i think you can use a map http://nginx.org/en/docs/http/ngx_http_map_module.html You dont even need an if.
Live long and prosper, Christ-Jan Wijtmans https://github.com/cjwijtmans http://facebook.com/cj.wijtmans http://twitter.com/cjwijtmans On Sun, Sep 27, 2015 at 10:32 AM, cacrus <nginx-fo...@nginx.us> wrote: > 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 > > _______________________________________________ > nginx mailing list > nginx@nginx.org > http://mailman.nginx.org/mailman/listinfo/nginx _______________________________________________ nginx mailing list nginx@nginx.org http://mailman.nginx.org/mailman/listinfo/nginx