nginx_upstream_check_module
nginx_upstream_check_module copied to clipboard
该模块是不是不支持stream里面的tcp健康检测?
我使用的是Nginx 1.14版本,打了check_1.14.0+.patch这个patch,编译也没问题,但在stream配置里面按照类似下面的配置做测试的时候,nginx启动的会提示 nginx: [emerg] "check" directive is not allowed here in /usr/local/nginx/conf/tcp_proxy.conf 如果check放在http配置项里面又不会报错,是我的配置有问题吗,还是本身就不支持?
stream { upstream cluster { # simple round-robin server 10.2.100.101:10001; server 10.2.100.101:10002; check interval=3000 rise=2 fall=5 timeout=1000 type=tcp; }
server {
listen 10000;
proxy_pass cluster;
}
}
我和你错误一样,好像确实不支持
我认为应该是不支持,之前也准备修改源代码,现在看到有这个现成的,我觉得只需要再此基础上,增加patch中的内容,将这部分检查也加到stream相关的代码中就可以了,目前patch中只是将检查的代码加到了http的代码中。
话说,当时我是看到了nginx的商业版本身就支持了这个检查,并且可以检查更多系统,就没再花更多力气改程序了。其实这个ngx_http_upstream_check_module.c源代码,也是早期nginx版本里面有的,只是后来免费版去掉了这个功能。
这个模块确实只支持http中upstream的检测。 我基于这个写了一个模块,同时支持http和stream的检测(对于stream同时增加了对UDP检查的支持)。 有需要的拿去: https://github.com/zhouchangxun/ngx_healthcheck_module/