Nginx dynamic second-level domain name configuration. While excluding a particular

nginx dynamic second-level domain name configuration. Exclude a specific

at the same time

I now configure the second-level domain name as dynamic.
~ ^ (< subdomain >. +). Baidu.com$;

but I need to exclude m.baidu.com.
~ ^ ((< subdomain >. +)! M) .baidu.com $;

this method of writing has not been realized. Could you tell me how to configure it?

< hr >

you don"t have to wait in line when you find a solution. Directly configure a separate

< hr >

there is no need to exclude the second-level domain names that have already been configured, because the matching order of server_name is like this

matches accurate server_name , that is,
matches server_name starting with * wildcard, that is,
matching of pan-domain name resolution ends with * wildcard server_name
regular match
does not match. Determine whether to set default
the rule that default, is not configured before takes effect
priority. The configured second-level domain name has the highest priority, so there is no need to do anything to exclude

Apr.09,2021

The regularity of

nginx does not support negative matching
by adding a server to

.
server {
    listen 80;
    server_name m.example.com;
    return 404;
    access_log off;
}
Menu