I have multiple "server" blocks in my nginx.conf. The documentation seems wrong about the order in which server_name matching takes places.
My conf looks something like:
server { listen 80 server_name domain.com *.domain.com # do stuff } server { listen 80 server_name sub.domain.com *.sub.domain.com # do something else }
I'm trying to figure out why requests with host = www.sub.domain.com are going to the correct place (the second server), when the documentation indicates it should be going to the first server.
Nginx documentation indicates that the server blocks are checked "in order" for matches, meaning any request with the host *.sub.domain.com should be caught by the first server, not the second server. (http://wiki.nginx.org/HttpCoreModule#server_name)
Also, the * wildcard matches any number of subdomain parts, so *.domain.com matches www.sub.domain.com. (http://nginx.org/en/docs/http/server_names.html#wildcard_names)
If this documentation is wrong, what is the actual matching order?