openresty / lua-resty-upstream-healthcheck

Health Checker for Nginx Upstream Servers in Pure Lua
515 stars 134 forks source link

invalid http_req introduce 400 code #65

Open shsun opened 4 years ago

shsun commented 4 years ago

I introduce this module to my project but got 400 error for the invalid http_req.

    local ok, err = hc.spawn_checker{
        shm = "healthcheck",  -- defined by "lua_shared_dict"
        upstream = "foo.com", -- defined by "upstream"
        type = "http",

        -- the http_req has a bug ? 
        -- http_req字段的格式可能有问题? 至少在我这里是老得到400 code. 
        http_req = "GET /status HTTP/1.0\r\nHost: foo.com\r\n\r\n",
                -- raw HTTP request for checking

        interval = 2000,  -- run the check cycle every 2 sec
        timeout = 1000,   -- 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
    }

Everything is ok if i update the http_req as below: http_req = "GET /status HTTP/1.0\r\n\r\nHost: foo.com",

please advice.