Skip to content

Commit b2c2c2a

Browse files
committed
doc: fixed a number of typos, grammar, and styling issues, and mentioned that we support NGINX 1.17.x.
1 parent 5a97cce commit b2c2c2a

File tree

1 file changed

+31
-27
lines changed

1 file changed

+31
-27
lines changed

README.md

+31-27
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ Table of Contents
3232
Status
3333
======
3434

35-
Producty ready.
35+
Production ready.
3636

3737
Synopsis
3838
========
@@ -107,7 +107,7 @@ This module is a core component of OpenResty. If you are using this module, then
107107
This is a port of the [ngx_http_lua_module](https://github.com/openresty/lua-nginx-module#readme) to the NGINX "stream" subsystem so
108108
as to support generic stream/TCP clients in the downstream.
109109

110-
Lua APIs and directive names rename the same as the `ngx_http_lua_module`.
110+
Lua APIs and directive names remain the same as the `ngx_http_lua_module`.
111111

112112
[Back to TOC](#table-of-contents)
113113

@@ -176,9 +176,9 @@ Acts as a `preread` phase handler and executes Lua code string specified in `lua
176176
(or packet in datagram mode).
177177
The Lua code may make [API calls](#nginx-api-for-lua) and is executed as a new spawned coroutine in an independent global environment (i.e. a sandbox).
178178

179-
It is possible to acquire raw request socket using [ngx.req.socket](https://github.com/openresty/lua-nginx-module#ngxreqsocket)
179+
It is possible to acquire the raw request socket using [ngx.req.socket](https://github.com/openresty/lua-nginx-module#ngxreqsocket)
180180
and receive data from or send data to the client. However, keep in mind that calling the `receive()` method
181-
of the request socket will consume the data from the buffer and those data will not be seen by handlers
181+
of the request socket will consume the data from the buffer and such consumed data will not be seen by handlers
182182
further down the chain.
183183

184184
The `preread_by_lua_block` code will always run at the end of the `preread` processing phase unless
@@ -189,7 +189,7 @@ This directive was first introduced in the `v0.0.3` release.
189189
[Back to TOC](#directives)
190190

191191
preread_by_lua_file
192-
--------------------
192+
-------------------
193193

194194
**syntax:** *preread_by_lua_file <path-to-lua-script-file>*
195195

@@ -202,33 +202,33 @@ or LuaJIT bytecode to be executed.
202202

203203
Nginx variables can be used in the `<path-to-lua-script-file>` string to provide flexibility. This however carries some risks and is not ordinarily recommended.
204204

205-
When a relative path like `foo/bar.lua` is given, they will be turned into the absolute path relative to the `server prefix` path determined by the `-p PATH` command-line option while starting the Nginx server.
205+
When a relative path like `foo/bar.lua` is given, it will be turned into the absolute path relative to the `server prefix` path determined by the `-p PATH` command-line option given when starting the Nginx server.
206206

207-
When the Lua code cache is turned on (by default), the user code is loaded once at the first request and cached and the Nginx config must be reloaded each time the Lua source file is modified. The Lua code cache can be temporarily disabled during development by switching [lua_code_cache](#lua_code_cache) `off` in `nginx.conf` to avoid reloading Nginx.
207+
When the Lua code cache is turned on (by default), the user code is loaded once at the first connection and cached. The Nginx config must be reloaded each time the Lua source file is modified. The Lua code cache can be temporarily disabled during development by switching [lua_code_cache](#lua_code_cache) `off` in `nginx.conf` to avoid having to reload Nginx.
208208

209209
This directive was first introduced in the `v0.0.3` release.
210210

211211
[Back to TOC](#directives)
212212

213213
log_by_lua_block
214-
--------------------
214+
----------------
215215

216216
**syntax:** *log_by_lua_block { lua-script }*
217217

218218
**context:** *stream, server*
219219

220220
**phase:** *log*
221221

222-
Runs the Lua source code inlined as the `<lua-script-str>` at the `log` request processing phase. This does not replace the current access logs, but runs before.
222+
Runs the Lua source code specified as `<lua-script>` during the `log` request processing phase. This does not replace the current access logs, but runs before.
223223

224-
Yielding APIs in this phase, such as `ngx.req.socket`, `ngx.socket.*`, `ngx.sleep`, `ngx.say` are **not** available in this phase.
224+
Yielding APIs such as `ngx.req.socket`, `ngx.socket.*`, `ngx.sleep`, or `ngx.say` are **not** available in this phase.
225225

226226
This directive was first introduced in the `v0.0.3` release.
227227

228228
[Back to TOC](#directives)
229229

230230
log_by_lua_file
231-
--------------------
231+
---------------
232232

233233
**syntax:** *log_by_lua_file &lt;path-to-lua-script-file&gt;*
234234

@@ -241,9 +241,9 @@ or LuaJIT bytecode to be executed.
241241

242242
Nginx variables can be used in the `<path-to-lua-script-file>` string to provide flexibility. This however carries some risks and is not ordinarily recommended.
243243

244-
When a relative path like `foo/bar.lua` is given, they will be turned into the absolute path relative to the `server prefix` path determined by the `-p PATH` command-line option while starting the Nginx server.
244+
When a relative path like `foo/bar.lua` is given, it will be turned into the absolute path relative to the `server prefix` path determined by the `-p PATH` command-line option given when starting the Nginx server.
245245

246-
When the Lua code cache is turned on (by default), the user code is loaded once at the first request and cached and the Nginx config must be reloaded each time the Lua source file is modified. The Lua code cache can be temporarily disabled during development by switching [lua_code_cache](#lua_code_cache) `off` in `nginx.conf` to avoid reloading Nginx.
246+
When the Lua code cache is turned on (by default), the user code is loaded once at the first connection and cached. The Nginx config must be reloaded each time the Lua source file is modified. The Lua code cache can be temporarily disabled during development by switching [lua_code_cache](#lua_code_cache) `off` in `nginx.conf` to avoid having to reload Nginx.
247247

248248
This directive was first introduced in the `v0.0.3` release.
249249

@@ -256,11 +256,11 @@ lua_add_variable
256256

257257
**context:** *stream*
258258

259-
Add variable `$var` to the stream subsystem and makes it changeable. If `$var` already exists,
259+
Add the variable `$var` to the stream subsystem and makes it changeable. If `$var` already exists,
260260
this directive will do nothing.
261261

262262
By default, variables added using this directive are considered "not found" and reading them
263-
using `ngx.var` will return `nil`. However, they could be re-assigned using `ngx.var` code at any time.
263+
using `ngx.var` will return `nil`. However, they could be re-assigned via the `ngx.var.VARIABLE` API at any time.
264264

265265
This directive was first introduced in the `v0.0.4` release.
266266

@@ -308,16 +308,17 @@ is ignored and the raw request socket is always returned. Unlike `ngx_http_lua_m
308308
you can still call output API functions like `ngx.say`, `ngx.print`, and `ngx.flush`
309309
after acquiring the raw request socket via this function.
310310

311-
When stream server is in UDP mode, reading from the downstream socket returned by the
311+
When the stream server is in UDP mode, reading from the downstream socket returned by the
312312
`ngx.req.socket` call will only return the content of a single packet. Therefore
313313
the reading call will never block and will return `nil, "no more data"` when all the
314314
data from the datagram has been consumed. However, you may choose to send multiple UDP
315315
packets back to the client using the downstream socket.
316316

317-
Raw TCP request socket returned by this module will contain the following extra method:
317+
The raw TCP sockets returned by this module will contain the following extra method:
318318

319319
tcpsock:shutdown
320320
----------------
321+
321322
**syntax:** *ok, err = tcpsock:shutdown("send")*
322323

323324
**context:** *content_by_lua&#42;*
@@ -333,15 +334,15 @@ before calling this method, consider use `ngx.flush(true)` to make sure all busy
333334
flushed before shutting down the socket. If any busy buffers were detected, this method will return `nil`
334335
will error message `"socket busy writing"`.
335336

336-
This feature is particularly useful for protocols that generates response before actually
337-
finishes consuming all incoming data. Normally Kernel will send out RST to the client when
337+
This feature is particularly useful for protocols that generate a response before actually
338+
finishing consuming all incoming data. Normally, the kernel will send RST to the client when
338339
[tcpsock:close](https://github.com/openresty/lua-nginx-module#tcpsockclose) is called without
339340
emptying the receiving buffer first. Calling this method will allow you to keep reading from
340341
the receiving buffer and prevents RST from being sent.
341342

342343
You can also use this method to simulate lingering close similar to that
343344
[provided by the ngx_http_core_module](https://nginx.org/en/docs/http/ngx_http_core_module.html#lingering_close)
344-
for protocols that needs such behavior. Here is an example:
345+
for protocols in need of such behavior. Here is an example:
345346

346347
```lua
347348
local LINGERING_TIME = 30 -- 30 seconds
@@ -366,19 +367,20 @@ until (not data and not partial) or ngx.time() >= deadline
366367

367368
reqsock:peek
368369
------------
370+
369371
**syntax:** *ok, err = reqsock:peek(size)*
370372

371373
**context:** *preread_by_lua&#42;*
372374

373375
Peeks into the [preread](https://nginx.org/en/docs/stream/stream_processing.html#preread_phase)
374376
buffer that contains downstream data sent by the client without consuming them.
375-
That is, data returned by this API will still be forwarded to upstream in later phases.
377+
That is, data returned by this API will still be forwarded upstream in later phases.
376378

377379
This function takes a single required argument, `size`, which is the number of bytes to be peeked.
378380
Repeated calls to this function always returns data from the beginning of the preread buffer.
379381

380-
Note that preread phase happens after TLS handshake. If the stream server was configured with
381-
TLS enabled, data returned will be in clear text.
382+
Note that preread phase happens after the TLS handshake. If the stream server was configured with
383+
TLS enabled, the returned data will be in clear text.
382384

383385
If preread buffer does not have the requested amount of data, then the current Lua thread will
384386
be yielded until more data is available, [`preread_buffer_size`](https://nginx.org/en/docs/stream/ngx_stream_core_module.html#preread_buffer_size)
@@ -398,9 +400,9 @@ the current stream session will be terminated with the
398400
In both cases, no further processing on the session is possible (except `log_by_lua*`). The connection will be closed by the
399401
stream core module automatically.
400402

401-
Note that this API can not be used if consumption of client data has occurred. For example, after calling
402-
`reqsock:receive`. If such attempt was made, Lua error `"attempt to peek on a consumed socket"` will
403-
be thrown. Consuming client data after calling this API safe and allowed.
403+
Note that this API cannot be used if consumption of client data has occurred. For example, after calling
404+
`reqsock:receive`. If such an attempt was made, the Lua error `"attempt to peek on a consumed socket"` will
405+
be thrown. Consuming client data after calling this API is allowed and safe.
404406

405407
Here is an example of using this API:
406408

@@ -503,7 +505,9 @@ Nginx Compatibility
503505

504506
The latest version of this module is compatible with the following versions of Nginx:
505507

506-
* 1.13.x >= 1.13.6
508+
* 1.17.x (last tested: 1.17.1)
509+
* 1.15.x (last tested: 1.15.8)
510+
* 1.13.x (last tested: 1.13.6)
507511

508512
Nginx cores older than 1.13.6 (exclusive) are *not* tested and may or may not work. Use at your own risk!
509513

0 commit comments

Comments
 (0)