At beginning, I created a conf file that work correctly when I want to access to http://www.domain.com
:
server {
listen 80;
listen [::]:80;
root /var/www/domain;
index index.html
server_name domain.com www.domain.com;
}
Then I decide to create another conf file for a subdomain :
server {
listen 80;
listen [::]:80;
root /var/www/subdomain.domain;
index index.html
server_name subdomain.domain.com;
}
Now the probleme is that whenever I want to access to http://www.domain.com
or http://subdomain.domain.com
, in both case the result is the page that I should obtain for the subdomain.
The new conf file is correctly added to site-enabled
folder :
ln -s /etc/nginx/site-available/subdomain.domain.conf /etc/nginx/site-enabled/subdomain.domain.conf
And this is how my DNS records looks like :
domain.com. IN A <server_ip>
www.domain.com. IN A <server_ip>
subdomain.domain.com. IN A <server_ip>