Closed eklinger closed 13 years ago
You can try ngx_lua module's ngx.location.capture and ngx.var.VAR interface:
http://wiki.nginx.org/HttpLuaModule
The ngx_eval module is also an option but I do not recommend it because ngx_lua is more flexible and more stable and you can do full error processing upon failures :)
Thank you for your fast reply. I am still having problems, though.
My nginx.conf file looks like:
location /add { set $memc_cmd 'set'; set $memc_key $remote_addr; set $memc_value 1; memc_pass localhost:11211; } location /whitelist { set $memc_cmd 'get'; set $memc_key $remote_addr; memc_pass localhost:11211;
}
location /redir {
default_type 'text/plain';
set $whitelist "";
content_by_lua '
local res = ngx.location.capture("/whitelist")
ngx.var.whitelist = res.body
ngx.print(res.body)
';
}
First I go to /add and I can see the entry was created in memcached by running memcached-tool localhost dump
But when I then go to /whitelist I see this in my error logs:
2011/10/04 17:04:46 [error] 19019#0: 17 memcached sent invalid trailer while reading response header from upstream, client: 127.0.0.1, server: localhost, request: "GET /whitelist HTTP/1.1", upstream: "memcached://127.0.0.1:11211", host: "localhost" 2011/10/04 17:04:46 [alert] 19019#0: 17 writev() failed (22: Invalid argument) while sending to client, client: 127.0.0.1, server: localhost, request: "GET /whitelist HTTP/1.1", upstream: "memcached://127.0.0.1:11211", host: "localhost"
I was expecting to see the response "1" back.
Thanks Evan
On Tue, Oct 4, 2011 at 4:02 PM, agentzh (章亦春) reply@reply.github.com wrote:
You can try ngx_lua module's ngx.location.capture and ngx.var.VAR interface:
http://wiki.nginx.org/HttpLuaModule
The ngx_eval module is also an option but I do not recommend it because ngx_lua is more flexible and more stable and you can do full error processing upon failures :)
Reply to this email directly or view it on GitHub: https://github.com/agentzh/memc-nginx-module/issues/7#issuecomment-2292558
Which verison of ngx_memc are you using? Please show me the output of the "nginx -V" command?
nginx: nginx version: nginx/1.1.4 nginx: built by gcc 4.6.1 20110908 (Red Hat 4.6.1-9) (GCC) nginx: TLS SNI support enabled nginx: configure arguments: --add-module=/home/eklinger/Downloads/simpl-ngx_http_set_hash-cfdd587 --add-module=/home/eklinger/Downloads/agentzh-memc-nginx-module-65002b9/ --add-module=/home/eklinger/Downloads/ngx_devel_kit/ --add-module=/home/eklinger/Downloads/lua-nginx-module/
Should be the memc module linked from the nginx web site.
Thanks Evan
On Tue, Oct 4, 2011 at 7:10 PM, agentzh (章亦春) reply@reply.github.com wrote:
Which verison of ngx_memc are you using? Please show me the output of the "nginx -V" command?
Reply to this email directly or view it on GitHub: https://github.com/agentzh/memc-nginx-module/issues/7#issuecomment-2293748
On Wed, Oct 5, 2011 at 9:27 AM, eklinger reply@reply.github.com wrote:
nginx: nginx version: nginx/1.1.4 nginx: built by gcc 4.6.1 20110908 (Red Hat 4.6.1-9) (GCC) nginx: TLS SNI support enabled nginx: configure arguments: --add-module=/home/eklinger/Downloads/simpl-ngx_http_set_hash-cfdd587 --add-module=/home/eklinger/Downloads/agentzh-memc-nginx-module-65002b9/ --add-module=/home/eklinger/Downloads/ngx_devel_kit/ --add-module=/home/eklinger/Downloads/lua-nginx-module/
Should be the memc module linked from the nginx web site.
Ah, you're using nginx 1.1.4. Your version of ngx_memc does not support nginx 1.1.4. Please try the latest master branch of ngx_memc's git repository and let me know the result :)
Thanks! -agentzh
That works! Thank you for your support.
On Wed, Oct 5, 2011 at 11:38 AM, agentzh (章亦春) reply@reply.github.com wrote:
On Wed, Oct 5, 2011 at 9:27 AM, eklinger reply@reply.github.com wrote:
nginx: nginx version: nginx/1.1.4 nginx: built by gcc 4.6.1 20110908 (Red Hat 4.6.1-9) (GCC) nginx: TLS SNI support enabled nginx: configure arguments: --add-module=/home/eklinger/Downloads/simpl-ngx_http_set_hash-cfdd587 --add-module=/home/eklinger/Downloads/agentzh-memc-nginx-module-65002b9/ --add-module=/home/eklinger/Downloads/ngx_devel_kit/ --add-module=/home/eklinger/Downloads/lua-nginx-module/
Should be the memc module linked from the nginx web site.
Ah, you're using nginx 1.1.4. Your version of ngx_memc does not support nginx 1.1.4. Please try the latest master branch of ngx_memc's git repository and let me know the result :)
Thanks! -agentzh
Reply to this email directly or view it on GitHub: https://github.com/agentzh/memc-nginx-module/issues/7#issuecomment-2301500
Cool! I'm closing this :)
Is it possible to get the memcache value from a get request stored in a variable rather than passed back in the content body? I want to retrieve the value and perform more operations on it first. Thank you