【问题标题】:how to configure my nginx config file for three apps on the same server如何为同一服务器上的三个应用程序配置我的 nginx 配置文件
【发布时间】:2020-09-15 18:48:09
【问题描述】:

你好,我有三个应用程序(反应、角度和节点)我想将我的 nginx 文件配置为: mysite.com 用于反应,mysite.com/admin 用于 Angular,pmysite.com/api 用于节点应用程序

    #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 不工作它重定向到/任何解决方案?

【问题讨论】:

  • 问题是……?!
  • /admin 重定向到 / (react app)

标签: node.js reactjs angular nginx


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 2018-02-03
    • 2013-10-05
    • 1970-01-01
    • 1970-01-01
    • 2022-11-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多