I need an expression to match all requests, no matter what.
Is this good enough?
location ~ ^/
I'm worried about other locations taking precedence, bypassing my auth.
You can put ngx_http_auth_basic_module
settings into any of the following contexts:
http, server, location, limit_except
Your version
location ~ ^/
Would work only if you don't have another declared locations in your server
section
example:
server {
... #some server settings
location / { # full equivalent for "~ ^/"
auth_basic on;
auth_basic_user_file /path/to/some/file;
}
location /other_location {
# here http_auth not inherited
}
}
Just put your http_auth
settings into server
section and all locations described for this server
would inherit this settings.
example:
server {
... # some server settings
auth_basic on;
auth_basic_user_file /path/to/some/file;
location / {
# HERE http_auth settings would be
# inherited from previous configuration level.
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With