Nginx ngx_http_upstream_module[原]
2012年01月08日
模块官方解释:
The ngx_http_upstream_module module allows to define groups of servers that can be referenced from the proxy_pass and fastcgi_pass directives. 
总结:该模块主要用作做负载均衡时使用
下面是一个配置例子:
upstream sv1 {
server 127.0.0.1 : 8080;
server 127.0.0.1 : 9999;
}
server {
listen 8888;
server_name localhost;
charset utf - 8;
location / {
index index.jsp index.html;
proxy_pass http: //sv1;
proxy_set_header Host $host;
proxy_set_header X - Real - IP $remote_addr;
proxy_set_header X - Forwarded - For $proxy_add_x_forwarded_for;
}
}
语法介绍:
(1)ip_hash:
官方解释:
Specifies that a group should use a balancing method where requestsare distributed between servers based on client IP addresses.A class C network containing the client IP address is used as a hashing key.The method ensures that requests of the same client will always bepassed to the same server except when this server is considered downin which case client requests will be passed to another server andmost probably it will also be the same server.
总结:每个request按访问ip的hash结果分配,这样每个request访问固定一个后端服务器,可以解决session同步的问题,但是存在单点问题。
配置例子:
upstream backend {
ip_hash;
server backend1.example.com;
server backend2.example.com;
server backend3.example.com down;
server backend4.example.com;
}
上面加粗down的意思,标示该server已经宕机,这样请求就不会pass过去。这种适用于在生产线上临时移除某台已经宕机的server。要注意如果采用ip散列的方式做负载均衡,那么权重属性(weight--下面做解释)就不起作用了。
(2)server name [parameters]:
官方解释:
Sets a name and other parameters of the server.A name can be a domain name, an address, a port, or apath of the UNIX-domain socket.If a domain name resolves to several addresses, all of them are used.
总结:设置服务名称,一般为域名或者ip地址,取决于你的负载架构。
其他可选参数:
1.down :当前的server不参与负载。
2.weight :值越大,负载的权重就越大。 默认为1。
3.max_fails :允许请求失败的次数,默认为1.
4.fail_timeout:请求server超时时间,默认为10秒。
5.backup:备份机器,当主服务器宕机,该备份机开始工作。
配置实例:
upstream backend {
server backend1.example.com weight=5;
server 127.0.0.1:8080 max_fails=3 fail_timeout=30s;
server unix:/tmp/backend3;
server backup1.example.com:8080 backup;
}
注意,设置了max_fails,当失败次数超过最大次数时,返回proxy_next_upstream和fastcgi_next_upstream模块定义的错误。404状态除外。

发表评论
-
Android模拟器上网问题
2012-01-20 02:05 585Android模拟器上网问题 2011年04月15日 I ... -
ERROR: the user data image is used by another emulator. aborting
2012-01-20 02:05 484ERROR: the user data image is u ... -
Eclipse插件之Java代码分析工具: FindBugs
2012-01-20 02:05 590Eclipse插件之Java代码分析工具: FindBugs ... -
模拟器里卸载应用程序的方法
2012-01-20 02:05 754模拟器里卸载应用程序的方法 2011年06月21日 我们 ... -
MFC架构之CWinThread类
2012-01-20 02:05 636MFC架构之CWinThread类 2010 ... -
XP优化大全(1)
2012-01-19 09:55 571XP优化大全(1) 2010年07月20日 1.减少 ... -
电脑技术
2012-01-19 09:55 582电脑技术 2011年04月20日 1、加快XP开机及 ... -
诺基亚5530使用技巧整理
2012-01-19 09:55 466诺基亚5530使用技巧整理 2010年11月28日 ◆快 ... -
Android程序结构解析
2012-01-19 09:55 691Android程序结构解析 2010 ... -
我几时先可以真正征服你啊 钻石Touch Diamond
2012-01-19 09:55 600我几时先可以真正征服你啊 钻石Touch Diamond 2 ... -
Qt phonon多媒体框架 基于播放器
2012-01-17 02:26 714Qt phonon多媒体框架 基于 ... -
写给那些想买手机,准备换手机的朋友,教你购买合适的手机
2012-01-17 02:26 566写给那些想买手机,准备 ... -
调用规范与可变参数表
2012-01-17 02:26 544调用规范与可变参数表 ... -
使用命令行管理IIS(6.0)
2012-01-17 02:26 491使用命令行管理IIS(6.0) 2011年12月06日 ... -
TI AM335x 应用处理器:无限可能
2012-01-17 02:26 1337TI AM335x 应用处理器:无 ... -
大家帮看看这个电脑多少钱 2手的 卖家1500 1年拉 2011-12-24
2012-01-15 22:05 569大家帮看看这个电脑多少钱 2手的 卖家1500 1年拉 ... -
电脑型号 索尼 VAIO VPCYA15EC 笔记本电脑
2012-01-15 22:05 680电脑型号 索尼 VAIO VPCYA15EC 笔记本电脑 2 ... -
HTTPS和HTTP的区别
2012-01-15 22:05 795HTTPS和HTTP的区别 2011年1 ... -
出售因特双核2.2gCPU,4G内存独显本子 - 2500元
2012-01-15 22:04 16出售因特双核2.2gCPU,4G内存独显本子 - 2500元 ...
相关推荐
lua-upstream-nginx-module, Nginx C 模块将Lua向ngx_lua公开,用于 Nginx upstreams 电子邮件名称ngx_http_lua_upstream - Nginx MODULE,用于向 Nginx upstreams公开Lua到 ngx_lua目录NAME状态概要说明函数get_...
ngx_dynamic_upstream ngx_dynamic_upstream是用于使用等HTTP API动态地操作上游的模块。要求ngx_dynamic_upstream在upstream上下文中需要zone指令。 该指令在nginx-1.9.0-plus中可用。地位生产准备就绪。指令...
、limit_conn_module、ngx_http_limit_req_module、ngx_http_access_module、ngx_http_auth_basic_module、ngx_http_fastcgi_module、ngx_http_gzip_module、ngx_http_proxy_module、ngx_http_upstream_module、ngx_...
nginx自带是没有针对负载均衡后端节点的健康检查的,但是可以通过默认自带的ngx_http_proxy_module 模块和ngx_http_upstream_module模块中的相关指令来完成当后端节点出现故障时,自动切换到健康节点来提供访问。
nginx的iphash改成按照ip轮询
ngx_lua_upstream headers-more-nginx-module rds-json-nginx-module nginx-http-concat-module redis2-nginx-module and these C module for Lua: 以及这些用于 Lua 的 C 模块: lua-cjson lua-redis-parser lua-...
./configure --prefix=/usr/local/nginx-1.6.0 --add-module=../nginx-sticky-module-1.25 --without-http_ssi_module --without-http_autoindex_module --without-http_fastcgi_module --with-...
此模块可用于更新您的上游列表,而无需重新加载Nginx。 目录 变更记录 版本V0.2.9 版本V0.2.8 版本V0.2.7 版本V0.2.6 版本V0.2.5 版本V0.2.4 版本V0.2.2 发行版V0.2.0 兼容性 Tengine相容性 模块兼容性 运行...
ngx_http_lua_upstream-Nginx C模块将Lua API公开给Nginx上游的ngx_lua 目录 状态 该模块已准备就绪。 概要 http { upstream foo.com { server 127.0.0.1 fail_timeout=53 weight=4 max_fails=100; server ...
./configure --with-ld-opt=-Wl,-rpath,/usr/local/lib --add-module=lua-nginx-module --add-module=lua-upstream-nginx-module --add-module=ngx_devel_kit 像这样配置您的nginx: upstream google { server ...
集成了第三方包: nginx_upstream_check_module 主动后端检查, ngx_http_substitutions_filter 内容替换, set-misc-nginx-module-0.33 url 中解码,ngx_devel_kit-0.3.2 misc 依赖
严格来说,nginx自带是没有针对负载均衡后端节点的健康检查的,但是可以通过默认自带的ngx_http_proxy_module模块和ngx_http_upstream_module模块中的相关指令来完成当后端节点出现故障时,自动切换到健康节点来提供...
nginx1.12适配的 lua 模块 ngx_dynamic_upstream 模块 ngx_http_dyups_module
姓名ngx_rds_json-将ngx_drizzle等生成的Resty DBD流格式化为JSON的输出过滤器目录状态该模块被认为可以投入生产。 我们需要你的帮助! 如果您发现此模块有用和/或有趣,请考虑加入开发! 提交位可以根据您的要求...
DrizzleNginxModule 是一个 Nginx upstream 模块用来跟 MySQL 和 Drizzle 数据库服务器进行通讯,使用 libdrizzle 开发。...该模块 (ngx_drizzle) 模块默认不启用,你可通过 --with-http_drizzle_module 参数来启用。
nginx 的负载均衡功能依赖于 ngx_http_upstream_module模块,所支持的代理方式有 proxy_pass(一般用于反向代理),fastcgi_pass(一般用于和动态程序交互),memcached_pass,proxy_next_upstream,fastcgi_next_pass,...
nginx-upsync-module Nginx C模块,可以同步Consul或其他模块的上游。 它动态地修改了后端服务器的属性(weight,max_fails等),而无需重新加载NGINX。 修改配置文件并重新启动NGINX可能并不总是很方便。 例如,...
nginx-1.11.3.tar.gz,echo-nginx-module-0.59.tar.gz,ngx_cache_purge-2.3.tar.gz,nginx_upstream-fair-a18b409.tar.gz,keepalived