nginx_upstream_check_module icon indicating copy to clipboard operation
nginx_upstream_check_module copied to clipboard

该模块是不是不支持stream里面的tcp健康检测?

Open caiwilliam opened this issue 6 years ago • 4 comments

我使用的是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;
    }   
} 

caiwilliam avatar Oct 26 '18 09:10 caiwilliam

我和你错误一样,好像确实不支持

maochongtian avatar Apr 11 '19 08:04 maochongtian

我认为应该是不支持,之前也准备修改源代码,现在看到有这个现成的,我觉得只需要再此基础上,增加patch中的内容,将这部分检查也加到stream相关的代码中就可以了,目前patch中只是将检查的代码加到了http的代码中。

saliven1970 avatar Mar 03 '20 09:03 saliven1970

话说,当时我是看到了nginx的商业版本身就支持了这个检查,并且可以检查更多系统,就没再花更多力气改程序了。其实这个ngx_http_upstream_check_module.c源代码,也是早期nginx版本里面有的,只是后来免费版去掉了这个功能。

saliven1970 avatar Mar 03 '20 09:03 saliven1970

这个模块确实只支持http中upstream的检测。 我基于这个写了一个模块,同时支持http和stream的检测(对于stream同时增加了对UDP检查的支持)。 有需要的拿去: https://github.com/zhouchangxun/ngx_healthcheck_module/

zhouchangxun avatar Jun 13 '20 13:06 zhouchangxun