Reference documents
Nginx Upstream Module
Http://www.nginx.cn/doc/standard/httpupstream.html
#upstream模块: For load Balancing, reverse proxy (proxy fastcgi uwsgi scgi memcached)
#语法: Upstream name {...}
Upstream Static_server {
Server a*:80 max_fails=2 fail_timeout=5s;
Serve b*:80 max_fails=2 fail_timeout=5s;
Server c*:80 max_fails=2 fail_timeout=5s backup;
KeepAlive 4;
}
Groups of #定义了一个名为static_server
The ip+ of the #server + back-end server corresponds to the port number that provides the service
#max_fails: The number of failed requests defaults to 2, which returns the error defined by the Proxy_next_upstream module when the maximum number of times is exceeded
#fail_timeout: It is associated with max_fails, if the request fails within 5s 2 times, then Nginx thinks this server has been hung, so that no longer query it within 5s
#backup: Indicates that Nginx will distribute the request only when the backend server is unavailable
# KeepAlive 4: Activate a long connection to the backend machine, support HTTP fastcgi memcache, this number should be set to a small point so that the backend server can accept the new connection at the same time, if the number is exceeded, the least recently used connection will be closed.
#srun_id =pnet1: Indicates that a label is set on this server, primarily to differentiate back-end servers
#jvm_route: Based on Jsessionid in a cookie, determine which server the request is sent to the backend
#通过jvm_route解决session不一致的问题
Upstream Puic-net {
Server e*:39921 srun_id=pnet1 max_fails=2 fail_timeout=5s;
Server f*:10021 Srun_id=pnet2 max_fails=2 fail_timeout=5s;
Server g*:11021 srun_id=pnet3 max_fails=2 fail_timeout=5s;
Server h*:39922 srun_id=pnet4 max_fails=2 fail_timeout=5s;
Jvm_route $cookie _jsessionid|sessionid Reverse;
KeepAlive 4;
}
This article is from the It Dick thread blog, so be sure to keep this source http://68686789.blog.51cto.com/10438688/1750596
Nginx Upstream Module