# Ngx\_lua v0.1.2: rewrite\_by\_lua/access\_by\_lua fixes and new features

**URL:** <https://www.ruby-forum.com/t/ngx-lua-v0-1-2-rewrite-by-lua-access-by-lua-fixes-and-new-features/201644>\
**Category:** NGINX\
**Created:** [January 12, 2011, 9:06am UTC](https://www.ruby-forum.com/t/ngx-lua-v0-1-2-rewrite-by-lua-access-by-lua-fixes-and-new-features/201644 "2011-01-12T09:06:16Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![luislavena](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/0ea827/32.png) [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Post date:** [January 12, 2011, 9:06am UTC](https://www.ruby-forum.com/t/ngx-lua-v0-1-2-rewrite-by-lua-access-by-lua-fixes-and-new-features/201644/1 "2011-01-12T09:06:16Z")

</div>

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 V…

- 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:

- rewrite\_by\_lua\_file, access\_by\_lua\_file, and content\_by\_lua\_file now  
support nginx variables in the path value. For example:

- 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](https://github.com/chaoslawful/lua-nginx-module)

Enjoy!  
-agentzh
