nginx 添加第三方nginx_upstream_check_module 模块实现健康状态检测 (2)

nginx 添加第三方nginx_upstream_check_module 模块实现健康状态检测

在使用GET方法时,请求的uri不宜过大。

Syntax: check_shm_size size Default: 1M Context: http

所有的后端服务器健康检查状态都存于共享内存中,该指令可以设置共享内存的大小。默认是1M,在配置的时候出现了错误,就可能需要扩大该内存的大小(后端服务较多的情况)。

Syntax: check_status [html|csv|json] Default: check_status html Context: location

后端服务器状态展示方式,默认html适合浏览器访问,如果需要使用第三方监控可以使用json方式。

$ vim xxx.conf ... location = /status { check_status json; ... } $ curl ?format=json {"servers": { "total": 2, "generation": 2, "server": [ {"index": 0, "upstream": "cluster", "name": "192.168.20.12:80", "status": "up", "rise": 202, "fall": 0, "type": "http", "port": 0}, {"index": 1, "upstream": "cluster", "name": "192.168.20.3:80", "status": "down", "rise": 0, "fall": 228, "type": "http", "port": 0} ] }} 注意事项

如果后端是基于域名访问,可使用check_http_send "GET /xxx HTTP/1.0\r\n HOST \r\n\r\n";方式在请求时添加请求头信息

总结

此模块已经很好的解决了健康状态检测功能,并提供自动恢复功能。

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/zzppzd.html