gpt4 book ai didi

nginx - nginx上的asp.net核心多个应用程序

转载 作者:行者123 更新时间:2023-12-04 18:22:43 25 4
gpt4 key购买 nike

我一直在努力使用 nginx 和主管在 EC2 ubuntu 实例上运行几个 asp.net 核心 web 应用程序。我成功地一次运行一个应用程序,只需在我的 nginx 设置中交换我的端口并重新加载,我就可以在 5000 和 5001 上运行的正在运行的 .netcore 应用程序之间进行交换。我似乎无法弄清楚 nginx 设置使它们同时存在在路径上工作,即:主机名/应用程序1,主机名/应用程序2。

这是我的 Nginx 配置。谁能指出我做错了什么?我的主管正在运行这两个应用程序,我可以通过查看日志并更改默认位置“/”中的端口来验证这一点。

server {
listen 80 default_server;
listen [::]:80 default_server;

# location / {
# proxy_pass http://localhost:5000;
# proxy_http_version 1.1;
# proxy_set_header Upgrade $http_upgrade;
# proxy_set_header Connection keep-alive;
# proxy_set_header Host $host;
# proxy_cache_bypass $http_upgrade;
# }


location /app1 {
rewrite ^/app1(.*) /$1 break;
proxy_pass http://localhost:5000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection keep-alive;
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}

location /app2{
rewrite ^/app2(.*) /$1 break;
proxy_pass http://localhost:5001;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection keep-alive;
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}

我没有简单的默认路线,因为我还没有任何东西可以放在那里。

最佳答案

看起来解决方案是在位置和代理通行证上添加斜杠

server {
listen 80 default_server;
listen [::]:80 default_server;

# location / {
# proxy_pass http://localhost:5000;
# proxy_http_version 1.1;
# proxy_set_header Upgrade $http_upgrade;
# proxy_set_header Connection keep-alive;
# proxy_set_header Host $host;
# proxy_cache_bypass $http_upgrade;
# }


location /app1/ {
proxy_pass http://localhost:5000/;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection keep-alive;
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}

location /app2/ {
proxy_pass http://localhost:5001/;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection keep-alive;
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}

关于nginx - nginx上的asp.net核心多个应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45745503/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com