[ANN] ngx_lua v0.1.2: rewrite_by_lua/access_by_lua fixes and new features
agentzh
agentzh at gmail.com
Wed Jan 12 11:04:25 MSK 2011
Hi, folks!
I'm happy to announce the v0.1.2 release of our ngx_lua module. You
can download the release tarball from the module's download page:
http://github.com/chaoslawful/lua-nginx-module/downloads
This release contains the following changes:
* Fixed a bug in rewrite_by_lua (introduced in ngx_lua v0.1.0) and
access_by_lua (introduced in ngx_lua v0.1.1) that it always sends out
a default response headers even if there's no user outputs in the
rewrite/access Lua handlers. Thanks Roman Vasilyev.
* The response headers returned from "ngx.location.capture" now
support multi-value headers, like "Set-Cookie". The value is a Lua
(array) table that holds all the values in the order that they appear.
For instance, if the subrequest response headers contains the
following lines:
Set-Cookie: a=3
Set-Cookie: foo=bar
Set-Cookie: baz=blah
Then res.header["Set-Cookie"] will be evaluted to the table value
{"a=3", "foo=bar", "baz=blah"}.
Thanks neilljordan ( https://github.com/neilljordan/ ).
* rewrite_by_lua_file, access_by_lua_file, and content_by_lua_file now
support nginx variables in the path value. For example:
# use nginx var in code path
# WARN: contents in nginx var must be carefully filtered,
# otherwise there'll be great security risk!
location ~ ^/app/(.+) {
content_by_lua_file /path/to/lua/app/root/$1.lua;
}
Thanks Xiaozhe Wang (chaoslawful).
* Fixed support for HTTP 1.0 requests. Sometimes you may want to use
nginx's standard ngx_proxy module to proxy requests to another nginx
machine configured by a location with content_by_lua. Because
proxy_pass only supports the HTTP 1.0 protocol, we have to know the
length of your response body and set the Content-Length header before
emitting any data out. ngx_lua will automatically recognize HTTP 1.0
requests and try to send out an appropriate Content-Length header for
you, at the first invocation of ngx.print() and ngx.say, assuming all
the response body data is in a single call of ngx.print() or ngx.say.
So if you want to support HTTP 1.0 clients like ngx_proxy, do not call
ngx.print() or ngx.say() multiple times, try buffering the output data
yourself wherever needed. This behavior is the same as the ngx_echo
module.
Please also note that rewrite_by_lua will *not* work with nginx 0.8.41 ~ 0.8.53.
Because the rewrite_by_lua and access_by_lua directives are very new,
be prepared to hit some hidden bugs. And you're very welcome to report
any issues that you meet on your side.
ngx_lua is an nginx C module that embeds the Lua or LuaJIT interpreter
into the nginx core and you can find the latest source code and the
complete documentation here
https://github.com/chaoslawful/lua-nginx-module
Enjoy!
-agentzh
More information about the nginx
mailing list