<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class="">
<div class="">Hello,</div><div class=""><br class=""></div><div class="">i encountered a strange behaviour with nginx, my backend seems to receive twice the same request from nginx proxy, to be sure that it's not the client that send two request i have had an uuid params to each request.</div><div class=""><br class=""></div><div class="">when the problem occurs in nginx log i found one request in success in access.log</div><div class=""><br class=""></div><div class="">x.x.x.x - - [09/Jul/2017:09:18:33 +0200] "GET /query?uid=b85cc8a4-b9cd-4093-aea5-95c0ea1391a6_428 HTTP/1.1" 200 2 "-" "-"</div><div class=""><br class=""></div><div class="">and an other one than generate this log in error.log :</div><div class=""><br class=""></div><div class="">2017/07/09 09:18:31 [error] 38111#38111: *4098505 upstream prematurely closed connection while reading response header from upstream, client: x.x.x.x, server: <a href="http://x.x.com" class="">x.x.com</a>, request: "GET /query?uid=b85cc8a4-b9cd-4093-aea5-95c0ea1391a6_428 HTTP/1.1", upstream: "<a href="http://172.16.0.11:9092/query?uid=b85cc8a4-b9cd-4093-aea5-95c0ea1391a6_428" class="">http://172.16.0.11:9092/query?uid=b85cc8a4-b9cd-4093-aea5-95c0ea1391a6_428</a>", host: "<a href="http://x.x.com" class="">x.x.com</a>"</div><div class=""><br class=""></div><div class="">on my backend i can see two request with the same uuid (the two succeed)</div><div class=""><br class=""></div><div class="">{"pid":11424,"level":"info","message":"[API] AUTH1 /query?uid=b85cc8a4-b9cd-4093-aea5-95c0ea1391a6_428","timestamp":"2017-07-09 09:18:31.861Z"}</div><div class="">{"pid":11424,"level":"info","message":"[API] AUTH1 /query?uid=b85cc8a4-b9cd-4093-aea5-95c0ea1391a6_428","timestamp":"2017-07-09 09:18:33.196Z"}</div><div class=""><br class=""></div><div class="">The client is a node program so i'm sure that it sends only one request with the same uuid (no thread problem ;) </div><div class="">the nginx serve as simple proxy (no load balancing)</div><div class=""><br class=""></div><div class="">[nginx.conf]</div><div class=""><br class=""></div><div class="">user www-data;</div><div class="">worker_processes 8;</div><div class="">worker_rlimit_nofile 8192;</div><div class="">pid /run/nginx.pid;</div><div class=""><br class=""></div><div class="">events {</div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>worker_connections 1024;</div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span># multi_accept on;</div><div class="">}</div><div class=""><br class=""></div><div class="">http {</div><div class=""> </div><div class=""> upstream api {</div><div class=""> keepalive 100;</div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span> server 172.16.0.11:9092;</div><div class=""> }</div><div class=""><br class=""></div><div class=""> include mime.types;</div><div class=""> default_type application/octet-stream; </div><div class=""> sendfile on;</div><div class=""> tcp_nopush on;</div><div class=""> tcp_nodelay on;</div><div class=""> </div><div class=""> proxy_buffering off;</div><div class=""> proxy_buffer_size 128k;</div><div class=""> proxy_buffers 100 128k;</div><div class=""> proxy_http_version 1.1;</div><div class=""> </div><div class=""> ### timeouts ###</div><div class=""> resolver_timeout 6;</div><div class=""> client_header_timeout 30;</div><div class=""> client_body_timeout 600;</div><div class=""> send_timeout 10;</div><div class=""> keepalive_timeout 65 20;</div><div class=""> proxy_read_timeout 600;</div><div class=""> </div><div class=""> server {</div><div class=""> listen 443 ssl;</div><div class=""> listen [::]:443 ssl;</div><div class=""> server_name <a href="http://x.x.com" class="">x.x.com</a>;</div><div class=""> include /etc/nginx/nginx_ssl.conf;</div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span></div><div class=""> client_max_body_size 200M;</div><div class=""><br class=""></div><div class=""> location / {</div><div class=""> proxy_next_upstream off;</div><div class=""> proxy_pass <a href="http://api" class="">http://api</a>;</div><div class=""> proxy_redirect <a href="http://api/" class="">http://api/</a> <a href="https://$host/" class="">https://$host/</a>;</div><div class=""> proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;</div><div class=""> proxy_set_header Connection "";</div><div class=""> }</div><div class=""> }</div><div class="">}</div><div class=""><br class=""></div><div class="">The backend is a simple node server.</div><div class=""><br class=""></div><div class="">the problem occurs randomly, and it happens for sure on <span style="font-family: Menlo; font-size: 11px; background-color: rgb(255, 255, 255);" class="">nginx/1.10.3 and </span><span style="font-family: Menlo; font-size: 11px; background-color: rgb(255, 255, 255);" class="">nginx/1.13.2 on debian/jessie</span></div><div class=""><br class=""></div><div class="">After some days of research, i found that if i remove the keepalive 100 from upstream configuration there is no longer the problem but i don't understand why ? Maybe somebody can explain me what could hapen ? maybe a misunderstanding about some configuration on keep alive ?</div><div class=""><br class=""></div><div class="">For me it seems to be a problem on nginx, if you can't explain with these information, i can send some debug (nginx-debug) log to you.</div><div class=""><br class=""></div><div class="">thanks in advance.</div></body></html>