Nginx中ip_hash负载均衡中location的proxy_pass配置与说明
来源:互联网 发布:银行家算法例题 编辑:程序博客网 时间:2024/05/21 19:49
Nginx可以根据客户端IP进行负载均衡,在upstream里设置ip_hash,就可以针对同一个地址段中的客户端选择同一个后端服务器,除非那个后端服务器宕机了才会换一个。
1
2
3
4
5
6
7
upstream tomcatserver {#定义负载均衡 设备的Ip及设备状态
ip_hash;
server :
8080
down;
server :
8888
weight=
2
;
server :
9999
;
server :
7777
backup;
}
在需要使用负载均衡的server中增加
1
2
3
4
5
6
7
8
9
10
11
12
13
14
server {
listen
80
;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
proxy_pass http:
//tomcatserver;
}
# 转发jsp servlet 或springmvc请求
#
location ~ (\.jsp)|(\.
do
)|(\.action)$ {
proxy_pass http:
//tomcatserver;
}
}
每个设备的状态设置为:
1.down 表示单前的server暂时不参与负载
2.weight 默认为1,weight越大,负载的权重就越大。
3.max_fails :允许请求失败的次数默认为1.当超过最大次数时,返回proxy_next_upstream 模块定义的错误
4.fail_timeout:max_fails次失败后,暂停的时间。
5.backup: 其它所有的非backup机器down或者忙的时候,请求backup机器。所以这台机器压力会最轻。
0 0
- Nginx中ip_hash负载均衡中location的proxy_pass配置与说明
- Nginx中ip_hash负载均衡中location的proxy_pass配置与说明
- nginx负载均衡中RR和ip_hash策略分析
- nginx负载均衡中RR和ip_hash策略分析
- nginx负载均衡中RR和ip_hash策略分析
- Nginx的负载均衡 - 保持会话 (ip_hash)
- nginx中location中关于proxy_pass和rewrite的应用
- nginx中location配置说明
- Nginx在局域网中使用ip_hash负载均衡策略,访问全部分发到同一个后台服务器
- Nginx在局域网中使用ip_hash负载均衡策略,访问全部分发到同一个后台服务器
- nginx负载均衡基于ip_hash的session粘帖
- nginx负载均衡基于ip_hash的session粘帖
- nginx负载均衡基于ip_hash的session粘帖
- nginx负载均衡配置说明
- Nginx负载均衡配置说明
- nginx中,ip_hash和url_hash的区别
- nginx中,ip_hash和url_hash的区别
- nginx负载均衡的4中配置策略
- Python 学习之路(二)
- linux相关知识
- SICP 习题 (2.23)解题总结:for-each的实现
- APPCAN学习笔记003---原生开发与HTML5技术
- Mac下安装Canvas(还未成功,望高手指点)
- Nginx中ip_hash负载均衡中location的proxy_pass配置与说明
- linux shell substr(分割字符串)
- [Unity3D]Unity3D游戏开发之Lua与游戏的不解之缘(中)
- SICP 习题 (2.24)解题总结:列表的结构
- 在WPF中使用谷歌地图和高德地图
- 注册表操作
- 第十八章 18.1.1节练习
- 【iOS XMPP】使用XMPPFramewok(二):用户登录
- SICP 习题 (2.25)解题总结:列表的操作