Skip to content

Commit 6f3238b

Browse files
committed
Merge branch 'master' into balancer-by-lua
2 parents 0cad356 + 6a664c8 commit 6f3238b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+1464
-193
lines changed

.gitmodules

Whitespace-only changes.

README.markdown

Lines changed: 131 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ Production ready.
6161
Version
6262
=======
6363

64-
This document describes ngx_lua [v0.9.19](https://github.com/openresty/lua-nginx-module/tags) released on 11 November 2015.
64+
This document describes ngx_lua [v0.9.20](https://github.com/openresty/lua-nginx-module/tags) released on 19 December 2015.
6565

6666
Synopsis
6767
========
@@ -243,7 +243,7 @@ Nginx Compatibility
243243
===================
244244
The latest module is compatible with the following versions of Nginx:
245245

246-
* 1.9.x (last tested: 1.9.3)
246+
* 1.9.x (last tested: 1.9.7)
247247
* 1.7.x (last tested: 1.7.10)
248248
* 1.6.x
249249
* 1.5.x (last tested: 1.5.12)
@@ -273,9 +273,9 @@ Build the source with this module:
273273

274274
```bash
275275

276-
wget 'http://nginx.org/download/nginx-1.9.3.tar.gz'
277-
tar -xzvf nginx-1.9.3.tar.gz
278-
cd nginx-1.9.3/
276+
wget 'http://nginx.org/download/nginx-1.9.7.tar.gz'
277+
tar -xzvf nginx-1.9.7.tar.gz
278+
cd nginx-1.9.7/
279279

280280
# tell nginx's build system where to find LuaJIT 2.0:
281281
export LUAJIT_LIB=/path/to/luajit/lib
@@ -1045,6 +1045,7 @@ Directives
10451045
* [lua_ssl_verify_depth](#lua_ssl_verify_depth)
10461046
* [lua_http10_buffering](#lua_http10_buffering)
10471047
* [rewrite_by_lua_no_postpone](#rewrite_by_lua_no_postpone)
1048+
* [access_by_lua_no_postpone](#access_by_lua_no_postpone)
10481049
* [lua_transform_underscores_in_response_headers](#lua_transform_underscores_in_response_headers)
10491050
* [lua_check_client_abort](#lua_check_client_abort)
10501051
* [lua_max_pending_timers](#lua_max_pending_timers)
@@ -1832,6 +1833,10 @@ As with other access phase handlers, [access_by_lua](#access_by_lua) will *not*
18321833

18331834
Note that when calling `ngx.exit(ngx.OK)` within a [access_by_lua](#access_by_lua) handler, the nginx request processing control flow will still continue to the content handler. To terminate the current request from within a [access_by_lua](#access_by_lua) handler, calling [ngx.exit](#ngxexit) with status >= 200 (`ngx.HTTP_OK`) and status < 300 (`ngx.HTTP_SPECIAL_RESPONSE`) for successful quits and `ngx.exit(ngx.HTTP_INTERNAL_SERVER_ERROR)` (or its friends) for failures.
18341835

1836+
Starting from the `v0.9.20` release, you can use the [access_by_lua_no_postpone](#access_by_lua_no_postpone)
1837+
directive to control when to run this handler inside the "access" request-processing phase
1838+
of NGINX.
1839+
18351840
[Back to TOC](#directives)
18361841

18371842
access_by_lua_block
@@ -2265,6 +2270,9 @@ The `<size>` argument accepts size units such as `k` and `m`:
22652270
}
22662271
```
22672272

2273+
The hard-coded minimum size is 8KB while the practical minimum size depends
2274+
on actual user data set (some people start with 12KB).
2275+
22682276
See [ngx.shared.DICT](#ngxshareddict) for details.
22692277

22702278
This directive was first introduced in the `v0.3.1rc22` release.
@@ -2518,12 +2526,27 @@ rewrite_by_lua_no_postpone
25182526

25192527
**context:** *http*
25202528

2521-
Controls whether or not to disable postponing [rewrite_by_lua](#rewrite_by_lua) and [rewrite_by_lua_file](#rewrite_by_lua_file) directives to run at the end of the `rewrite` request-processing phase. By default, this directive is turned off and the Lua code is postponed to run at the end of the `rewrite` phase.
2529+
Controls whether or not to disable postponing [rewrite_by_lua](#rewrite_by_lua)* directives to run at the end of the `rewrite` request-processing phase. By default, this directive is turned off and the Lua code is postponed to run at the end of the `rewrite` phase.
25222530

25232531
This directive was first introduced in the `v0.5.0rc29` release.
25242532

25252533
[Back to TOC](#directives)
25262534

2535+
access_by_lua_no_postpone
2536+
-------------------------
2537+
2538+
**syntax:** *access_by_lua_no_postpone on|off*
2539+
2540+
**default:** *access_by_lua_no_postpone off*
2541+
2542+
**context:** *http*
2543+
2544+
Controls whether or not to disable postponing [access_by_lua](#access_by_lua)* directives to run at the end of the `access` request-processing phase. By default, this directive is turned off and the Lua code is postponed to run at the end of the `access` phase.
2545+
2546+
This directive was first introduced in the `v0.9.20` release.
2547+
2548+
[Back to TOC](#directives)
2549+
25272550
lua_transform_underscores_in_response_headers
25282551
---------------------------------------------
25292552

@@ -2629,6 +2652,7 @@ Nginx API for Lua
26292652
* [ngx.status](#ngxstatus)
26302653
* [ngx.header.HEADER](#ngxheaderheader)
26312654
* [ngx.resp.get_headers](#ngxrespget_headers)
2655+
* [ngx.req.is_internal](#ngxreqis_internal)
26322656
* [ngx.req.start_time](#ngxreqstart_time)
26332657
* [ngx.req.http_version](#ngxreqhttp_version)
26342658
* [ngx.req.raw_header](#ngxreqraw_header)
@@ -2727,13 +2751,17 @@ Nginx API for Lua
27272751
* [ngx.thread.kill](#ngxthreadkill)
27282752
* [ngx.on_abort](#ngxon_abort)
27292753
* [ngx.timer.at](#ngxtimerat)
2754+
* [ngx.timer.running_count](#ngxtimerrunning_count)
2755+
* [ngx.timer.pending_count](#ngxtimerpending_count)
27302756
* [ngx.config.debug](#ngxconfigdebug)
27312757
* [ngx.config.prefix](#ngxconfigprefix)
27322758
* [ngx.config.nginx_version](#ngxconfignginx_version)
27332759
* [ngx.config.nginx_configure](#ngxconfignginx_configure)
27342760
* [ngx.config.ngx_lua_version](#ngxconfigngx_lua_version)
27352761
* [ngx.worker.exiting](#ngxworkerexiting)
27362762
* [ngx.worker.pid](#ngxworkerpid)
2763+
* [ngx.worker.count](#ngxworkercount)
2764+
* [ngx.worker.id](#ngxworkerid)
27372765
* [ndk.set_var.DIRECTIVE](#ndkset_vardirective)
27382766
* [coroutine.create](#coroutinecreate)
27392767
* [coroutine.resume](#coroutineresume)
@@ -2936,23 +2964,40 @@ HTTP status constants
29362964

29372965
```nginx
29382966
2967+
value = ngx.HTTP_CONTINUE (100) (first added in the v0.9.20 release)
2968+
value = ngx.HTTP_SWITCHING_PROTOCOLS (101) (first added in the v0.9.20 release)
29392969
value = ngx.HTTP_OK (200)
29402970
value = ngx.HTTP_CREATED (201)
2971+
value = ngx.HTTP_ACCEPTED (202) (first added in the v0.9.20 release)
2972+
value = ngx.HTTP_NO_CONTENT (204) (first added in the v0.9.20 release)
2973+
value = ngx.HTTP_PARTIAL_CONTENT (206) (first added in the v0.9.20 release)
29412974
value = ngx.HTTP_SPECIAL_RESPONSE (300)
29422975
value = ngx.HTTP_MOVED_PERMANENTLY (301)
29432976
value = ngx.HTTP_MOVED_TEMPORARILY (302)
29442977
value = ngx.HTTP_SEE_OTHER (303)
29452978
value = ngx.HTTP_NOT_MODIFIED (304)
2979+
value = ngx.HTTP_TEMPORARY_REDIRECT (307) (first added in the v0.9.20 release)
29462980
value = ngx.HTTP_BAD_REQUEST (400)
29472981
value = ngx.HTTP_UNAUTHORIZED (401)
2982+
value = ngx.HTTP_PAYMENT_REQUIRED (402) (first added in the v0.9.20 release)
29482983
value = ngx.HTTP_FORBIDDEN (403)
29492984
value = ngx.HTTP_NOT_FOUND (404)
29502985
value = ngx.HTTP_NOT_ALLOWED (405)
2986+
value = ngx.HTTP_NOT_ACCEPTABLE (406) (first added in the v0.9.20 release)
2987+
value = ngx.HTTP_REQUEST_TIMEOUT (408) (first added in the v0.9.20 release)
2988+
value = ngx.HTTP_CONFLICT (409) (first added in the v0.9.20 release)
29512989
value = ngx.HTTP_GONE (410)
2990+
value = ngx.HTTP_UPGRADE_REQUIRED (426) (first added in the v0.9.20 release)
2991+
value = ngx.HTTP_TOO_MANY_REQUESTS (429) (first added in the v0.9.20 release)
2992+
value = ngx.HTTP_CLOSE (444) (first added in the v0.9.20 release)
2993+
value = ngx.HTTP_ILLEGAL (451) (first added in the v0.9.20 release)
29522994
value = ngx.HTTP_INTERNAL_SERVER_ERROR (500)
29532995
value = ngx.HTTP_METHOD_NOT_IMPLEMENTED (501)
2996+
value = ngx.HTTP_BAD_GATEWAY (502) (first added in the v0.9.20 release)
29542997
value = ngx.HTTP_SERVICE_UNAVAILABLE (503)
29552998
value = ngx.HTTP_GATEWAY_TIMEOUT (504) (first added in the v0.3.1rc38 release)
2999+
value = ngx.HTTP_VERSION_NOT_SUPPORTED (505) (first added in the v0.9.20 release)
3000+
value = ngx.HTTP_INSUFFICIENT_STORAGE (507) (first added in the v0.9.20 release)
29563001
```
29573002

29583003
[Back to TOC](#nginx-api-for-lua)
@@ -3114,7 +3159,7 @@ ngx.location.capture
31143159

31153160
**context:** *rewrite_by_lua*, access_by_lua*, content_by_lua**
31163161

3117-
Issue a synchronous but still non-blocking *Nginx Subrequest* using `uri`.
3162+
Issues a synchronous but still non-blocking *Nginx Subrequest* using `uri`.
31183163

31193164
Nginx's subrequests provide a powerful way to make non-blocking internal requests to other locations configured with disk file directory or *any* other nginx C modules like `ngx_proxy`, `ngx_fastcgi`, `ngx_memc`,
31203165
`ngx_postgres`, `ngx_drizzle`, and even ngx_lua itself and etc etc etc.
@@ -3125,6 +3170,9 @@ Subrequests are completely different from HTTP 301/302 redirection (via [ngx.red
31253170

31263171
You should always read the request body (by either calling [ngx.req.read_body](#ngxreqread_body) or configuring [lua_need_request_body](#lua_need_request_body) on) before initiating a subrequest.
31273172

3173+
This API function (as well as [ngx.location.capture_multi](#ngxlocationcapture_multi)) always buffers the whole response body of the subrequest in memory. Thus, you should use [cosockets](#ngxsockettcp)
3174+
and streaming processing instead if you have to handle large subrequest responses.
3175+
31283176
Here is a basic example:
31293177

31303178
```lua
@@ -3619,6 +3667,21 @@ This API was first introduced in the `v0.9.5` release.
36193667

36203668
[Back to TOC](#nginx-api-for-lua)
36213669

3670+
ngx.req.is_internal
3671+
-------------------
3672+
**syntax:** *is_internal = ngx.req.is_internal()*
3673+
3674+
**context:** *set_by_lua*, rewrite_by_lua*, access_by_lua*, content_by_lua*, header_filter_by_lua*, body_filter_by_lua*, log_by_lua**
3675+
3676+
Returns a boolean indicating whether the current request is an "internal request", i.e.,
3677+
a request initiated from inside the current nginx server instead of from the client side.
3678+
3679+
Subrequests are all internal requests and so are requests after internal redirects.
3680+
3681+
This API was first introduced in the `v0.9.20` release.
3682+
3683+
[Back to TOC](#nginx-api-for-lua)
3684+
36223685
ngx.req.start_time
36233686
------------------
36243687
**syntax:** *secs = ngx.req.start_time()*
@@ -5732,7 +5795,7 @@ Unconditionally sets a key-value pair into the shm-based dictionary [ngx.shared.
57325795

57335796
The `value` argument inserted can be Lua booleans, numbers, strings, or `nil`. Their value type will also be stored into the dictionary and the same data type can be retrieved later via the [get](#ngxshareddictget) method.
57345797

5735-
The optional `exptime` argument specifies expiration time (in seconds) for the inserted key-value pair. The time resolution is `0.001` seconds. If the `exptime` takes the value `0` (which is the default), then the item will never be expired.
5798+
The optional `exptime` argument specifies expiration time (in seconds) for the inserted key-value pair. The time resolution is `0.001` seconds. If the `exptime` takes the value `0` (which is the default), then the item will never expire.
57365799

57375800
The optional `flags` argument specifies a user flags value associated with the entry to be stored. It can also be retrieved later with the value. The user flags is stored as an unsigned 32-bit integer internally. Defaults to `0`. The user flags argument was first introduced in the `v0.5.0rc2` release.
57385801

@@ -6976,6 +7039,30 @@ This API was first introduced in the `v0.8.0` release.
69767039

69777040
[Back to TOC](#nginx-api-for-lua)
69787041

7042+
ngx.timer.running_count
7043+
-----------------------
7044+
**syntax:** *count = ngx.timer.running_count()*
7045+
7046+
**context:** *init_worker_by_lua*, set_by_lua*, rewrite_by_lua*, access_by_lua*, content_by_lua*, header_filter_by_lua*, body_filter_by_lua*, log_by_lua*, ngx.timer.**
7047+
7048+
Returns the number of timers currently running.
7049+
7050+
This directive was first introduced in the `v0.9.20` release.
7051+
7052+
[Back to TOC](#nginx-api-for-lua)
7053+
7054+
ngx.timer.pending_count
7055+
-----------------------
7056+
**syntax:** *count = ngx.timer.pending_count()*
7057+
7058+
**context:** *init_worker_by_lua*, set_by_lua*, rewrite_by_lua*, access_by_lua*, content_by_lua*, header_filter_by_lua*, body_filter_by_lua*, log_by_lua*, ngx.timer.**
7059+
7060+
Returns the number of pending timers.
7061+
7062+
This directive was first introduced in the `v0.9.20` release.
7063+
7064+
[Back to TOC](#nginx-api-for-lua)
7065+
69797066
ngx.config.debug
69807067
----------------
69817068
**syntax:** *debug = ngx.config.debug*
@@ -7066,6 +7153,42 @@ This API was first introduced in the `0.9.5` release.
70667153

70677154
[Back to TOC](#nginx-api-for-lua)
70687155

7156+
ngx.worker.count
7157+
----------------
7158+
7159+
**syntax:** *count = ngx.worker.count()*
7160+
7161+
**context:** *set_by_lua*, rewrite_by_lua*, access_by_lua*, content_by_lua*, header_filter_by_lua*, body_filter_by_lua*, log_by_lua*, ngx.timer.*, init_by_lua**
7162+
7163+
Returns the total number of the Nginx worker processes (i.e., the value configured
7164+
by the [worker_processes](http://nginx.org/en/docs/ngx_core_module.html#worker_processes)
7165+
directive in `nginx.conf`).
7166+
7167+
This API was first introduced in the `0.9.20` release.
7168+
7169+
[Back to TOC](#nginx-api-for-lua)
7170+
7171+
ngx.worker.id
7172+
-------------
7173+
7174+
**syntax:** *count = ngx.worker.id()*
7175+
7176+
**context:** *set_by_lua*, rewrite_by_lua*, access_by_lua*, content_by_lua*, header_filter_by_lua*, body_filter_by_lua*, log_by_lua*, ngx.timer.*, init_by_lua**
7177+
7178+
Returns the ordinal number of the current Nginx worker processes (starting from number 0).
7179+
7180+
So if the total number of workers is `N`, then this method may return a number between 0
7181+
and `N - 1` (inclusive).
7182+
7183+
This function returns meaningful values only for NGINX 1.9.1+. With earlier versions of NGINX, it
7184+
always returns `nil`.
7185+
7186+
See also [ngx.worker.count](#ngxworkercount).
7187+
7188+
This API was first introduced in the `0.9.20` release.
7189+
7190+
[Back to TOC](#nginx-api-for-lua)
7191+
70697192
ndk.set_var.DIRECTIVE
70707193
---------------------
70717194
**syntax:** *res = ndk.set_var.DIRECTIVE_NAME*

0 commit comments

Comments
 (0)