HTTP Request filter module
agentzh at gmail.com
Thu Nov 3 11:00:37 UTC 2011
On Thu, Nov 3, 2011 at 3:06 PM, forum_id <nginx-forum at nginx.us> wrote:
> I have a requirement for HTTP request filter. Whenever I receive a HTTP
> request this filter module should read the request and does some
> internal statistical work, it doesn't manipulate the request page nor
> creates response page. It just need to peep into request that's it.
> After this filter module, nginx HTTP server should continue to process
> the request and serve the response to user. Can we do it without a proxy
> handler, because nginx serves the responses directly here.
I think this is a perfect use case for the rewrite_by_lua or
access_by_lua directives provided by the ngx_lua module. See
You can read and modify the request URI, query args, or even request
bodies in your Lua code and save the statistical results in the
shm-based dictionary (shared_dict) provided by ngx_lua or issue a
subrequest from within Lua to internal locations configured by
ngx_memc or ngx_redis2 via the ngx.location.capture API.
Because LuaJIT 2.0 is so light and so fast, this setting can achieve
performance comparable with an Nginx C module and also provide
scripting flexibility :)
More information about the nginx