Welcome! Log In Create A New Profile

Advanced

Adding server specific proxy_connect_timeout - Need help :)

Posted by anonymous-one 
Adding server specific proxy_connect_timeout - Need help :)
September 19, 2012 05:12AM
Before I begin, I should mention... I have never coded in C. But I think I should be able to pull this off. All the below is in relation to 1.3.4 source. So here goes:

What I am trying to accomplish is adding server specific proxy_connect_timeout.

Something along the lines of:

upstream name{
name 1.1.1.1 connect_timeout=5;
name 2.2.2.2 connect_timeout=10;
}

Like I said, my C skills are weak, but here is what I CAN do on my own here.

I can add the "connect_timeout" property to each server. I will just replicate what fail_timeout does now.

fail_timeout is defined, roughly in function ngx_http_upstream_server @ line 4199 in ngx_http_upstream.c.

So, giving each server a connect_timeout property I can do on my own.

Now having nginx use these timeouts, thats a different story.

What I know so far:

The above mentioned function creates an object "us".

"us" from what I can see is each server in the upstream block. Line 4339 in ngx_http_upstream.c seams to 'finalize' it all, and put each of the properties of "us" into place.

Now here is the part that I need help with:

As best as I can tell, the current "global" proxy_connect_timeout, is used in ngx_http_upstream.c line 1221.

It looks as follows:

if (rc == NGX_AGAIN) {
ngx_add_timer(c->write, u->conf->connect_timeout);
return;
}

The question I have is as follows:

If I add a property (connect_timeout) to the us object mentioned above, how do I expose it to the ngx_http_upstream_connect function so i can use each servers connect_timeout rather then the global one?

Thanks... Any and all successful changes I make I will post here for the community to use. Having server specific connect_timeouts would be quite useful. We have a few fallback backends. And the primary one we expect to be quite fast at connecting, but since the fallbacks are basically alternate trans-atlantic routes, we would like to give them a little bit longer to connect as they have a few additional hops... and hit a haproxy in the middle.

Thanks!
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 175
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready