Skip to content

Commit 0428b88

Browse files
committed
Merge branch 'master' of github.com:chaoslawful/lua-nginx-module
2 parents c2d095a + f73785c commit 0428b88

File tree

3 files changed

+154
-93
lines changed

3 files changed

+154
-93
lines changed

README

Lines changed: 78 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ Status
88
This module is under active development and is production ready.
99

1010
Version
11-
This document describes ngx_lua v0.5.1
12-
(<https://github.com/chaoslawful/lua-nginx-module/tags>) released on 16
11+
This document describes ngx_lua v0.5.2
12+
(<https://github.com/chaoslawful/lua-nginx-module/tags>) released on 18
1313
June 2012.
1414

1515
Synopsis
@@ -227,9 +227,9 @@ Directives
227227
to to reload the config file are to send a "HUP" signal or to restart
228228
Nginx.
229229

230-
The ngx_lua module does not currently support the "stat" mode available
231-
with the Apache "mod_lua" module but this is planned for implementation
232-
in the future.
230+
The "ngx_lua" module does not currently support the "stat" mode
231+
available with the Apache "mod_lua" module but this is planned for
232+
implementation in the future.
233233

234234
Disabling the Lua code cache is strongly discouraged for production use
235235
and should only be used during development as it has a significant
@@ -385,6 +385,10 @@ Directives
385385
can be temporarily disabled during development by switching
386386
lua_code_cache "off" in "nginx.conf" to avoid reloading Nginx.
387387

388+
Since the "v0.5.0rc32" release, the file specified by
389+
"<path-to-lua-script-file>" can be a pre-compiled Lua/LuaJIT bytecode
390+
file.
391+
388392
This directive requires the ngx_devel_kit
389393
(<https://github.com/simpl/ngx_devel_kit>) module.
390394

@@ -428,6 +432,10 @@ Directives
428432
can be temporarily disabled during development by switching
429433
lua_code_cache "off" in "nginx.conf" to avoid reloading Nginx.
430434

435+
Since the "v0.5.0rc32" release, the file specified by
436+
"<path-to-lua-script-file>" can be a pre-compiled Lua/LuaJIT bytecode
437+
file.
438+
431439
rewrite_by_lua
432440
syntax: *rewrite_by_lua <lua-script-str>*
433441

@@ -578,6 +586,10 @@ Directives
578586
"rewrite" request-processing phase unless rewrite_by_lua_no_postpone is
579587
turned on.
580588

589+
Since the "v0.5.0rc32" release, the file specified by
590+
"<path-to-lua-script-file>" can be a pre-compiled Lua/LuaJIT bytecode
591+
file.
592+
581593
access_by_lua
582594
syntax: *access_by_lua <lua-script-str>*
583595

@@ -677,6 +689,10 @@ Directives
677689
lua_code_cache "off" in "nginx.conf" to avoid repeatedly reloading
678690
Nginx.
679691

692+
Since the "v0.5.0rc32" release, the file specified by
693+
"<path-to-lua-script-file>" can be a pre-compiled Lua/LuaJIT bytecode
694+
file.
695+
680696
header_filter_by_lua
681697
syntax: *header_filter_by_lua <lua-script-str>*
682698

@@ -723,6 +739,10 @@ Directives
723739
into the absolute path relative to the "server prefix" path determined
724740
by the "-p PATH" command-line option while starting the Nginx server.
725741

742+
Since the "v0.5.0rc32" release, the file specified by
743+
"<path-to-lua-script-file>" can be a pre-compiled Lua/LuaJIT bytecode
744+
file.
745+
726746
This directive was first introduced in the "v0.2.1rc20" release.
727747

728748
body_filter_by_lua
@@ -831,6 +851,10 @@ Directives
831851
into the absolute path relative to the "server prefix" path determined
832852
by the "-p PATH" command-line option while starting the Nginx server.
833853

854+
Since the "v0.5.0rc32" release, the file specified by
855+
"<path-to-lua-script-file>" can be a pre-compiled Lua/LuaJIT bytecode
856+
file.
857+
834858
This directive was first introduced in the "v0.5.0rc32" release.
835859

836860
log_by_lua
@@ -913,6 +937,10 @@ Directives
913937
into the absolute path relative to the "server prefix" path determined
914938
by the "-p PATH" command-line option while starting the Nginx server.
915939

940+
Since the "v0.5.0rc32" release, the file specified by
941+
"<path-to-lua-script-file>" can be a pre-compiled Lua/LuaJIT bytecode
942+
file.
943+
916944
This directive was first introduced in the "v0.5.0rc31" release.
917945

918946
lua_need_request_body
@@ -2502,7 +2530,7 @@ Nginx API for Lua
25022530
ngx.exec("/foo", "a=3&b=hello%20world")
25032531

25042532
Alternatively, a Lua table can be passed for the "args" argument for
2505-
ngx_lua to carry out URI escaping and string concatenation
2533+
"ngx_lua" to carry out URI escaping and string concatenation
25062534
automatically.
25072535

25082536
ngx.exec("/foo", { a = 3, b = "hello world" })
@@ -2596,10 +2624,10 @@ Nginx API for Lua
25962624

25972625
context: *set_by_lua*, rewrite_by_lua*, access_by_lua*, content_by_lua**
25982626

2599-
Returns "true" if the response headers have been sent (by ngx_lua), and
2600-
"false" otherwise.
2627+
Returns "true" if the response headers have been sent (by "ngx_lua"),
2628+
and "false" otherwise.
26012629

2602-
This API was first introduced in ngx_lua v0.3.1rc6.
2630+
This API was first introduced in "ngx_lua" v0.3.1rc6.
26032631

26042632
ngx.print
26052633
syntax: *ngx.print(...)*
@@ -4101,44 +4129,44 @@ Nginx API for Lua
41014129
(<https://github.com/simpl/ngx_devel_kit>) module.
41024130

41034131
Lua/LuaJIT bytecode support
4104-
Since the "v0.5.0rc32" release, all the *_by_lua_file configure
4105-
directives (like content_by_lua_file) support loading Lua 5.1 and LuaJIT
4106-
2.0 raw bytecode files automatically.
4132+
All *_by_lua_file configure directives (such as content_by_lua_file)
4133+
support directly loading Lua 5.1 and LuaJIT 2.0 raw bytecode files since
4134+
the "v0.5.0rc32" release.
41074135

4108-
Please note that the bytecode format used by LuaJIT 2.0 is completely
4109-
different from the standard Lua 5.1 interpreter's. So if you're using
4110-
LuaJIT 2.0 with this Nginx module, you need to use LuaJIT 2.0 to
4111-
generate LuaJIT-compatible bytecode files, like this:
4136+
Please note that the bytecode format used by LuaJIT 2.0 is not
4137+
compatible with that for the standard Lua 5.1 interpreter. So if using
4138+
LuaJIT 2.0 with "ngx_lua", LuaJIT-compatible bytecode files must be
4139+
generated as shown:
41124140

4113-
/path/to/luajit/bin/luajit-2.0.0-beta10 -b /path/to/your.lua /path/to/your.luac
4141+
/path/to/luajit/bin/luajit -b /path/to/input_file.lua /path/to/output_file.luac
41144142

4115-
You can use the "-bg" option instead to include debug information in the
4116-
LuaJIT bytecode file:
4143+
The "-bg" option can be used to include debug information in the LuaJIT
4144+
bytecode file:
41174145

4118-
/path/to/luajit/bin/luajit-2.0.0-beta10 -bg /path/to/your.lua /path/to/your.luac
4146+
/path/to/luajit/bin/luajit -bg /path/to/input_file.lua /path/to/output_file.luac
41194147

4120-
Check out the official documentation for "luajit"'s "-b" option for more
4121-
details:
4148+
Please refer to the official LuaJIT documentation for the "-b" option
4149+
for more details:
41224150

41234151
http://luajit.org/running.html#opt_b
41244152

4125-
Similarly, if you're using the standard Lua 5.1 interpreter with this
4126-
Nginx module, then you need to use the "luac" command-line utility to
4127-
generate the Lua-compatible bytecode files, like this:
4153+
Similarly, if using the standard Lua 5.1 interpreter with "ngx_lua",
4154+
Lua-compatible bytecode files must be generated using the "luac"
4155+
command-line utility as shown:
41284156

4129-
luac -o /path/to/your.luac /path/to/your.lua
4157+
luac -o /path/to/output_file.luac /path/to/input_file.lua
41304158

4131-
Unlike LuaJIT, the debug information in included in standard Lua 5.1's
4132-
bytecode by default. You can strip the debug information by specifying
4133-
the "-s" option, as in
4159+
Unlike as with LuaJIT, debug information is included in standard Lua 5.1
4160+
bytecode files by default. This can be striped out by specifying the
4161+
"-s" option as shown:
41344162

4135-
luac -s -o /path/to/your.luac /path/to/your.lua
4163+
luac -s -o /path/to/output_file.luac /path/to/input_file.lua
41364164

4137-
If you're trying to load a standard Lua 5.1 bytecode file into an nginx
4138-
linked with LuaJIT 2.0 or in the other way around, you will get an error
4139-
message like below in your Nginx's "error.log" file:
4165+
Attempts to load standard Lua 5.1 bytecode files into "ngx_lua"
4166+
instances linked to LuaJIT 2.0 or vice versa, an error message such as
4167+
that below will be logged in the Nginx "error.log" file:
41404168

4141-
[error] 13909\#0: *1 failed to load Lua inlined code: bad byte-code header in /path/to/test.luac
4169+
[error] 13909#0: *1 failed to load Lua inlined code: bad byte-code header in /path/to/test_file.luac
41424170

41434171
Loading bytecode files via the Lua primitives like "require" and
41444172
"dofile" should always work as expected.
@@ -4250,16 +4278,16 @@ Known Issues
42504278
5.1 and LuaJIT 2.0 and when ngx.location.capture is called,
42514279
ngx.exec, ngx.exit or ngx.req.read_body or similar in the file to be
42524280
loaded by "dofile", a coroutine yield across the C function boundary
4253-
will be initiated. This however is not allowed within ngx_lua and
4254-
will usually result in error messages like "lua handler aborted:
4255-
runtime error: attempt to yield across C-call boundary". To avoid
4256-
this, define a real Lua module and use the Lua "require" builtin
4257-
instead.
4258-
4259-
* Because the standard Lua 5.1 interpreter's VM is not fully
4260-
resumable, the methods ngx.location.capture,
4261-
ngx.location.capture_multi, ngx.redirect, ngx.exec, and ngx.exit
4262-
cannot be used within the context of a Lua pcall()
4281+
will be initiated. This however is not normally allowed within
4282+
"ngx_lua" and will usually result in error messages like "lua
4283+
handler aborted: runtime error: attempt to yield across C-call
4284+
boundary". To avoid this, define a real Lua module and use the Lua
4285+
"require" builtin instead.
4286+
4287+
* As the standard Lua 5.1 interpreter's VM is not fully resumable, the
4288+
methods ngx.location.capture, ngx.location.capture_multi,
4289+
ngx.redirect, ngx.exec, and ngx.exit cannot be used within the
4290+
context of a Lua pcall()
42634291
(<http://www.lua.org/manual/5.1/manual.html#pdf-pcall>) or xpcall()
42644292
(<http://www.lua.org/manual/5.1/manual.html#pdf-xpcall>) when the
42654293
standard Lua 5.1 interpreter is used and the "attempt to yield
@@ -4460,6 +4488,9 @@ Typical Uses
44604488
Nginx Compatibility
44614489
The module is compatible with the following versions of Nginx:
44624490

4491+
*
4492+
1.2.x (last tested: 1.2.1)
4493+
44634494
*
44644495
1.1.x (last tested: 1.1.5)
44654496

@@ -4495,7 +4526,7 @@ Installation
44954526
2. Download the latest version of the ngx_devel_kit (NDK) module HERE
44964527
(<http://github.com/simpl/ngx_devel_kit/tags>).
44974528

4498-
3. Download the latest version of this module HERE
4529+
3. Download the latest version of "ngx_lua" HERE
44994530
(<http://github.com/chaoslawful/lua-nginx-module/tags>).
45004531

45014532
4. Download the latest version of Nginx HERE (<http://nginx.org/>) (See
@@ -4595,7 +4626,7 @@ Changes
45954626

45964627
* bugfix: ngx.exit, ngx.redirect, ngx.exec, and ngx.req.set_uri(uri,
45974628
true) could return (they should never return as per the
4598-
documentation). this bug had appeared in ngx_lua v0.3.1rc4 and
4629+
documentation). this bug had appeared in "ngx_lua" v0.3.1rc4 and
45994630
ngx_openresty 1.0.6.13. thanks @cyberty (<http://weibo.com/cyberty>)
46004631
for reporting it.
46014632

@@ -4637,7 +4668,7 @@ Changes
46374668
value. thanks sexybabes.
46384669

46394670
* feature: implemented the ngx.headers_sent API to check if response
4640-
headers are sent (by ngx_lua). thanks @hugozhu.
4671+
headers are sent (by "ngx_lua"). thanks @hugozhu.
46414672

46424673
* feature: exposes the CRC-32 API of the Nginx core to the Lua land,
46434674
in the form of the ngx.crc32_short and ngx.crc32_long methods.

0 commit comments

Comments
 (0)