nginx - two subdomain configuration

You'll have to create another nginx config file with a serverblock for your subdomain. Like so:

/etc/nginx/sites-enabled/subdomain.example.com

The mistake is putting a server block inside a server block, you should close the main server block then open a new one for the sub domains

server {
    server_name example.com;
    # the rest of the config
}
server {
    server_name sub1.example.com;
    # sub1 config
}
server {
    server_name sub2.example.com;
    # sub2 config
}

You just need to add the following line in place of your server_name

server_name xyz.com  *.xyz.com;

And restart Nginx. That's it.