gpt4 book ai didi

asp.net-core - 502 Bad Gateway 在 Ubuntu 20.04 上的 NGINX 上运行 ASP .NET Core 5 站点

转载 作者:行者123 更新时间:2023-12-04 19:27:19 24 4
gpt4 key购买 nike

不确定是什么问题:

502 Bad Gateway
nginx/1.18.0 (Ubuntu)
来自 nginx 日志:
2021/11/05 21:59:21 [error] 59385#59385: *1 connect() failed (111: Connection refused) while connecting to upstream, client: x.x.x.x, server: mydomain.com, request: "GET / HTTP/1.1", upstream: "http://127.0.0.1:5004/", host: "mdomain.com"
我的站点 nginx 配置:
server {
listen 80;
listen [::]:80;
server_name mydomain.com www.mydomain.com;
return 301 https://$host$request_uri;
}
server {
listen 443 ssl;
listen [::]:443 ssl;
server_name mydomain.com www.mydomain.com;
ssl_certificate /etc/letsencrypt/live/mydomain.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/mydomain.com/privkey.pem;
root /var/www/mydomain.com;
large_client_header_buffers 4 16k;
location / {
proxy_pass http://localhost:5004;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection keep-alive;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_cache_bypass $http_upgrade;
proxy_buffer_size 128k;
proxy_buffers 4 256k;
proxy_busy_buffers_size 256k;
}
location ~ /.well-known {
root /var/www/mydomain.com;
}
}
我的 ASP .NET core 5 站点:
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
webBuilder.UseUrls("http://localhost:5004");
});

最佳答案

对于任何有同样问题的人,我在我的 ASP .NET 项目的 url 中使用了通配符,它​​可以工作。
webBuilder.UseUrls("http://*:5004");

关于asp.net-core - 502 Bad Gateway 在 Ubuntu 20.04 上的 NGINX 上运行 ASP .NET Core 5 站点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69859771/

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