【发布时间】:2023-03-27 13:09:02
【问题描述】:
所以问题是我有 1 个 ip(例如 127.0.0.1)
在我的服务器上有 2 个不同的 django 应用程序
1. /api 0.0.0.0:8000
2. /data 0.0.0.0:8090
3. / this will go to default pages served up by nodejs
我需要弄清楚 nginx 配置如何部署这些单独的服务,每个服务都有自己的数据库。
在导航时,如果某个端点被命中,它将被路由到适当的应用程序,否则它将默认到 nodejs 应用程序。
额外信息: 登录 /api/admin/ 时,它被路由到 /admin 并失败 请考虑 django 所做的重定向。 我尝试了很多东西,包括设置主机或位置
这将是 2 天后的赏金,所以狩猎愉快。
当前的 nginx
upstream app1 {
server 0.0.0.0:8000;
}
upstream app2 {
server 0.0.0.0:8090;
}
server {
listen 80;
server_name localhost;
location / {
error_log /var/log/webapp/error.log debug;
access_log /var/log/webapp/access.log;
proxy_pass http://0.0.0.0:3000;
proxy_redirect off;
}
location /api {
location /api/static {
alias /var/tmp/app1/static;
#autoindex on;
}
proxy_pass http://app1;
proxy_redirect off;
}
location /data {
location /data/static {
alias /var/tmp/app2/static;
}
proxy_pass http://app2;
proxy_redirect off;
}
}
【问题讨论】:
-
你在用docker吗?
-
能否分享完整的 nginx 配置文件
-
不使用 docker
-
我会让这笔交易变得更甜蜜.... 2 天后,这个问题就有资格获得赏金。接受的答案将获得 75 分。