cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Highlighted

Unable to configure subdomains with NGINX

I've recently bought a Domain (leonloncaric.xyz) on Go Daddy which I would like to connect to my home server. I want to setup my domain such that on leonloncaric.xyz I will serve my personal website and on the subdomain e.g. app1.leonloncaric.xyz I want to serve a react application. What instead happens is that both my main domain and subdomain serve the same website

 

But what is also interesting if I edit the /etc/hosts of my desktop computer (not the server's hosts file) and add the following lines, i get served the correct websites for my domain and subdomain.

 

<local ip of server> leonloncaric.xyz
<local ip of server> app1.leonloncaric.xyz

So now I'm really not sure what is wrong, I've tried messing around with the DNS settings and going trough some tutorials for setting up NGINX with subdomains, but no luck. Any help is greatly appreciated.

 

 

My NGINX configurations are the following:

 

 

# Main Website
server {  

  listen 80;
  server_name leonloncaric.xyz;

  root /var/www/html;
  index index.html;

  location / {
	try_files $uri /index.html =404;
  }
}

# APP
server {  

  listen 80;
  server_name app1.leonloncaric.xyz;

  root /var/www/app1;
  index index.html;

  location / {
	try_files $uri /index.html =404;
  }
}

These are my DNS settings:

 

godaddy.png