An issue with health checker lua library when using incorrect http_req URL

112 views
Skip to first unread message

divya mp

unread,
Apr 4, 2017, 7:55:42 PM4/4/17
to openresty-en
Team

I have implemented the lua_resty_upstream_healthcheck library into our NGINX 1.11.10 build to check the status of our webservices running in the backend. We are using NGINX as only reverse proxy.

We have run into issue with this library. The document on the GIT says the spawnchecker() function does not need http traffic. It used all the upstream configured and used the http_req configured to check if the upstream server is up or now.

Since it is a webservice we are checking i configured the http_req to the get the WSDL. Now what is breaking for us is if the http_req is configured incorrectly i was expecting only the upstream to get impacted and the status page will indicate the upstream is down. But the issue is even the actual client traffic is getting impacted. Clients who are trying to access the WSDL also get errors.

Can someone please explain if this is expected behaviour? 

My sample configuration for health check looks like this

lua_shared_dict healthcheck 1m;

lua_socket_log_errors off;

init_worker_by_lua_block {
        local hc = require "resty.upstream.healthcheck"
        local upstream = require "ngx.upstream"
        local us = upstream.get_upstreams()
 for _, u in ipairs(us) do
    local upstreamvalue = u
              local ok, err = hc.spawn_checker{
                shm = "healthcheck",  -- defined by "lua_shared_dict"
                upstream = upstreamvalue, -- defined by "upstream"
                type = "http",

                http_req = "GET /WebServices/"..upstreamvalue..".serviceagent?wsdl HTTP/1.1\r\nHost: "..upstreamvalue.."\r\n\r\n",
                    -- raw HTTP request for checking

                interval = 4000,  -- run the check cycle every 2 sec
                timeout = 10000,   -- 1 sec is the timeout for network operations
                fall = 3,  -- # of successive failures before turning a peer down
                rise = 2,  -- # of successive successes before turning a peer up
                valid_statuses = {200, 302},  -- a list valid HTTP status code
                concurrency = 10,  -- concurrency level for test requests
           }
        if not ok then
            ngx.log(ngx.ERR, "failed to spawn health checker: ", err)
            return
        end
       end
    }

Thanks
Divya.
Reply all
Reply to author
Forward
0 new messages