鍍金池/ 問(wèn)答/Linux  HTML/ 如何在nginx上的同一域名及端口上配置兩個(gè)打包后的react應(yīng)用?

如何在nginx上的同一域名及端口上配置兩個(gè)打包后的react應(yīng)用?

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;
    }
}

目前的思路我這樣寫是沒(méi)有用的!
請(qǐng)問(wèn)還有什么寫法嗎?

回答
編輯回答
淚染裳
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;
    }
}
2017年3月13日 17:36
編輯回答
柚稚
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;
    }
}

這樣呢?

2018年7月19日 06:14