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
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
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:
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.