I don't know why server_name example.com matches also subdomains (at least when there's not a rule for those), if there's an specific syntax for doing so:
Nginx documentation states that you can define server_name in the following ways:
Sets names of a virtual server, for example:
server_name example.com;Server names can include an asterisk (“*”) replacing the first or last part of a name:
server_name *.example.com;Such names are called wildcard names.
The first two of the names mentioned above can be combined in one:
server_name .example.com;
But I tested this, and example.com behaves just as .example.com is expected, matching also all the subdomains.
This is not a problem as I can override the subdomains by setting a server for *.example.com but it seems very odd to me that if the syntax of .example.com exists with the intention to match both other two, it should mean that the other two don't match to eachother...
Why is this?