I'm recreating the topic: https://forum.nginx.org/read.php?15,263481
As I've done some tests and localized the problem more or less, it seems to point on a particular issue, but I can't edit the old topic's subject.
I'm deploying an ASP.NET 5 app on Ubuntu 14.04, using nginx (tried versions 1.4.6 and 1.8.0) as reverse proxy like this:
server {
listen 8080;
server_name localhost;
proxy_connect_timeout 5;
proxy_send_timeout 5;
proxy_read_timeout 5;
send_timeout 5;
location / {
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_pass http://127.0.0.1:5002;
}
}
If I'm accessing the app directly via http://127.0.0.1:5002 from local browser, it works correctly and responds fast. However, if accessing 192.168.0.1:8080 or, locally, 127:0.0.1:8080 it doesn't responds correctly.
According to the app log, the requested page is actually rendered quite fast, then application starts to pass it to nginx, but suddenly stops transmitting data without warning (or nginx stops to read the data, while playing as if it is still listening). And transmission is always cut only when close to the end, so if there is more data, the part of this data can make its way through nginx. And if there is very small amount of data to be passed, then almost nothing is passed at all, just response headers. Nginx seems to be unaware of the transmission stop and just waits it to continue, and once it hits the timeout, it just transmits all the data it received to the moment. For small simple template pages it is just response headers. For the larger page with a couple of kilobytes it is also most of the page's html transmitted, but page is incomplete (no closing body and html tags and some other markup).
Sometimes it just the error 504, as no data from the app was transmitted in response.