Report this

What is the reason for this report?

Nginx server block displaying wrong site on droplet

Posted on September 12, 2020

I have 3 sites on one droplet. The first two work fine, but as I add a third following this guide it directs itself to the first site I uploaded to the droplet. I’ve triple checked my symlinks between sites-enabled and sites-available, and the files themselves within (including having a www. and non www. listed in the server_name line), and I can’t understand why this would be happening when the second site never had this problem following the same method. I even restored a backup of my entire droplet and redid it, but the problem persists. Below are the two files under sites-available (the only difference being an SSL cert by certbot in the first site):

Original Site

server {
  listen 80;
  listen [::]:80;
  
  root /var/www/anchoridea.com/html;
  index index.html index.htm index.nginx-debian.html;

  server_name anchoridea.com www.anchoridea.com;

  location / {
    try_files $uri $uri/ =404;
  }

    listen [::]:443 ssl ipv6only=on; # managed by Certbot
    listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/anchoridea.com/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/anchoridea.com/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot


}
server {
    if ($host = www.anchoridea.com) {
        return 301 https://$host$request_uri;
    } # managed by Certbot


    if ($host = anchoridea.com) {
        return 301 https://$host$request_uri;
    } # managed by Certbot


  listen 80;
  listen [::]:80;

  server_name anchoridea.com www.anchoridea.com;
    return 404; # managed by Certbot




}

New Site

server {
	listen 80;
	listen [::]:80;
	root /var/www/prairiestormpaintball.com/html;
	index index.html index.htm index.nginx-debian.html;

	server_name prairiestormpaintball.com www.prairiestormpaintball.com;

	location / {
		try_files $uri $uri/ =404;
	}
}

Any help would be greatly appreciated, thanks!

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Start building today

From GPU-powered inference and Kubernetes to managed databases and storage, get everything you need to build, scale, and deploy intelligent applications.