configure nginx to get url from redis with key and

2019-08-22 23:00发布

问题:

now, I'm blocked at how to configure nginx to get url from redis with key and proxy the url to other server, in a detail:

first, request: http://www.example.com?id=12345, nginx will split the url args to key=12345,then, nginx passes the key to redis, get the url saved in redis with key=12345,finally, nginx proxy the url to other servers?

I have read some info about HttpRedis2Module, HttpRedisModule and HttpLuaModule, but the directives of HttpRedis2Module and HttpRedisModule seem to get content from redis and then response to client, but this doesn't match my demand, so I also take a look at HttpLuaModule, but it seems to difficult, so could you teach me how to configure this or some useful blogs, thanks

回答1:

Take a look at https://github.com/openresty/lua-resty-redis. You will be able to get a key's value from redis in async. way.

Here you may find the good example - http://openresty.org/#DynamicRoutingBasedOnRedis



标签: nginx lua redis