簡體   English   中英

如何為同一服務器上的三個應用程序配置我的 nginx 配置文件

[英]how to configure my nginx config file for three apps on the same server

你好,我有三個應用程序(react、angular 和 node)我想配置我的 nginx 文件來實現這個:mysite.com 用於 react,mysite.com/admin 用於 angular,pmysite.com/api 用於 node 應用程序

    #node app
    location /api/ {
            proxy_pass http://127.0.0.1:3000;
            access_log /var/log/nginx/mysite.log;
            error_log /var/log/nginx/mysite_error.log;
    }
    #angular app
    location /admin {
    root /var/www/mysite/backoffice/dist/index.html;
                    access_log /var/log/nginx/mysite_bo.log;
            error_log /var/log/nginx/mysite_bo.log;
    }
    location ~ \.(aac|m3u8|ts) {
            root /var/www/mysite/media;
    }
    location  /uploads/ {
           root  /var/www/mysite/;
   }
   #react app
    location / {
            proxy_pass http://127.0.0.1:3006;
            access_log /var/log/nginx/mysite_react.log;
            error_log /var/log/nginx/mysite_react.log;
    }}

/admin 不工作它重定向到 / 任何解決方案?

location /admin塊下的root路徑用作匹配該模式的所有后續請求的基本路徑。 看起來您已經硬編碼了/admin路徑以提供單個文件/var/www/mysite/backoffice/dist/index.html

嘗試更改它以查看是否有效:

location /admin {
    root /var/www/mysite/backoffice/dist;   # change to this
    access_log /var/log/nginx/mysite_bo.log;
    error_log /var/log/nginx/mysite_bo.log;
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM