I’ve just finished my first run of “echo” module hacking by the v0.15
release. The documentation is on the Nginx wiki site:
I’m not going to repeat everything in the wiki page but only quoting
the “Description” section (please allow me to do that ;)):
This module provides various utilities that help testing and
of other modules by trivially emulating different kinds of faked
People will also find it useful in real-world applications that need
1. serve static contents directly from memory (loading from the
2. wrap the upstream response with custom header and footer (kinda
the addition module but with contents read directly from the
file and Nginx variables).
3. merge contents of various "Nginx locations" (i.e., subrequests) together in a single main request (using echo_location and its friends). This is a special dual-role module that can *lazily* serve as a
handler or register itself as an output filter only upon demand. By
default, this module does not do anything at all.
Use of any of this module's directives (no matter content handler directives or filter directives) will force the chunked encoding to
used for the HTTP response due to the streaming nature of this
Technially, this module has also demonstrated the following
that might be helpful for module writers:
1. Issue parallel subreqeusts directly from content handler. 2. Issue chained subrequests directly from content handler, by
contination along the subrequest chain.
3. Interact with the Nginx event model directly from content
using custom events and timers, and resume the content handler
4. Dual-role module that can (lazily) serve as a content handler or
output filter or both.
5. Nginx config file variable creation and interpolation. 6. Streaming output control using output_chain, flush and its
7. Read client request body from the content handler, and returns
(asynchronously) to the content handler after completion.
Hopefully you’ll find it funny and useful.