I have in the *.conf file for my domain the following:
server {
listen 80;
server_name domain.tld;
access_log /var/log/nginx/domain.tld.accesslog;
root /var/www/domain.tld;
index index.htm index.html;
}
My question is... what if I wanted to make all subdomains use the same document root (and same settings in general) as domain.tld?
I tried this:
server {
listen 80;
server_name domain.tld;
server_name *.domain.tld;
access_log /var/log/nginx/domain.tld.accesslog;
root /var/www/domain.tld;
index index.htm index.html;
}
But that didn't work, even after reloading. Any ideas?
I think the above is the problem. Try this instead:
There's special syntax "sugar" to handle this gracefully:
but in case you're ex-assembler programmer counting CPU-cycles in your spare time, you might want to trade simplicity of shorter notation for explicit long listing of server's names (10x2 @cnst).