Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

nginx close upstream connection after request

Tags:

http

nginx

I need to keep alive my connection between nginx and upstream nodejs.

Just compiled and installed nginx 1.2.0

my configuration file:

upstream backend {     ip_hash;     server dev:3001;     server dev:3002;     server dev:3003;     server dev:3004;     keepalive 128; }  server {     listen      9000;     server_name dev;      location / {         proxy_pass http://backend;         error_page  404 = 404.png;     } } 

My programe (dev:3001 - 3004) detect that the connection was closed by nginx after response.

document

like image 727
guilin 桂林 Avatar asked May 01 '12 09:05

guilin 桂林


People also ask

How does NGINX resolve upstream?

Upstream Domain Resolve¶ Its buffer has the latest IPs of the backend domain name and it integrates with the configured load balancing algorithm (least_conn, hash, etc) or the built in round robin if none is explicitly defined. At every interval (one second by default), it resolves the domain name.

What is keepalive in NGINX?

In Nginx, keepalive is a directive that is utilized for keeping the connection open for a certain number of requests to the server or until the request timeout period has expired.

What is Fail_timeout in NGINX?

fail_timeout = time sets. the time during which the specified number of unsuccessful attempts to communicate with the server should happen to consider the server unavailable; and the period of time the server will be considered unavailable.

What is Ip_hash NGINX?

With ip-hash, the client's IP address is used as a hashing key to determine what server in a server group should be selected for the client's requests. This method ensures that the requests from the same client will always be directed to the same server except when this server is unavailable.


1 Answers

The documentation states that for http keepalive, you should also set proxy_http_version 1.1; and proxy_set_header Connection "";

like image 131
kolbyjack Avatar answered Oct 02 '22 11:10

kolbyjack