lua-resty-upstream-healthcheck icon indicating copy to clipboard operation
lua-resty-upstream-healthcheck copied to clipboard

add ssl support

Open sitano opened this issue 10 years ago • 17 comments

I have added ssl handshake if requested to support https during health checking. It also able to skip cert checks which is fine for my use case. Session caching could be added in the future.

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

        -- if you put this Lua snippet in separate .lua file,
        -- then you should write this instead: http_req = "GET /status HTTP/1.0\r\nHost: foo.com\r\n\r\n",
        http_req = "GET /status HTTP/1.0\\r\\nHost: foo.com\\r\\n\\r\\n",
                -- raw HTTP request for checking

        ssl = true, -- use https
        ssl_verify = false, -- verify SSL certs, see https://github.com/openresty/lua-nginx-module/pull/290

        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
    }

sitano avatar Aug 24 '15 16:08 sitano

We can reuse ["type"] field instead of introducing separate ["ssl"] field. Missed it while developing a variant.

sitano avatar Aug 25 '15 10:08 sitano

Now its

    local ok, err = hc.spawn_checker{
        shm = "healthcheck",
        upstream = "foo.com",

        type = "https",
        ssl_verify = false,

        http_req = "GET /status HTTP/1.0\\r\\nHost: foo.com\\r\\n\\r\\n",
    }

sitano avatar Aug 25 '15 16:08 sitano

@sitano Thank you for the patch! Will you please add some corresponding test cases to the existing test suite (under t/) also? Thanks!

agentzh avatar Aug 27 '15 03:08 agentzh

hi @agentzh . thanks for the comments . i will do all the changes you described . tests too . i was going to provide ssl session caching a bit later, but i will look into it .

sitano avatar Aug 27 '15 07:08 sitano

@sitano Great! Thanks!

agentzh avatar Aug 27 '15 07:08 agentzh

Any news about getting the ssl support merged?

pasikarkkainen avatar Jun 12 '16 12:06 pasikarkkainen

@pasikarkkainen Yeah, this is long overdue. Sorry about that. I'll look into this soon.

agentzh avatar Jun 12 '16 15:06 agentzh

Ping? :)

pasikarkkainen avatar Sep 23 '16 10:09 pasikarkkainen

hi @agentzh, why not just change socket to resty.http? And we do't have to bind this module with ngx.upstream, so we can use this module with balancer by lua ?

binnn6 avatar Oct 17 '16 09:10 binnn6

@agentzh Any update on this?

bompus avatar Oct 26 '16 21:10 bompus

@doujiang24 Please review this PR when you have a chance. Thanks!

agentzh avatar Oct 26 '16 21:10 agentzh

@bompus It seems that @sitano has not updated his branch according to the comments of my last round of review.

agentzh avatar Oct 26 '16 21:10 agentzh

Also, there's conflicts between this branch and master that must be solved before this PR can be merged.

agentzh avatar Oct 26 '16 21:10 agentzh

@agentzh yes, sorry. no still.

sitano avatar Oct 27 '16 00:10 sitano

@sitano is it likely you'll be able to fix/resolve the merge conflict, or should someone else pick up this work? Thanks.

pasikarkkainen avatar Dec 06 '16 09:12 pasikarkkainen

Hi. Better pickup if in a hurry. I am very short on time currently.

Sent from my iPhone

On 6 Dec 2016, at 11:25, pasikarkkainen [email protected] wrote:

@sitano is it likely you'll be able to fix/resolve the merge conflict, or should someone else pick up this work? Thanks.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

sitano avatar Dec 09 '16 15:12 sitano

This work is being completed at: https://github.com/Shopify/lua-resty-upstream-healthcheck/pull/1

ElvinEfendi avatar Jan 23 '17 21:01 ElvinEfendi