第一种:轮询
upstream test{
server 192.168.0.1:3000;
server 192.168.0.1:3001;
}
第二种:权重
upstream test{
server 192.168.0.1 weight=2;
server 192.168.0.2 weight=3;
}
这种模式可解决服务器性能不等的情况下轮询比率的调配
第三种:ip_hash
upstream test{
ip_hash;
server 192.168.0.1;
server 192.168.0.2;
}
这种模式会根据来源IP和后端配置来做hash分配,确保固定IP只访问一个后端
第四种:fair
需要安装Upstream Fair Balancer Module
upstream test{
server 192.168.0.1;
server 192.168.0.2;
fair;
}
这种模式会根据后端服务的响应时间来分配,响应时间短的后端优先分配
第五种:自定义hash
需要安装Upstream Hash Module
upstream test{
server 192.168.0.1;
server 192.168.0.2;
hash $request_uri;
}
这种模式可以根据给定的字符串进行Hash分配
具体应用:
server{
listen 80;
server_name .test.com;
charset utf-8;
location / {
proxy_pass http://test/;
}
}
此外upstream每个后端的可设置参数为:
1.down: 表示此台server暂时不参与负载。
2.weight: 默认为1,weight越大,负载的权重就越大。
3.max_fails: 允许请求失败的次数默认为1.当超过最大次数时,返回proxy_next_upstream模块定义的错误。
4.fail_timeout: max_fails次失败后,暂停的时间。
5.backup: 其它所有的非backup机器down或者忙的时候,请求backup机器,应急措施。
转载:https://www.ttjoin.com/blog/index.php/archives/51
分享到:
相关推荐
官方nginx 镜像不带主动健康,本镜像将 nginx_upstream_check健康检查 打包到了镜像中。
nginx配置upstream的资源文件文件,下载下来直接上传至服务解压即可
此资源有两个文件,含 nginx-upstream-jvm-route 和 nginx 对应版本,都是tar.gz文件。 安装方法网上很多就不写了,亲测可用。 不用担心版本不匹配造成安装失败,再浪费积分去到处下载尝试的烦恼。 此资源有两个文件...
nginx-upstream-jvm-route 支持nginx版本1.15 解决nginx: [emerg] invalid parameter "srun_id=tomcat1" 问题
zabbix 主动检测nginx upstream servers 故障报警,无需安装python插件,开箱即用,支持python3和python2
nginx upstream fair算法 编译时加下面选项: --add-module=./nginx-upstream-fair make && make install
NGINX第三方模块:nginx_upstream_hash-0.3.1.tar.gz。
Nginx upstream urlhash url hash 反向代理 Nginx upstream urlhash url hash 反向代理
nginx.conf nginx-1.20.1.tar.gz 这是关于centos8的nginx 和nginx 的配置https文件
这是一个很小的脚本文件用来管理 Nginx 的 upstream 配置。 使用方法:upstream_manager.py <cluster> <action> [...]
Nginx upstream的5种权重分配方式分享,需要的朋友可以参考下
此文档详细介绍了Windows下Nginx的安装与配置,可以让用户在最短的时间内完全配置好nginx!
nginx1.16版本 后端节点健康检查、自动隔离+nginx_upstream_check_module-master+nginx-upload-module
NGINX第三方模块:nginx_upstream_hash-0.3.2,0.3.2版本。
Nginx-配置负载均衡的几种方式
Nginx反向代理服务器配置基础教程
Nginx所需环境的安装,及nginx安装,nginx相关功能开启,后端节点健康检查插件安装,静态资源缓存插件,缩略图插件安装等。
nginx_upstream_jvm_route 是一个 Nginx 的扩展模块,用来实现基于 Cookie 的 Session Sticky 的功能。 安装方法(进入Nginx源码目录): #patch -p0 # ./configure --prefix=/usr/nginx-0.8.1 --with-...
Nginx如何配置url_hash转发方式.docx