I have a setup with my blog at example.com
server { listen 8082; ## listen for ipv4; this line is default and implied #listen [::]:80 default ipv6only=on; ## listen for ipv6 server_name example.com; And to redirect from www. to non-www i also have this block:
server { listen 8082; server_name www.example.com; return 301 http://example.com$request_uri; } This also works, but then i wanted to add a subdomain: "api.example.com". First i tried adding another file in sites-available and symlinking to sites-enabled. But that didn't work, the second file did not trigger at all.
Next i added the subdomain as a serverblock in the first file. That worked. But now every subdomain lead to api.example.com.
First i don't understand how "test.example.com" can lead to this serverblock:
server { listen 8082; ## listen for ipv4; this line is default and implied #listen [::]:80 default ipv6only=on; ## listen for ipv6 server_name api.example.com; } since server_name is api.example.com, and test.example.com is another subdomain. And how can i let every subdomain not specified lead to mainpage or custom error page?
/sites-enabled/folder?