Hello!
On Mon, Jul 1, 2013 at 7:46 AM, gabor.lengyel wrote:
> As far as I understand, Redis, Mysql, etc. cannot be used in
> body_filter_by_lua. How do I get around this, if in a reverse proxy setup I
> need to modify the content served by the upstream server, before passing it
> on to the client, and the modification needs data from a database?
>
Instead of using a body filter, you can just use ngx.location.capture
to do a subrequest to access your location configured by ngx_proxy and
modify the whole response body in Lua before sending it out. See
http://wiki.nginx.org/HttpLuaModule#ngx.location.capture
Alternatively, you can cache your modification rules stored in Redis
or MySQL in either your nginx's Lua variables or shared memory
dictionaries so that you do not have to do I/O in your body filters.
In this setting, you can also use ngx.timer.at to periodically
synchronize your local rule cache with your backend storage. See
http://wiki.nginx.org/HttpLuaModule#ngx.timer.at
BTW, please join the mailing list before posting, otherwise your posts
require manual moderation.
Thanks!
-agentzh