You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.markdown
+64-55Lines changed: 64 additions & 55 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -53,7 +53,7 @@ Table of Contents
53
53
Status
54
54
======
55
55
56
-
This module is under active development and is production ready.
56
+
Production ready.
57
57
58
58
Version
59
59
=======
@@ -312,8 +312,8 @@ The [ngx_openresty bundle](http://openresty.org) can be used to install Nginx, n
312
312
Alternatively, ngx_lua can be manually compiled into Nginx:
313
313
314
314
1. Install LuaJIT 2.0 or 2.1 (recommended) or Lua 5.1 (Lua 5.2 is *not* supported yet). LuaJIT can be downloaded from the [the LuaJIT project website](http://luajit.org/download.html) and Lua 5.1, from the [Lua project website](http://www.lua.org/). Some distribution package managers also distribute LuajIT and/or Lua.
315
-
1. Download the latest version of the ngx_devel_kit (NDK) module [HERE](http://github.com/simpl/ngx_devel_kit/tags).
316
-
1. Download the latest version of ngx_lua [HERE](http://github.com/openresty/lua-nginx-module/tags).
315
+
1. Download the latest version of the ngx_devel_kit (NDK) module [HERE](https://github.com/simpl/ngx_devel_kit/tags).
316
+
1. Download the latest version of ngx_lua [HERE](https://github.com/openresty/lua-nginx-module/tags).
317
317
1. Download the latest version of Nginx [HERE](http://nginx.org/) (See [Nginx Compatibility](#nginx-compatibility))
318
318
319
319
Build the source with this module:
@@ -412,7 +412,7 @@ The [openresty](https://groups.google.com/group/openresty) mailing list is for C
412
412
Code Repository
413
413
===============
414
414
415
-
The code repository of this project is hosted on github at [openresty/lua-nginx-module](http://github.com/openresty/lua-nginx-module).
415
+
The code repository of this project is hosted on github at [openresty/lua-nginx-module](https://github.com/openresty/lua-nginx-module).
416
416
417
417
[Back to TOC](#table-of-contents)
418
418
@@ -881,22 +881,22 @@ The following dependencies are required to run the test suite:
Does an internal redirect to `uri` with `args` and is similar to the [echo_exec](http://github.com/openresty/echo-nginx-module#echo_exec) directive of the [echo-nginx-module](http://github.com/openresty/echo-nginx-module).
Named locations are also supported (but the second `args` argument is currently ignored). For example,
4136
-
4137
-
```nginx
4138
-
4139
-
location /foo {
4140
-
content_by_lua '
4141
-
ngx.exec("@bar");
4142
-
';
4143
-
}
4144
-
4145
-
location @bar {
4146
-
...
4147
-
}
4148
-
```
4149
-
4150
4136
The optional second `args` can be used to specify extra URI query arguments, for example:
4151
4137
4152
4138
```lua
@@ -4161,19 +4147,41 @@ Alternatively, a Lua table can be passed for the `args` argument for ngx_lua to
4161
4147
ngx.exec("/foo", { a=3, b="hello world" })
4162
4148
```
4163
4149
4164
-
The result is exactly the same as the previous example. The format for the Lua table passed as the `args` argument is identical to the format used in the [ngx.encode_args](#ngxencode_args) method.
4150
+
The result is exactly the same as the previous example.
4165
4151
4166
-
Note that this is very different from [ngx.redirect](#ngxredirect) in that
4167
-
it is just an internal redirect and no new HTTP traffic is involved.
4152
+
The format for the Lua table passed as the `args` argument is identical to the format used in the [ngx.encode_args](#ngxencode_args) method.
4168
4153
4169
-
This method never returns.
4154
+
Named locations are also supported but the second `args` argument will be ignored if present and the querystring for the new target is inherited from the referring location (if any).
4170
4155
4171
-
This method *must* be called before [ngx.send_headers](#ngxsend_headers) or explicit response body
4172
-
outputs by either [ngx.print](#ngxprint) or [ngx.say](#ngxsay).
4156
+
`GET /foo/file.php?a=hello` will return "hello" and not "goodbye" in the example below
4157
+
4158
+
```nginx
4159
+
4160
+
location /foo {
4161
+
content_by_lua '
4162
+
ngx.exec("@bar", "a=goodbye");
4163
+
';
4164
+
}
4165
+
4166
+
location @bar {
4167
+
content_by_lua '
4168
+
local args = ngx.req.get_uri_args()
4169
+
for key, val in pairs(args) do
4170
+
if key == "a" then
4171
+
ngx.say(val)
4172
+
end
4173
+
end
4174
+
';
4175
+
}
4176
+
```
4173
4177
4174
-
It is strongly recommended to combine the `return` statement with this call, i.e., `return ngx.exec(...)`.
4178
+
Note that the `ngx.exec` method is different from [ngx.redirect](#ngxredirect) in that
4179
+
it is purely an internal redirect and that no new external HTTP traffic is involved.
4175
4180
4176
-
This method is similar to the [echo_exec](http://github.com/openresty/echo-nginx-module#echo_exec) directive of the [echo-nginx-module](http://github.com/openresty/echo-nginx-module).
4181
+
Also note that this method call terminates the processing of the current request and that it *must* be called before [ngx.send_headers](#ngxsend_headers) or explicit response body
4182
+
outputs by either [ngx.print](#ngxprint) or [ngx.say](#ngxsay).
4183
+
4184
+
It is recommended that a coding style that combines this method call with the `return` statement, i.e., `return ngx.exec(...)` be adopted when this method call is used in contexts other than [header_filter_by_lua](#header_filter_by_lua) to reinforce the fact that the request processing is being terminated.
4177
4185
4178
4186
[Back to TOC](#nginx-api-for-lua)
4179
4187
@@ -4188,7 +4196,7 @@ Issue an `HTTP 301` or `302` redirection to `uri`.
4188
4196
The optional `status` parameter specifies whether
4189
4197
`301` or `302` to be used. It is `302` (`ngx.HTTP_MOVED_TEMPORARILY`) by default.
4190
4198
4191
-
Here is an example assuming the current server name is `localhost` and that it is listening on Port 1984:
4199
+
Here is an example assuming the current server name is `localhost` and that it is listening on port 1984:
4192
4200
4193
4201
```lua
4194
4202
@@ -4216,9 +4224,7 @@ We can also use the numerical code directly as the second `status` argument:
4216
4224
returnngx.redirect("/foo", 301)
4217
4225
```
4218
4226
4219
-
This method *must* be called before [ngx.send_headers](#ngxsend_headers) or explicit response body outputs by either [ngx.print](#ngxprint) or [ngx.say](#ngxsay).
4220
-
4221
-
This method is very much like the [rewrite](http://nginx.org/en/docs/http/ngx_http_rewrite_module.html#rewrite) directive with the `redirect` modifier in the standard
4227
+
This method is similar to the [rewrite](http://nginx.org/en/docs/http/ngx_http_rewrite_module.html#rewrite) directive with the `redirect` modifier in the standard
4222
4228
[[HttpRewriteModule]], for example, this `nginx.conf` snippet
4223
4229
4224
4230
```nginx
@@ -4254,7 +4260,10 @@ URI arguments can be specified as well, for example:
4254
4260
returnngx.redirect('/foo?a=3&b=4')
4255
4261
```
4256
4262
4257
-
This method call terminates the current request's processing and never returns. It is recommended to combine the `return` statement with this call, i.e., `return ngx.redirect(...)`, so as to be more explicit.
4263
+
Note that this method call terminates the processing of the current request and that it *must* be called before [ngx.send_headers](#ngxsend_headers) or explicit response body
4264
+
outputs by either [ngx.print](#ngxprint) or [ngx.say](#ngxsay).
4265
+
4266
+
It is recommended that a coding style that combines this method call with the `return` statement, i.e., `return ngx.redirect(...)` be adopted when this method call is used in contexts other than [header_filter_by_lua](#header_filter_by_lua) to reinforce the fact that the request processing is being terminated.
4258
4267
4259
4268
[Back to TOC](#nginx-api-for-lua)
4260
4269
@@ -4419,9 +4428,9 @@ ngx.exit(501)
4419
4428
4420
4429
Note that while this method accepts all [HTTP status constants](#http-status-constants) as input, it only accepts `NGX_OK` and `NGX_ERROR` of the [core constants](#core-constants).
4421
4430
4422
-
It is recommended, though not necessary (for contexts other than [header_filter_by_lua](#header_filter_by_lua)), to combine the `return` statement with this call, i.e., `return ngx.exit(...)`, to give a visual hint to others reading the code.
4431
+
Also note that this method call terminates the processing of the current request and that it is recommended that a coding style that combines this method call with the `return` statement, i.e., `return ngx.exit(...)` be used to reinforce the fact that the request processing is being terminated.
4423
4432
4424
-
When being used in the context of [header_filter_by_lua](#header_filter_by_lua), `ngx.exit()` is an asynchronous operation and will return immediately. This behavior might change in the future. So always use `return`at the same time, as suggested above.
4433
+
When being used in the context of [header_filter_by_lua](#header_filter_by_lua), `ngx.exit()` is an asynchronous operation and will return immediately. This behavior may change in future and it is recommended that users always use `return`in combination as suggested above.
0 commit comments