好像Nginx代理服务器不起作用

时间:2019-01-17 20:16:28

标签: nginx asp.net-core

我是Linux和Nginx托管的新手。我有一个简单的ASP网络核心应用程序,我需要在https://localhost:5050上运行。因此,我在https://localhost上发送了一个请求,并等待Nginx将其处理到:5050端口。但这不是..

我使用以下代码创建了\ etc \ nginx \ sites-available \ aspnetcore.conf

server {
    listen 443;

    location / {
        proxy_pass https://localhost:5050; 
        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;
    }
}

和一个symbolinc链接到/etc/nginx/sites-enabled/aspnetcore.conf。 我也有Startup.cs文件

app.UseForwardedHeaders(new ForwardedHeadersOptions
{
    ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto
});

因此我的应用程序未收到任何请求。我在做什么错了?

UPD: https联系人中的问题。我在这里配置了ssl https://www.digitalocean.com/community/tutorials/how-to-create-a-self-signed-ssl-certificate-for-nginx-on-debian-9 但是仍然没有请求...

1 个答案:

答案 0 :(得分:0)

upstream backend {
    server localhost:5050;
}

server {
    listen 443;

    location / {
        proxy_pass http://backend;
        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;
    }
}