node.js - 如何为同一服务器上的三个应用程序配置我的 nginx 配置文件
问题描述
你好我有三个应用程序(反应,角度和节点)我想配置我的nginx文件有这个:mysite.com for react,mysite.com/admin for angular,pmysite.com/api for node app
#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 不工作它重定向到 / 任何解决方案?
解决方案
root
块下的路径location /admin
用作与该模式匹配的所有后续请求的基本路径。看起来您已经硬编码了/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;
}
推荐阅读
- java - Java简单递归算法,使其并行
- redis - Redis 默认会触发复制吗?
- c - 在打开的文件中寻找 0 是否比关闭文件然后再次打开它更快?
- javascript - 循环遍历多维数组以生成新数据并在节点 js / javascript 中追加新的键值
- r - 将字符串传递给 tidybayes::spread_draws()
- python - 在 matplotlib 错误栏中,如何通过不同颜色的颜色传递不同的点?
- node.js - 设置锯齿浏览器时被 CORS 策略问题阻止
- python - How to do for loop with a list that contains lists with another list?
- html - 为什么导航栏内的容器有限制宽度而不是填充整个宽度?
- android - 如何使用 okhttp post json 并通过 android 获取 jeson 返回?