NGINX domain shows different directory?

Hi All!

I just started with my linode, I'm still a noob but wanted to give it a go. I followed the linode LEMP documentation and I added 2 domains on my linode.

1. cloudening.com

2. vaughancorp.com

Now the weird thing is when I go to vaughancorp.com I can see the website normally. But now when I go to www.vaughancorp.com I can see the index.php file of cloudening.com.

> I did a: tail /var/log/nginx/error.log and this is the result:

2018/02/12 20:57:11 [error] 14017#14017: *20 directory index of "/var/www/html/cloudening.com/public_html/" is forbidden, client: 49.xxx.xxx.xxx, server: cloudening.com, request: "GET / HTTP/1.1", host: "www.vaughancorp.com"

So the above error log is showing that it's accessing the public_html folder of cloudening

But the Nginx virtual host settings for vaughancorp.com is:

server {
        listen 80;
        listen [::]:80;

        server_name vaughancorp.com;

        root /var/www/html/vaughancorp.com/public_html;
        index index.php index.html;

        location / {
                try_files $uri $uri/ =404;
        }
        location ~ \.php$ {
                include snippets/fastcgi-php.conf;
                include fastcgi_params;
                fastcgi_pass unix:/run/php/php7.0-fpm.sock;
                fastcgi_param SCRIPT_FILENAME /var/www/html/vaughancorp.com/public_html$fastcgi_script_name;
        }
}

So it got me thinking that it might be on my domain manager, so what I did was I deleted the A record of hostname www and then added a cname of www that points to vaughancorp.com, but still did not work.

Now if I view cloudening.com and www.cloudening.com it shows the correct files/page.

And now if I go to www.vaughancorp.com it shows me the cloudening.com index.php file?

Your thoughts? Thanks!

1 Reply

Okay never mind, I fixed this by adding:

server_name vaughancorp.com www.vaughancorp.com;

Hope this helps newbies like me.

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct