你的位置:首页 > 软件开发 > 操作系统 > ngx_http_upstream_module模块学习笔记

ngx_http_upstream_module模块学习笔记

发布时间:2016-04-22 17:00:12
ngx_http_upstream_module用于将多个服务器定义成服务器组,而由proxy_pass,fastcgi_pass等指令引用(1)upstream name {...} 定义一个后端服务器组,name为组名,只能用于http上下文中(2) server ad ...

ngx_http_upstream_module模块学习笔记

ngx_http_upstream_module用于将多个服务器定义成服务器组,而由proxy_pass,fastcgi_pass等指令引用

(1)upstream name  {...} 定义一个后端服务器组,name为组名,只能用于http上下文中

(2) server address [parametrs] 在upstream中定义一个服务器及其相关参数;仅能用于upstream上下文

 

ngx_http_upstream_module模块学习笔记

weight=number:定义服务器权重,默认为1

max_fails=number:最大失败连接尝试次数

fail_timeout=number:等待目标服务器发送响应的时长

proxy_pass http://backserver  反代至upstream中定义的组

其它指令不做介绍,前面的博文有详细说明

 

(3)ip_hash 源地址hash,把来自同一个ip地址的请求始终发往同一个backend server,除非此backend server不可用

ngx_http_upstream_module模块学习笔记

 

ngx_http_upstream_module模块学习笔记

如果web页面已经绑定了第一台server,而现在我在后面添加了down参数(手动标记其不再处理任何用户请求)则再次请求时会由第二台server发送响应

(4) least_conn 最少连接;当各server权重不同时,即为加权最少连接(算法:当前连接数/权重)

(5) health_check [parameters]; 健康状态检测机制;只能用于location上下文 (官方的nginx对后端服务器的健康状态检测不完善,但淘宝的tengine的完善了此功能)

 


原标题:ngx_http_upstream_module模块学习笔记

关键词:http

*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。