# Set header based on memcached request - mod\_eval

**URL:** <https://www.ruby-forum.com/t/set-header-based-on-memcached-request-mod-eval/207831>\
**Category:** NGINX\
**Created:** [June 3, 2011, 4:56pm UTC](https://www.ruby-forum.com/t/set-header-based-on-memcached-request-mod-eval/207831 "2011-06-03T16:56:25Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![luislavena](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/0ea827/32.png) [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Post date:** [June 3, 2011, 4:56pm UTC](https://www.ruby-forum.com/t/set-header-based-on-memcached-request-mod-eval/207831/1 "2011-06-03T16:56:25Z")

</div>

Hi all,

I try to set a HTTP header for a proxy request based on some variable I  
get from memcached with the eval module:

location / {  
eval $role {  
set $memcached\_key $cookie\_sessionid;  
memcached\_pass 127.0.0.1:11211;  
}  
proxy\_pass [http://1.2.3.4:80](http://1.2.3.4:80);  
proxy\_set\_header X-Role $role;  
}

I can see the memcached request, however the HTTP requests to the nginx  
server just hangs for some seconds and no proxy request is done to the  
backend server.

Any ideas?

# nginx -V

nginx: nginx version: nginx/1.0.4  
nginx: built by gcc 4.1.2 20080704 (Red Hat 4.1.2-50)  
nginx: TLS SNI support disabled  
nginx: configure arguments: --user=nginx --group=nginx  
–prefix=/usr/share/nginx --sbin-path=/usr/sbin/nginx  
–conf-path=/etc/nginx/nginx.conf  
–error-log-path=/var/log/nginx/error.log  
–http-log-path=/var/log/nginx/access.log  
–http-client-body-temp-path=/var/lib/nginx/tmp/client\_body  
–http-proxy-temp-path=/var/lib/nginx/tmp/proxy  
–http-fastcgi-temp-path=/var/lib/nginx/tmp/fastcgi  
–pid-path=/var/run/nginx.pid --lock-path=/var/lock/subsys/nginx  
–with-http\_secure\_link\_module --with-http\_random\_index\_module  
–with-http\_ssl\_module --with-http\_realip\_module  
–with-http\_addition\_module --with-http\_sub\_module  
–with-http\_dav\_module --with-http\_flv\_module  
–with-http\_gzip\_static\_module --with-http\_stub\_status\_module  
–with-http\_perl\_module --with-mail --with-mail\_ssl\_module  
–with-cc-opt=‘-O2 -g -pipe -Wall -Wp,-D\_FORTIFY\_SOURCE=2 -fexceptions  
-fstack-protector --param=ssp-buffer-size=4 -m32 -march=i386  
-mtune=generic -fasynchronous-unwind-tables’ --with-ipv6 --with-file-aio  
–add-module=/home/compile/redhat/BUILD/nginx-1.0.4/nginx\_eval\_module-1.0.1

Regards,

Peter
