R
R
Ruslan Absalyamov2018-11-13 19:07:29
Nginx
Ruslan Absalyamov, 2018-11-13 19:07:29

Why is the wrong website opening for me?

I have 2 websites backend and frontend. Both should open separately, but for some reason my backend pages open the same way. The fact that admin.rsi.local.
How I configured nginx
/etc/nginx/sites-enabled/rsi.local

server {
        charset utf-8;
        client_max_body_size 128M;

        listen 80;

        root /home/ruslan/Development/rsi/frontend/web;
        index index.php;

        server_name rsi.local;

        access_log /home/ruslan/Development/rsi/vagrant/nginx/log/frontend-access.log;
        error_log /home/ruslan/Development/rsi/vagrant/nginx/log/frontend-error.log;

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

        location ~ \.php$ {
                include snippets/fastcgi-php.conf;
                fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
        }
}

/etc/nginx/sites-enabled/admin.rsi.local
server {
        charset utf-8;
        client_max_body_size 128M;

        listen 80;

        root /home/ruslan/Development/rsi/backend/web;
        index index.php;

        server_name rsi.local;

        access_log /home/ruslan/Development/rsi/vagrant/nginx/log/backend-access.log;
        error_log /home/ruslan/Development/rsi/vagrant/nginx/log/backend-error.log;

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

        location ~ \.php$ {
                include snippets/fastcgi-php.conf;
                fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
        }
}

And in /etc/hosts
127.0.0.1       rsi.local
127.0.0.1       admin.rsi.local

And reloaded nginx
sudo service nginx reload
And it seems that the front in rsi.local should work and the backend in admin.rsi.local should work. But everything works for me from admin.rsi.local even if the address is rsi.local.
Why is this happening. But if you remove it from sites-enabled/admin.rsi.local, then the site from the front works again

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Softer, 2018-11-13
@rusline18

server_name must be different.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question