Question

Domain names are indifferent

Hello,

I have followed this post and tried to make two domains work on a single server.

To make thing simpler, I don’t want to set up a default server.

/etc/nginx/sites-available/addbba.com

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

        root /var/www/addbba.com/html;
        index index.php index.html index.htm;

        server_name addbba.com www.addbba.com;

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

        error_page 404 /404.html;

        error_page 500 502 503 504 /50x.html;
        location = /50x.html {
                root /usr/share/nginx/html;
        }

        location ~ \.php$ {
                try_files $uri =404;
                fastcgi_split_path_info ^(.+\.php)(/.+)$;
                fastcgi_pass unix:/var/run/php5-fpm.sock;
                fastcgi_index index.php;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                include fastcgi_params;
        }
}

/etc/nginx/sites-available/matrixandcompany.com

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

        root /var/www/matrixandcompany.com/html;
        index index.php index.html index.htm;

        server_name matrixandcompany.com www.matrixandcompany.com;

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

        error_page 404 /404.html;

        error_page 500 502 503 504 /50x.html;
        location = /50x.html {
                root /usr/share/nginx/html;
        }

        location ~ \.php$ {
                try_files $uri =404;
                fastcgi_split_path_info ^(.+\.php)(/.+)$;
                fastcgi_pass unix:/var/run/php5-fpm.sock;
                fastcgi_index index.php;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                include fastcgi_params;
        }
}

I bought two domains addbba.com and matrixandcompany.com both from GoDaddy, I made them forward and mask to the IP 178.62.87.72 that I bought from DigitalOcean.

The result of the above configuration is that, the two URLs and 178.62.87.72 all lead to the same page of addbba.com.

If I delete the /etc/nginx/sites-enabled/addbba.com and leave only /etc/nginx/sites-enabled/matrixandcompany.com, the two URLs and 178.62.87.72 all lead to the same page of matrixandcompany.com.

So it seems that the URL is not well parsed and does not make any difference. Did I set something wrong in GoDaddy (maybe DNS?), or in nginx?

Thank you

Subscribe
Share

Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

If you take a closer look at one of the URL’s source code, you will see that it contains the following:

<frameset rows="100%,*" border="0">
  <frame src="http://178.62.87.72" frameborder="0" />
  <frame frameborder="0" noresize />
</frameset>

This is because you have set up your domains to “forward” to your IP address. GoDaddy does that by hosting a page for you that loads http://178.62.87.72/. So, even if you browse to http://matrixandcompany.com, nginx will receive a request for 178.62.87.72 because of GoDaddy’s forwarding.

You need to point the DNS records to your droplet instead of setting up forwarding. You can do that by either using GoDaddy’s DNS Manager, or setting your domains’ nameservers to DigitalOcean’s.

The following tutorials should help you point your domains’ nameservers to DigitalOcean’s nameservers and configure the proper DNS records:

  1. How to Point to DigitalOcean Nameservers From Common Domain Registrars
  2. How To Set Up a Host Name with DigitalOcean