Profil de agentzhHuman & MachinePhotosBlogListesPlus Outils Aide

Blog


18 novembre

The "headers more" module: scripting input and output filters in your Nginx config file

I've been working madly on the "headers more" module:

   http://github.com/agentzh/headers-more-nginx-module

And got everything that I want working now. It also has a nice wiki page (which also has brief explanation of the underlying implementation):

   http://wiki.nginx.org/NginxHttpHeadersMoreModule

Our buzzword is that it can rewrite the "Server" output header dynamically! See this:

   location /foo {
        more_set_headers   "Server: $arg_server";
   }


Then GET /foo?server=Foo will get a response with the "Server: Foo" header set ;)

Input headers can be trivially rewritten as well, including the "Host" header:

    more_set_input_headers   "Host: some-other-host";

Well, the full practical power of this module is out of my current imagination. If you have some crazy uses, please drop me a line ;)

Happy Nginx hacking!
15 novembre

The "chunkin" module: Experimental chunked input support for Nginx

Pushed by those cutting-edge users on the Nginx mailing list, I've quickly worked out the "chunkin" module which adds HTTP 1.1 chunked input support for Nginx without the need of patching the core:

    http://github.com/agentzh/chunkin-nginx-module

This module registers an access-phase handler that will eagerly read and decode incoming request bodies when a "Transfer-Encoding: chunked" header triggers a 411 error page in Nginx (hey, that's what you have to pay for avoiding patching the core ;)). For requests that are not in the "chunked" transfer encoding, this module is a "no-op".

To enable the magic, just turn on the "chunkin" config option like this:

    chunkin on;
    location /foo { ... }
    ....

No other modification is required in your nginx.conf file. (The "chunkin" directive is not allowed in the location block BTW.)

This module is still considered highly experimental and there must be some serious bugs lurking somewhere. But you're encouraged to play and test it in your non-production environment and report any quirks to me :)

Efforts have been made to reduce data copying and dynamic memory allocation, thus unfortunately raising the risk of potential buffer handling bugs caused by premature optimizations :P

This module is not supposed to be merged into the Nginx core because I've used Ragel to generate the chunked encoding parser for joy :)

The following Nginx versions have been successfully tested by this module's (very limited) test suite:

   0.8.0 ~ 0.8.24
   0.7.21 ~ 0.7.63

The test suite definitely needs more test cases and the code is hacky in various places. If you're willing to contribute, feel free to ask me for a commit bit in a private email :)

Update: I've also added a wiki page for it: http://wiki.nginx.org/NginxHttpChunkinModule