R
R
Ruslan2021-06-15 11:22:39
Nginx
Ruslan, 2021-06-15 11:22:39

How to specify in the config for an alternative route - alternative html?

I want to make it so that when I log in from a browser via https://0.0.0.0 , "location /" works,
and when I log in via https://0.0.0.0/site2 , "location /site2" works,

but for some reason it always works " location /".
Both sites are on React, but it hardly matters

nginx.conf snippet:

server {
        listen 80;
        server_name ipaddr;

        location = /favicon.ico {
            alias  /home/siteadmin/site1/favicon.ico;
        }  

        location / {
            root /home/siteadmin/site1;
            try_files $uri $uri/ /index.html;
        }

  location = /site2 {
             root /home/siteadmin/site2;
             index index.html;
             try_files $uri $uri/ /index.html;
        }
    }


I will be grateful for help.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Ruslan, 2021-06-15
@Rus17

Understood.
In fact, the path is a little longer than I indicated in the message, I decided to simplify and in vain.
Path: /home/siteadmin/site2/client/index.html
So the code worked:

location /client {
             root /home/siteadmin/site2;
             index index.html;
             try_files  $uri $uri/ /client/index.html;
}

Everything opens to the request https://0.0.0.0/client
Apparently you need to rename the client pack.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question