配置Nginx以使用密钥从Redis获取URL并将URL代理到其他服务器 [英] configure nginx to get url from redis with key and proxy the url to other server
问题描述
现在,我不知道如何配置nginx以使用key从redis获取url并将该url代理到其他服务器,
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:
首先,请求: http://www.example.com?id=12345 , Nginx会将URL args拆分为key = 12345,然后,nginx将密钥传递给redis,使用key = 12345将URL保存到redis中,最后,nginx将URL代理到其他服务器吗?
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?
我已经阅读了有关HttpRedis2Module,HttpRedisModule和HttpLuaModule的信息, 但是HttpRedis2Module和HttpRedisModule的指令似乎从redis获取内容,然后响应客户端,但这与我的要求不符,因此我也研究了HttpLuaModule,但这似乎很困难,所以您可以教我如何配置这个或一些有用的博客,谢谢
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
推荐答案
看看 https: //github.com/openresty/lua-resty-redis . 您将能够以异步方式从redis获取密钥的值.方式.
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.
在这里您可能会找到一个很好的例子- http://openresty.org/#DynamicRoutingBasedOnRedis
Here you may find the good example - http://openresty.org/#DynamicRoutingBasedOnRedis
这篇关于配置Nginx以使用密钥从Redis获取URL并将URL代理到其他服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!