A
A
Alexander Epikhin2019-03-10 17:53:23
Nginx
Alexander Epikhin, 2019-03-10 17:53:23

Why is NGINX returning the wrong site?

There are 2 nginx hosts in the virtual machine kiosan.loc and sijio.loc. Accessing sijio.loc opens kiosan.loc. If you deactivate kiosan.loc, then sijio.loc opens.
kiosan.loc.conf:

server {
        listen 80;
        listen [::]:80;
        root /home/web/hosts/kiosan.loc/www;
        index index.php

        server_name kiosan.loc www.kiosan.loc;

        location ~ \.php$ {
          try_files $uri =404;
          include /etc/nginx/fastcgi.conf;
          fastcgi_pass unix:/run/php/php7.3-fpm-kiosan.loc.sock;
        }

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

        access_log /home/web/hosts/kiosan.loc/logs/access_log;
        error_log /home/web/hosts/kiosan.loc/logs/error_log;
}

sijio.loc.conf:
server {
        listen 80;
        listen [::]:80;
        root /home/web/hosts/sijio.loc/www;
        index index.php

        server_name sijio.loc www.sijio.loc;

        location ~ \.php$ {
          try_files $uri =404;
          include /etc/nginx/fastcgi.conf;
          fastcgi_pass unix:/run/php/php7.3-fpm-sijio.loc.sock;
        }

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

        access_log /home/web/hosts/sijio.loc/logs/access_log;
        error_log /home/web/hosts/sijio.loc/logs/error_log;
}

nginx.conf:
events {
    worker_connections  1024;
    multi_accept off;
}

http {

    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;

    server_names_hash_bucket_size 64;

    client_max_body_size 64m;

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                       '$status $body_bytes_sent "$http_referer" '
                       '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  /var/log/nginx/access.log main buffer=16k flush=2m;

    sendfile        on;
    tcp_nopush      on;
    tcp_nodelay     on;

    keepalive_timeout  65;
    keepalive_requests 100;

    server_tokens on;

    # gzip on;



    include /etc/nginx/conf.d/*.conf;
    include /etc/nginx/sites-enabled/*;

    }

There are symlinks in sites-enabled.
The default host has been removed (in both sites-available and sites-enabled).
After all the changes, nginx rebooted.
There is nothing superfluous in site-enabled. Only 2 symlinks.
When checking for errors (nginx -t) gives:
nginx: [warn] conflicting server name "" on 0.0.0.0:80, ignored
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
Lynn "Coffee Man", 2019-03-10
@leshiple

Forgotten semicolon in index directive. Twice

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question