# Question regarding the "server" directive handler function

**URL:** <https://www.ruby-forum.com/t/question-regarding-the-server-directive-handler-function/183751>\
**Category:** NGINX\
**Created:** [February 19, 2010, 1:18pm UTC](https://www.ruby-forum.com/t/question-regarding-the-server-directive-handler-function/183751 "2010-02-19T13:18:48Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mauro\_Stettler](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/898d66/32.png) [@Mauro\_Stettler](https://www.ruby-forum.com/u/Mauro_Stettler)\
**Post date:** [February 19, 2010, 1:18pm UTC](https://www.ruby-forum.com/t/question-regarding-the-server-directive-handler-function/183751/1 "2010-02-19T13:18:48Z")

</div>

hi

some time ago i wrote the nginx module upstream\_consistent\_hash which  
is also presented on the nginx wiki:

> **[NGINX 3rd Party Modules | NGINX](https://www.nginx.com/resources/wiki/modules/)**
>
> A list of third party modules for NGINX.

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?

thanks,

mauro

---

<div class="post-metadata">

**Author:** ![Mauro\_Stettler](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/898d66/32.png) [@Mauro\_Stettler](https://www.ruby-forum.com/u/Mauro_Stettler)\
**Post date:** [February 19, 2010, 1:42pm UTC](https://www.ruby-forum.com/t/question-regarding-the-server-directive-handler-function/183751/2 "2010-02-19T13:42:13Z")

</div>

Hello!

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

> upstream\_consistent\_hash module builds the hashring based on the  
> 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:

[http://git.openhack.ru/?p=nginx-patched.git;a=commitdiff;h=de9561bc10bdedb26f91cedb0fb2512785561b18](http://git.openhack.ru/?p=nginx-patched.git;a=commitdiff;h=de9561bc10bdedb26f91cedb0fb2512785561b18)

It would be fine to see this merged into nginx.

Maxim D.

---

<div class="post-metadata">

**Author:** ![Mauro\_Stettler](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/898d66/32.png) [@Mauro\_Stettler](https://www.ruby-forum.com/u/Mauro_Stettler)\
**Post date:** [February 19, 2010, 1:43pm UTC](https://www.ruby-forum.com/t/question-regarding-the-server-directive-handler-function/183751/3 "2010-02-19T13:43:58Z")

</div>

hi,

thanks a lot. i agree, it would be really nice to have that merged.  
shouldn’t be a big thing anyway (2 lines). i guess thats igor’s  
decision?

mauro
