Welcome! Log In Create A New Profile

Advanced

Re: Proxying module query

Piotr Sikora
January 06, 2010 07:44PM
> I'm struggling a bit to understand how a module can indicate which server
> to
> issue a request to - the example proxy module code presumably does this
> via
> the config for the upstream module. If I'm just interested in sending a
> query to a known host/port, what's the best way of doing this?

Using function registered with r->upstream->peer.get. There is number of
examples how to do this in nginx base: upstream_round_robin,
upstream_ip_hash and in 3rd party modules: upstream_hash, upstream_fair,
ngx_supervisord.

In short:
1) during configuration phase module sets pointer to init function in
uscf->peer.init_upstream,
2) during initialization phase module sets pointer to per-request init
function in uscf->peer.init and pointer to some data (which usually contains
list of backend servers) in uscf->peer.data.
3) as each request is processed, function at uscf->peer.init is called and
it, among other things, sets stuff like r->upstream->peer.get,
r->upstream->peer.free and r->upstream->peer.tries.
4) before connecting to upstream server, function at r->upstream->peer.get
is called and it sets information about which backend server nginx should
connect to in (ngx_peer_connection_t *) pc,
5) after request is processed from the upstream, function at
r->upstream->peer.free is called to "free resources".

That should be about it.

Best regards,
Piotr Sikora < piotr.sikora@frickle.com >


_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

Proxying module query

Edward Hibbert 3152 January 06, 2010 07:04PM

Re: Proxying module query

Piotr Sikora 1108 January 06, 2010 07:44PM

RE: Proxying module query

Edward Hibbert 1223 January 07, 2010 12:24PM

Re: Proxying module query

Piotr Sikora 1676 January 07, 2010 12:56PM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 308
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