Name based virtual hosts not working

zzyber nginx-forum at forum.nginx.org
Sat Mar 12 05:40:53 UTC 2016


Hi!

I just did a lemp setup but I can't get my virtual hosts to work properly.
I´m totally lost and out of ideas.
Two domains and one starting on e is always responding showing its root and
the other starting on s is just dead. I understand that nginx is handling
this as Apache analyzing the headers for a match and if no match it goes
alphabetically taking the first as default domain.

I have my configuration files in /etc/nginx/conf.d, domain1.conf and
domain2.conf and the root pointing to /var/www/domain1/html and 
/var/www/domain2/html
The domains are pointed A records to my public IP

What can be wrong here? So many people having this problem but I can´t find
a solution. I hope this forum are holding cutting edge professionals to help
me out.

config file 

server {
    listen 80;

    root /var/www/domain1/html;
    index index.php index.html index.htm;

    server_name domain1.com www.domain1.com;

    location / {
            try_files $uri $uri/ /index.php;
    }

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


/zzyber

Posted at Nginx Forum: https://forum.nginx.org/read.php?2,265259,265259#msg-265259



More information about the nginx mailing list