Report this

What is the reason for this report?

Two domains on the same Nginx server

Posted on April 14, 2015

Hi, I have one site already set up on Nginx and tried to add a second but is not working.

Every time I try to access the second field I am directed to the first domain. What might be happening?

site1 = inforlogia.com site2 = tudodesconto.com

config for site1:

server {
	listen 80 default_server;
	error_log /var/www/error.log;
	access_log off;
	root /var/www/inforlogia.com;
	server_name inforlogia.com;
	index index.php;
	include /etc/nginx/wordpress.conf;
}

config for site2:

server {
	listen 80;
	listen [::]:80;
	error_log /var/www/error.tudodesconto.log;
	access_log off;
	root /var/www/tudodesconto.com;
	server_name tudodesconto.com;
	index index.php;
	include /etc/nginx/wordpress.conf;

}

wordpress.conf

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

	location / {
	try_files $uri $uri/ /index.html;
	rewrite ^/sitemap_index\.xml$ /index.php?sitemap=1 last;
	rewrite ^/([^/]+?)-sitemap([0-9]+)?\.xml$ /index.php?sitemap=$1&sitemap_n=$2 last;
	}

	location ~ \.conf$ {
	deny all;
	}

	if (!-e $request_filename)
	{
	rewrite ^(.+)$ /index.php?q=$1 last;
	}


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!

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.

I solved the problem. I changed (each block):

server {
    server_name inforlogia.com;
......

}

to

server {
    server_name inforlogia.com www.inforlogia.com;
......

}

I spent two days on it …

This comment has been deleted

The developer cloud

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

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.