微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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

我一直在努力使用Nginx和supervisor在EC2 ubuntu实例上运行一些asp.net核心webapps.我成功地一次运行一个应用程序,只需在我的Nginx设置中交换我的端口并重新加载我可以在运行5000和5001的运行.netcore应用程序之间切换.我似乎无法找出Nginx设置来使它们两者在路径上工作,即:hostname / app1,hostname / app2.

这是我的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;
    }
}

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

解决方法:

看起来解决方案是在位置和proxypass上尾随斜杠

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

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐