Healthcheck do not working

I tried to use the latest stable: nginx/1.0.0
I installed both this healthcheck_nginx_upstream and cep21 /
nginx_upstream_hash. Both patches

succeeded.

The configure looked good:
./configure --add-module=/tmp/cep21-healthcheck_nginx_upstreams-5fa4bff/
–with-

http_stub_status_module --with-http_ssl_module
–prefix=/usr/local/nginx/
make && make install

finish it,no error and warning.

I used the sample nginx configs and have this:

upstream main_servers {
server 192.168.0.242:8080;
server 192.168.0.246:8090;

hash $request_uri;

hash_again 0;

healthcheck_enabled;
healthcheck_delay 200;
healthcheck_timeout 200;
healthcheck_failcount 1;
healthcheck_expected 'I_AM_ALIVE';
healthcheck_buffer 32;
healthcheck_send "GET /health HTTP/1.1" 'Host: $http_host';
}


#
# The default server
#
server {
    listen       81;
    server_name  _;

    #charset koi8-r;

    #access_log  logs/host.access.log  main;

    proxy_set_header Host $http_host;

    #rewrite ^/destroute$ /destRoute/destrote.do;


    location / {
        proxy_pass   http://main_servers;
        proxy_next_upstream timeout invalid_header;
        proxy_set_header Host $http_host;
        proxy_set_header X-Forwarded-For $remote_addr;
    }

include /etc/nginx/conf.d/*.conf;

}
}

Q1:I can’t use module hash.when I use it,tell me: nginx: [emerg]
unknown directive “hash” in

/usr/local/nginx/conf/nginx.conf:65
So I delete it

There is no error report during executing.

Q2;
In my opinion, when the “tomcat of host_192.168.0.242” hasn’t totally
started, healthcheck regards it as unvailable and transfers the visit
link directly to “host_192.168.0.246”.
It comes back after “host_192.168.0.242” has totally started.

But during the course of restart, there was no evidence showing that
healthcheck is working.

Does it happen beacause of my wrong setting or my lack of
understanding?

Looking forward for your help. Thank you for your help in advance.

Best regards!
Stone

Posted at Nginx Forum:

Good day! I have same problem with nginx-1.0.5 (and nginx-1.0.0)

root@true:/tmp/nginx-1.0.5# ./configure
–add-module=/tmp/nginx_upstream_hash-0.3.1/
–add-module=/tmp/healthcheck_nginx_upstreams/ --with-debug

error_log logs/error_log debug_http;

upstream backend {
    ip_hash;
    server 172.16.0.130:81;
    server 172.16.0.130:82;
    server 172.16.0.130:22;

hash $remote_addr;

hash_again 0;

    healthcheck_enabled;
    healthcheck_delay 5000;
    healthcheck_timeout 1500;
    healthcheck_failcount 1;
    healthcheck_send "GET /PingAction.do HTTP/1.0" 'Host: ivis0';
}

2011/07/29 12:15:54 [debug] 26735#0: healthcheck: begun healthcheck of
index 2
2011/07/29 12:15:54 [debug] 26735#0: healthcheck: Memzero done
2011/07/29 12:15:54 [debug] 26735#0: healthcheck: Connecting peer
2011/07/29 12:15:54 [debug] 26735#0: healthcheck: connected so far
2011/07/29 12:15:54 [debug] 26735#0: healthcheck: Peer connected
2011/07/29 12:15:54 [debug] 26735#0: healthcheck: Send size 44
2011/07/29 12:15:54 [debug] 26735#0: healthcheck: Finished sending
request
2011/07/29 12:15:54 [debug] 26735#0: healthcheck: Write handler called
2011/07/29 12:15:54 [debug] 26735#0: healthcheck: Ignoring a write. Not
in writing state
2011/07/29 12:15:54 [debug] 26735#0: healthcheck: Read handler called
2011/07/29 12:15:54 [debug] 26735#0: healthcheck: Recv size 39 when I
wanted 6442450945000
2011/07/29 12:15:54 [debug] 26735#0: healthcheck: Recv size -2 when I
wanted 6442450944961
2011/07/29 12:15:54 [debug] 26735#0: healthcheck: Process recv
2011/07/29 12:15:54 [debug] 26735#0: healthcheck: Finished
172.16.0.130:22, state 201
2011/07/29 12:15:54 [debug] 26733#0: healthcheck: begun healthcheck of
index 0
2011/07/29 12:15:54 [debug] 26733#0: healthcheck: Memzero done
2011/07/29 12:15:54 [debug] 26733#0: healthcheck: Connecting peer
2011/07/29 12:15:54 [debug] 26733#0: healthcheck: connected so far
2011/07/29 12:15:54 [debug] 26733#0: healthcheck: Peer connected
2011/07/29 12:15:54 [debug] 26733#0: healthcheck: Send size 44
2011/07/29 12:15:54 [debug] 26733#0: healthcheck: Finished sending
request
2011/07/29 12:15:54 [debug] 26733#0: healthcheck: Write handler called
2011/07/29 12:15:54 [debug] 26733#0: healthcheck: Ignoring a write. Not
in writing state
2011/07/29 12:15:54 [debug] 26733#0: healthcheck: Write handler called
2011/07/29 12:15:54 [debug] 26733#0: healthcheck: Ignoring a write. Not
in writing state
2011/07/29 12:15:54 [debug] 26733#0: healthcheck: Read handler called
2011/07/29 12:15:54 [debug] 26733#0: healthcheck: Recv size 211 when I
wanted 4398046512104
2011/07/29 12:15:54 [debug] 26733#0: healthcheck: Recv size -2 when I
wanted 4398046511893
2011/07/29 12:15:54 [debug] 26733#0: healthcheck: Process recv
2011/07/29 12:15:54 [debug] 26733#0: healthcheck: Finished
172.16.0.130:81, state 100
2011/07/29 12:15:57 [debug] 26735#0: healthcheck: begun healthcheck of
index 1
2011/07/29 12:15:57 [debug] 26735#0: healthcheck: Memzero done
2011/07/29 12:15:57 [debug] 26735#0: healthcheck: Connecting peer
2011/07/29 12:15:57 [debug] 26735#0: healthcheck: connected so far
2011/07/29 12:15:57 [debug] 26735#0: healthcheck: Peer connected
2011/07/29 12:15:57 [debug] 26735#0: healthcheck: Send size 44
2011/07/29 12:15:57 [debug] 26735#0: healthcheck: Finished sending
request
2011/07/29 12:15:57 [debug] 26735#0: healthcheck: Write handler called
2011/07/29 12:15:57 [debug] 26735#0: healthcheck: Ignoring a write. Not
in writing state
2011/07/29 12:15:57 [debug] 26735#0: healthcheck: Read handler called
2011/07/29 12:15:57 [debug] 26735#0: healthcheck: Recv size 211 when I
wanted 6442450945000
2011/07/29 12:15:57 [debug] 26735#0: healthcheck: Recv size -2 when I
wanted 6442450944789
2011/07/29 12:15:57 [debug] 26735#0: healthcheck: Process recv
2011/07/29 12:15:57 [debug] 26735#0: healthcheck: Finished
172.16.0.130:82, state 100

Where 81 and 82 tcp-ports is a tomcat, who answer “HTTP/1.1 200 OK\r\n”
with some fields and close connection.
And 22 is a localhost ssh server, who simply close tcp socket without
answer if nginx send “GET /PingAction.do HTTP/1.0\r\n”

As i see in ngx_http_healthcheck_module.c
“state 100” is a NGX_HEALTH_OK ( // Good + final states)
“state 201” is a NGX_HEALTH_BAD_STATUS (// bad + final states)

But in my case all inversely - :81 and :82 are good - they answer
“HTTP/1.1 200 OK\r\n”
and 22 is bad - he close connection without answer

Posted at Nginx Forum:

But in my case all inversely - :81 and :82 are good - they answer
“HTTP/1.1 200 OK\r\n”
and 22 is bad - he close connection without answer

Sorry, in states all right - this paragraph used mistakenly

But nginx NOT mark 172.16.0.130:22 as wrong server and unsuccessfully
trying to redirect browser request to 22 tcp-port

Posted at Nginx Forum:

Hi,

You should compile upstream hash module which cep12 patched, See:

liseen

Hi,
You should compile upstream hash module which cep12 patched, See:
GitHub - cep21/nginx_upstream_hash at support_http_healthchecks

nginx-1.0.5 was compiled with both patches:

root@true:/tmp/nginx-1.0.5# patch -p0 <
…/nginx_upstream_hash-0.3.1/nginx.patch
patching file src/http/ngx_http_upstream.h
Hunk #1 succeeded at 106 (offset 1 line).

root@true:/tmp/nginx-1.0.5# patch -p1 <
…/healthcheck_nginx_upstreams/nginx.patch
patching file src/http/ngx_http_upstream.c
patching file src/http/ngx_http_upstream.h
Hunk #1 succeeded at 110 with fuzz 2 (offset 4 lines).
patching file src/http/ngx_http_upstream_round_robin.c
patching file src/http/ngx_http_upstream_round_robin.h

root@true:/tmp/nginx-1.0.5# ./configure
–add-module=/tmp/nginx_upstream_hash-0.3.1/
–add-module=/tmp/healthcheck_nginx_upstreams/ --with-debug
root@true:/tmp/nginx-1.0.5# make -j5 && make install

But if I use “hash” options, error.log is empty after nginx reload, even
if I use “server” option, which indicates to closed port.

error_log /usr/local/nginx/logs/error.log;
upstream backend {
#ip_hash;
server 172.16.0.130:181;
server 172.16.0.130:182;
server 172.16.0.130:122;
hash $remote_addr;
hash_again 0;
healthcheck_enabled;
healthcheck_delay 5000;
healthcheck_timeout 1500;
healthcheck_failcount 1;
healthcheck_send “GET /PingAction.do HTTP/1.0” ‘Host: ivis0’;
}

Posted at Nginx Forum:

Please check you nginx_upstream_hash with this command,

grep HEALTHCHECK ngx_http_upstream_hash_module.c
#if (NGX_HTTP_HEALTHCHECK)
#if (NGX_HTTP_HEALTHCHECK)
#if (NGX_HTTP_HEALTHCHECK)
#if (NGX_HTTP_HEALTHCHECK)
#if (NGX_HTTP_HEALTHCHECK)
#if (NGX_HTTP_HEALTHCHECK)

if you have compiled with right hash module, Health check should be
worked.
I have used this module for 2 months.