How to Exclude Basic Auth from Nginx Subdomain

I have the two lines of basic auth added in the nginx.conf.

So that all subdomain blocks under reverse proxy are password protected. But I do have a few in which I don't want it to have that.

What do I need to include in those server blocks in order to let them thru?

Thank you!

And sorry I don't know what wildcard is nor if it is applicable in this case.


Solution 1:

There is an option to turn off on server block using auth_basic off;. Add it to the root location of each subdomain.

server {
   ...
   server_name sub.example;
   ...
   location / {
       ....
       auth_basic off;
   }
}

Source : https://nginx.org/en/docs/http/ngx_http_auth_basic_module.html#auth_basic