Welcome! Log In Create A New Profile

Advanced

Re: nginx memcache for redirecta

agentzh
November 02, 2009 10:08PM
2009/11/3 Fernando Flórez <fernando@funciton.com>:
> Hello,
>
> I would like to know if i could use nginx's memcache module to store urls so
> i can create redirects based on variables.
>
> Is this possible?
>

Yes, it's possible, with the excellent "eval" module (
http://www.grid.net.ru/nginx/eval.en.html ):

location / {
eval $my_real_url {
set $memcached_key $request_uri;
memcached_pass '127.0.0.1:11211';
}
proxy_pass $scheme://127.0.0.1:$server_port$my_real_url;
}

assuming you have memcached set up at localhost:11211. Then store the
key-value pair /blah and /foo in your memcached:

$ set-memcached localhost:11211 /blah /foo

And access your nginx server this way:

$ curl 'http://localhost/blah'

You'll get the results of the location /foo.

Here I use "proxy_pass" in the example above because I dunno if
there's a config file level directive for the nginx C function
ngx_http_internal_redirect. Using a "proxy" here is rather
inefficient.

I'll add one (named echo_exec) later to my "echo" module anyway.

Cheers,
-agentzh
Subject Author Posted

nginx memcache for redirecta

Fernando Flórez November 02, 2009 08:14PM

Re: nginx memcache for redirecta

张立冰 November 02, 2009 09:48PM

Re: nginx memcache for redirecta

Fernando Flórez November 02, 2009 10:10PM

Re: nginx memcache for redirecta

张立冰 November 02, 2009 10:34PM

Re: nginx memcache for redirecta

agentzh November 02, 2009 10:08PM

Re: nginx memcache for redirecta

agentzh November 02, 2009 10:16PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

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