question regarding the "server" directive handler function

Maxim Dounin mdounin at
Fri Feb 19 15:40:35 MSK 2010


On Fri, Feb 19, 2010 at 08:18:13PM +0800, Mauro Stettler wrote:

> hi
> some time ago i wrote the nginx module upstream_consistent_hash which
> is also presented on the nginx wiki:
> so this module actually works and is compatible to the php memcache
> module. but i have the following problem. if you specify memcache
> hosts, using dns names, then the php-memcache module will build the
> hashring based on the dns names that are entered, but the nginx
> upstream_consistent_hash module builds the hashring based on the
> resolved ips.
> i'm looking for a way to fix this. for this the directive handler
> function ngx_http_upstream_consistent_hash would need to get the
> actual strings which are entered into the config somehow, not only the
> resolved ips. so i've read through the code of the upstream module
> where it handles the "server" directive. and if i understand that code
> there right, there is actually no way to retrieve the entered strings
> without patching the upstreams module, because the upstreams module
> seems to resolve the names via ngx_parse_url and then only keeps
> certain data of the ngx_url_t struct, but not the actual entered
> string.
> is that right, do i really have to patch the upstreams module, or did
> i (hopefully) miss something?

Yes, it's currently impossible to get upstream name as written in 
config.  The patch for this may be found in memcached_hash module, 
commit is here:;a=commitdiff;h=de9561bc10bdedb26f91cedb0fb2512785561b18

It would be fine to see this merged into nginx.

Maxim Dounin

More information about the nginx mailing list