简体   繁体   English

为Kestrel AspNet5运行Nginx代理

[英]Running Nginx proxy for Kestrel AspNet5

I am having some troubles running Nginx server to proxy requests to Kestrel. 我在运行Nginx服务器以将请求代理到Kestrel时遇到一些麻烦。 In Kestrel i can see responses coming relatively fast, bust Nginx for some reason waiting til timeout to return the response. 在Kestrel中,我可以看到响应相对较快,由于某种原因使Nginx崩溃,直到超时才返回响应。

Here is my proxy conf: 这是我的代理配置文件:

server {
 listen   80;
 server_name    192.168.163.143;
 access_log     /var/log/nginx/mydomain.access.log;
 location / {
        proxy_set_header X-Forwarded-Host $host;
        proxy_set_header X-Forwarded-Server $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_redirect off;
        proxy_pass      http://127.0.0.1:5000;
 }
}

ngic.conf: ngic.conf:

worker_processes 1;
events{
worker_connections 768;
}

I run kestrel with default arguments to run application on port 5000. 我使用默认参数运行kestrel以在端口5000上运行应用程序。

Giving it to be requested from browser at 192.168.163.143 does not return a json until timeout. 允许从192.168.163.143的浏览器请求它直到超时才返回json。

I have tried curl my endpoint and what i have found is: Direct Kestrel call returns whole batch of data at once, while Nginx call returns a portion of json and stucks... 我试过卷曲我的端点,发现的是:直接Kestrel调用一次返回整批数据,而Nginx调用返回json和卡住的一部分...

Any idea? 任何想法?

Ok, the solution was quite simple. 好的,解决方案非常简单。 RC1 of Kestrel does not work with closed connection, therefore you have to keep alive ur connection. Kestrel的RC1不适用于封闭连接,因此您必须保持活动连接。

In the location section of ur proxy configuration, add proxy_set_header Connection "" 在您的代理配置的位置部分中,添加proxy_set_header Connection ""

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM