nginx学习(八)——nginx的配置系统4之healthcheck module
来源:互联网 发布:公司审批软件 编辑:程序博客网 时间:2024/06/08 02:49
ngx_http_healthcheck_module
参考自:nginx负载集群解决方案
1.upstream模块
upstream provider { server 192.168.237.186:10086; healthcheck_enabled; healthcheck_delay 10000; healthcheck_timeout 1000; healthcheck_failcount 2; healthcheck_send 'GET /test HTTP/1.0' 'Host: xxcupid1.qunar.com' 'Connection: close'; }healthcheck_enabled ##启用此模块
healthcheck_delay ##对同一台后端服务器两次检测之间的时间间隔,单位毫秒,默认为1000;
healthcheck_timeout ##进行一次健康检测的超时时间,单位为毫秒,默认值2000;
healthcheck_failcount ##对一台后端服务器检测成功或失败多少次之后方才确定其为成功或失败,并实现启用或禁用此服务器;
healthcheck_send ##为了检测后端服务器的健康状态所发送的检测请求;如:healthcheck_send "GET /health HTTP/1.0" 'Host: coolinuz.9966.org';
healthcheck_expected ##期望从后端服务器收到的响应内容;如果未设置,则表示从后端服务器收到200状态码即为正确;
healthcheck_buffer ##健康状态检查所使用的buffer空间大小;
healthcheck_status
通过类似stub_status的方式输出检测信息,使用方法如下:
location /stat {
healthcheck_status;
}
如果healthcheck_send配置的地址无法访问,nginx的error日志中会打印如下内容:
2016/09/12 15:48:06 [info] 5831#0: check protocol qunar_http error with peer: 192.168.237.186:10086
如果能正常访问的话
2016/09/12 15:51:02 [info] 6974#0: enable check peer: 192.168.237.186:10086
nginx关闭启动日志:
2016/09/12 15:50:39 [error] 5831#0: ngx_exiting...
2016/09/12 15:50:39 [error] 5831#0: Pending timer: 1616 handler addr: (4bc6d7)
2016/09/12 15:50:41 [notice] 5831#0: clear all the events on 5831
2016/09/12 15:50:41 [error] 5831#0: ngx_exiting...
2016/09/12 15:50:41 [error] 5831#0: Pending timer: -1 handler addr: (0)
2016/09/12 15:50:41 [notice] 5831#0: exiting
2016/09/12 15:50:41 [notice] 5831#0: exit
2016/09/12 15:50:41 [notice] 18102#0: signal 17 (SIGCHLD) received
2016/09/12 15:50:41 [notice] 18102#0: worker process 5831 exited with code 0
2016/09/12 15:50:41 [notice] 18102#0: signal 29 (SIGIO) received
2.server location模块
location /name { #proxy_pass http://provider; proxy_pass http://192.168.237.186:10086/; proxy_set_header Host $host; proxy_set_header X-Real-Scheme $scheme; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; }http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_set_header
proxy_set_header Host $proxy_host;proxy_set_header Connection close;If caching is enabled, the header fields “If-Modified-Since”, “If-Unmodified-Since”, “If-None-Match”, “If-Match”, “Range”, and “If-Range” from the original request are not passed to the proxied server.
proxy_set_header Host $http_host;However, if this field is not present in a client request header then nothing will be passed. In such a case it is better to use the $host variable - its value equals the server name in the “Host” request header field or the primary server name if this field is not present:
proxy_set_header Host $host;In addition, the server name can be passed together with the port of the proxied server:
proxy_set_header Host $host:$proxy_port;If the value of a header field is an empty string then this field will not be passed to a proxied server:
proxy_set_header Accept-Encoding "";
3.http request header
- nginx学习(八)——nginx的配置系统4之healthcheck module
- nginx学习(六)——nginx的配置系统3之upstream_module(上)
- nginx学习(七)——nginx的配置系统3之upstream_module(下)
- nginx学习(九)——nginx的配置系统5之rewrite
- nginx学习(十)——nginx的配置系统6之server_name
- nginx学习(十一)——nginx的配置系统7之if
- nginx学习(十四)——lua-nginx-module
- nginx学习(五)——nginx的配置系统1
- nginx学习(五)——nginx的配置系统2
- Nginx学习总结(3)——Nginx配置及应用场景之高级配置
- Nginx学习——Nginx基本配置
- Nginx学习笔记1—Nginx(Win32) 配置详解
- Nginx学习笔记1—Nginx(Win32) 配置详解
- nginx的配置系统
- nginx的配置系统
- nginx反向代理配置----nginx的学习之路
- nginx负载均衡配置---nginx的学习之路
- Nginx源码分析—nginx的配置
- NetBeans启动失败,提示“JVM creation failed”的解决办法
- html运用(四) html解决浏览器记住密码输入框的问题
- vimrc 配置参考
- Python编码错误的解决办法SyntaxError: Non-ASCII character '\xe5' in file
- 浏览器加载网页的顺序和优化
- nginx学习(八)——nginx的配置系统4之healthcheck module
- Java 静态语句块、语句块、构造函数
- Camera 硬件结构介绍
- SAP中事务代码ME2N中引出的表格里,仍要Invoice数量是什么含义?
- maven install Failed to execute goal org.apache.maven.plugins:maven-war-plugin:2.1.1:war (default-wa
- 一个企业it的触云感受:多台电脑测试程序的烦恼将不会再来
- ios developer tiny share-20160912
- 图像特征之SIFT
- android轻量级缓存框架ASimpleCache分析