The following rules duplicate the proxy
directives and I would prefer to only mention them once:
location /view/ {
# Duplicated!
proxy_pass http://127.0.0.1:9292;
proxy_set_header Host $host;
}
location /api/ {
# Duplicated!
proxy_pass http://127.0.0.1:9292;
proxy_set_header Host $host;
auth_basic "esqulino Testbetrieb";
auth_basic_user_file /srv/svn/users.conf;
}
There are more locations then the ones that I have mentioned here, so specifying the proxy
directives globally is not an option.
My naive approach was to simply extend the first location with a regex, mention the proxy there and then only specifying the auth
section for the API:
location ~ /(api|view)/ {
proxy_pass http://127.0.0.1:9292;
proxy_set_header Host $host;
}
location /api/ {
auth_basic "esqulino Testbetrieb";
auth_basic_user_file /srv/svn/users.conf;
}
But for some reason this does not trigger the authentication at all.
How could I mention the proxy
(or actually any) directives only once for a set of locations and still "overload" some more specific locations with additional directives like auth_basic
?