Welcome! Log In Create A New Profile

Advanced

Re: nginx nested location and different basic authentication file

September 27, 2015 11:04AM
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-forum@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
Subject Author Posted

nginx nested location and different basic authentication file

cacrus September 27, 2015 04:32AM

Re: nginx nested location and different basic authentication file

chris-breda September 27, 2015 11:04AM

Re: nginx nested location and different basic authentication file

Francis Daly September 29, 2015 04:22PM

Re: nginx nested location and different basic authentication file

cacrus September 30, 2015 05:35AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

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