How to configure two packaged react applications on the same domain name and port on nginx?

server {
    listen       80;
    server_name  localhost;

    location /a {
        root   /test/nginx/a;
        index  index.html index.htm;
    try_files $uri /index.html =404;
    }

    location /b {
        root   /test/nginx/b;
        index  index.html index.htm;
    try_files $uri /index.html =404;
    }
}

it is useless for me to write this way of thinking at present!
is there any other way to write it?

Mar.21,2021

server {
    listen       80;
    server_name  localhost;
    
    root   /test/nginx;

    location /a {
    index  /a/index.html index.htm;
    try_files $uri /index.html =404;
    }

    location /b {
    index  /b/index.html index.htm;
    try_files $uri /index.html =404;
    }
}

how about this?


server {
    listen       80;
    server_name  localhost;

    location /a {
        alias /test/nginx/a;
        index  index.html index.htm;
        try_files $uri /a/index.html;
    }

    location /b {
        alias /test/nginx/b;
        index  index.html index.htm;
        try_files $uri /b/index.html;
    }
}
  • After the react agent is deployed, access 404

    problem description: 1.react implements a dynamic proxy in package.json, as follows: "proxy": "http: www.iamcrawler.cn:4000" 2. When you get up locally, you can access it. 3. After packaging with run build, put it in the corres...

    Mar.22,2021
Menu