nginx mod_zip and lua

259 views
Skip to first unread message

Tor Hveem

unread,
Dec 9, 2013, 11:41:06 AM12/9/13
to openre...@googlegroups.com
I'm trying to craft a zip-file using lua and
https://github.com/evanmiller/mod_zip

Basically my question is the same as this:
http://stackoverflow.com/questions/20110601/nginx-custom-request-body

But I'm wondering if this module will work together with lua at all?

Anyone have any suggestions?

Thanks
--
Tor

Yichun Zhang (agentzh)

unread,
Dec 9, 2013, 10:28:56 PM12/9/13
to openresty-en
Hello!

On Mon, Dec 9, 2013 at 8:41 AM, Tor Hveem wrote:
> I'm trying to craft a zip-file using lua and
> https://github.com/evanmiller/mod_zip
>
> Basically my question is the same as this:
> http://stackoverflow.com/questions/20110601/nginx-custom-request-body
>
> But I'm wondering if this module will work together with lua at all?
>

As far as I can see, Evan Miller's mod_zip is an nginx output filter
module, which means that it should work with content_by_lua and echo.
If not, then you should check the nginx debugging logs to debug any
issues here. See http://nginx.org/en/docs/debugging_log.html

It is recommended, however, to implement the job done by mod_zip in
pure Lua to reduce the overall complexity here.

Regards,
-agentzh

Tor Hveem

unread,
Dec 10, 2013, 8:15:47 AM12/10/13
to openre...@googlegroups.com
Thank you for your reply, I will try more debugging.

Do you mean using a lua library to create zip files within lua, would
that not scale poorly with the nginx lua event model?

Thanks

2013/12/10 Yichun Zhang (agentzh) <age...@gmail.com>:
> --
> You received this message because you are subscribed to the Google Groups "openresty-en" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to openresty-en...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.

Yichun Zhang (agentzh)

unread,
Dec 10, 2013, 10:51:33 AM12/10/13
to openresty-en
Hello!

On Tue, Dec 10, 2013 at 5:15 AM, Tor Hveem wrote:
>
> Do you mean using a lua library to create zip files within lua, would
> that not scale poorly with the nginx lua event model?
>

Why do you say that? What's wrong with ngx_lua's event model?

Actually with pure Lua implementation, you can save the cost involved
in subrequests which are used by Evan Miller's mod_zip module. And
with ngx.flush(true) provided by ngx_lua you can also ensure very
small (and even constant) memory footprint.

Regards,
-agentzh

乔巴乔巴

unread,
Oct 30, 2014, 3:50:23 AM10/30/14
to openre...@googlegroups.com
Hi, 

I'm trying to get nginx mod_zip and lua working together. But I was encountered with the same issues described by Tor Hveem. And there is no difference between response headers of php and lua. I could get a successful zip via php, while a failed zip via lua. If I open the failed zip file by nodepad++,  the following line is found:  - 0 /data/12.txt 1.txt

It seems that response headers or body lines set by lua cannot be filtered by mod_zip successfully.  Do you have any suggestion? 

Thanks.



在 2013年12月10日星期二UTC+8上午11时28分56秒,agentzh写道:

Vladislav Manchev

unread,
Oct 30, 2014, 5:14:58 AM10/30/14
to openre...@googlegroups.com
Try posting a self-contained example of what you're trying to achieve, this will increase your chances of getting a solution.

Looking at the initial thread one also does wonder why not use Lua for setting headers.

Finally, the following change looks relevant to your question, so you might want to look into it: https://github.com/evanmiller/mod_zip/pull/26


Best,
Vladislav

--
You received this message because you are subscribed to the Google Groups "openresty-en" group.
To unsubscribe from this group and stop receiving emails from it, send an email to openresty-en...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

乔巴乔巴

unread,
Oct 30, 2014, 11:26:44 PM10/30/14
to openre...@googlegroups.com
Thank you ! 

I upgrade mod_zip from v1.16 to the newest, and it does work.  Version 1.1.6 dosen't support non-upstream header settings like ngx_lua.


在 2014年10月30日星期四UTC+8下午5时14分58秒,Vladislav Manchev写道:
Reply all
Reply to author
Forward
0 new messages