T
T
tuxx2016-10-03 21:36:26
Nginx
tuxx, 2016-10-03 21:36:26

Why is the wrong site opening?

There is a server with several different sites. The server runs a bunch of Nginx + php-fpm and Node.js on its port. Today I added another site from the .su domain zone. All other sites .com, .ru, .rf. The new site does not open. Instead, one of the workers opens. There are no errors in the logs. For each site, the nginx conf file looks almost the same. The difference is only in root, server_name and error_log:

upstream php-fpm-site_code_name
{
        server unix:/var/run/php5-fpm.sock;
}
server
{
        listen 127.0.0.1:80;
        root /var/www/site_code_name/public_html;
        error_log /var/log/site_code_name/error.log;
        index index.php index.html index.htm;
        server_name site_code_name www.site_code_name;
        rewrite ^([^.]*[^/])$ $1/ permanent;

        location /
        {
                index index.php index.html index.htm;
                try_files $uri $uri/ =404;
                fastcgi_pass    php-fpm-site_code_name;
                include fastcgi_params;
                fastcgi_split_path_info                 ^(.+?\.php)(/.*)?$;
                fastcgi_param   SCRIPT_FILENAME         $document_root$fastcgi_script_name;
                fastcgi_param   PATH_TRANSLATED         $document_root$fastcgi_script_name;
                set             $path_info              $fastcgi_path_info;
                fastcgi_param   PATH_INFO               $path_info;
                fastcgi_param   SERVER_SIGNATURE        nginx/$nginx_version;
                fastcgi_index   index.php;
                fastcgi_buffers 4 512k;
                fastcgi_busy_buffers_size 512k;
                fastcgi_temp_file_write_size 512k;
        }

        location ~* .(html|js|css|htm|jpeg|jpg|jpg|gif|png|woff|woff2|ttf|mp3|svg|xml|ico|conf|eot|json|log|yml|txt|steamd|otf)$
        {
                        root /var/www/site_code_name/public_html;
                        error_page 404 = 404;
        }
}

There are several such files in /etc/nginx/sites-available. All are symlinked to /etc/nginx/sites-enabled
If you reload nginx, the site displayed on the new domain changes.
What is wrong with the configuration that it works like that?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
T
tuxx, 2016-10-04
@tuxx

The problem was solved stupidly by combining all the configs into a single conf file and creating a symbolic link to it from sites-enabled. Removed other conf files

M
Maxim, 2016-10-03
@pudovMaxim

nginx has a parameter, default server. This is the server that will be returned if the requested one is not found. It may or may not be specified explicitly. I thought that he would always spit out the first one in the config, but probably not always so.
Check your new domain settings. Perhaps the config is not being pulled up or there is some kind of error in it.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question