1、前提
- nginx已经编译集成Lj2.1
- nginx已经编译集成nginx_upstream_check_module
- 多台nginx转发终端服务只能tcp探活,上游服务需要URL探活
2、4层upstream探活配置--nginx-B
upstream lama.member { server 127.0.0.1:8081 max_fails=3 fail_timeout=30s; server 127.0.0.2:8081 max_fails=3 fail_timeout=30s; server 127.0.0.3:8081 max_fails=3 fail_timeout=30s; check interval=2000 rise=3 fall=5 timeout=2000 type=tcp default_down=false; }
3、nginx_upstream_check_module模块接口--nginx-B
location /check_status { check_status; access_log off; }
4、lua脚本检测列表--nginx-B
listen 8088; location /tcpserver { content_by_lua_block { local res=ngx.location.capture("/check_status?format=csv&status=up") for val in string.gmatch(res.body,"[^%c]+") do if string.match(val,'127.0.0.[12]:8081') then ngx.say(val) ngx.status=ngx.HTTP_OK ngx.exit(200) end end ngx.status=ngx.HTTP_NOT_FOUND ngx.say('Error fond') } }
upstream lama.member { server 127.0.0.5:8088 max_fails=3 fail_timeout=30s; server 127.0.0.4:8088 max_fails=3 fail_timeout=30s; check interval=2000 rise=3 fall=5 timeout=2000 type=tcp default_down=false; check_http_send "HEAD /tcpserver HTTP/1.0rnrn"; check_http_expect_alive http_2xx http_3xx; }
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)