# Healthcheck do not working

**URL:** <https://www.ruby-forum.com/t/healthcheck-do-not-working/205774>\
**Category:** NGINX\
**Created:** [April 15, 2011, 10:26am UTC](https://www.ruby-forum.com/t/healthcheck-do-not-working/205774 "2011-04-15T10:26:01Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![luislavena](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/0ea827/32.png) [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Post date:** [April 15, 2011, 10:26am UTC](https://www.ruby-forum.com/t/healthcheck-do-not-working/205774/1 "2011-04-15T10:26:01Z")

</div>

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:

> **[healthcheck do not working](https://forum.nginx.org/read.php?2,191445,191445#msg-191445)**
>
> 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...

---

<div class="post-metadata">

**Author:** ![stone](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c89c15/32.png) [@stone](https://www.ruby-forum.com/u/stone)\
**Post date:** [July 29, 2011, 11:17am UTC](https://www.ruby-forum.com/t/healthcheck-do-not-working/205774/2 "2011-07-29T11:17:47Z")

</div>

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:  
[http://forum.nginx.org/read.php?2,191445,213076#msg-213076](http://forum.nginx.org/read.php?2,191445,213076#msg-213076)

---

<div class="post-metadata">

**Author:** ![stone](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c89c15/32.png) [@stone](https://www.ruby-forum.com/u/stone)\
**Post date:** [July 29, 2011, 3:51pm UTC](https://www.ruby-forum.com/t/healthcheck-do-not-working/205774/3 "2011-07-29T15:51:48Z")

</div>

> 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:  
[http://forum.nginx.org/read.php?2,191445,213096#msg-213096](http://forum.nginx.org/read.php?2,191445,213096#msg-213096)

---

<div class="post-metadata">

**Author:** ![stone](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c89c15/32.png) [@stone](https://www.ruby-forum.com/u/stone)\
**Post date:** [July 29, 2011, 4:04pm UTC](https://www.ruby-forum.com/t/healthcheck-do-not-working/205774/4 "2011-07-29T16:04:48Z")

</div>

Hi,

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

> **[GitHub - cep21/nginx\_upstream\_hash at support\_http\_healthchecks](https://github.com/cep21/nginx_upstream_hash/tree/support_http_healthchecks)**
>
> support\_http\_healthchecks

liseen

---

<div class="post-metadata">

**Author:** ![stone](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c89c15/32.png) [@stone](https://www.ruby-forum.com/u/stone)\
**Post date:** [August 1, 2011, 1:16pm UTC](https://www.ruby-forum.com/t/healthcheck-do-not-working/205774/5 "2011-08-01T13:16:08Z")

</div>

> Hi,  
> You should compile upstream hash module which cep12 patched, See:  
> [GitHub - cep21/nginx\_upstream\_hash at support\_http\_healthchecks · GitHub](https://github.com/cep21/nginx_upstream_hash/tree/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:  
[http://forum.nginx.org/read.php?2,191445,213176#msg-213176](http://forum.nginx.org/read.php?2,191445,213176#msg-213176)

---

<div class="post-metadata">

**Author:** ![stone](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c89c15/32.png) [@stone](https://www.ruby-forum.com/u/stone)\
**Post date:** [August 2, 2011, 3:53pm UTC](https://www.ruby-forum.com/t/healthcheck-do-not-working/205774/6 "2011-08-02T15:53:30Z")

</div>

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.
