Skip to content
This repository was archived by the owner on Jan 11, 2025. It is now read-only.

Commit 14f5160

Browse files
linted
1 parent 878143d commit 14f5160

File tree

6 files changed

+52
-29
lines changed

6 files changed

+52
-29
lines changed

.github/linters/.ecrc

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"Exclude": [
3+
"docs/lua-nginx-module/DIRECTIVES.md",
34
"docs/lua-nginx-module/known-issues.md",
45
"docs/lua-nginx-module/nginx-api-for-lua.md"
56
]

README.md

+2-3
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ Lua is a lightweight, high-level, multi-paradigm programming language designed p
6161

6262
| | nginx-lua | OpenResty |
6363
|--|--|--|
64-
| nginx latest version | `1.21.0` | `1.19.x` (last tested: `1.19.9`)<sup>*</sup> |
64+
| nginx latest version | `1.21.0` | `1.19.x` (last tested: `1.19.9`)¹ |
6565
| Alpine supported |||
6666
| Amazon supported |||
6767
| CentOS supported |||
@@ -70,7 +70,7 @@ Lua is a lightweight, high-level, multi-paradigm programming language designed p
7070
| Ubuntu supported |||
7171
| Windows supported |||
7272

73-
<sup>*</sup> Note: Between OpenResty compatibility for `1.17.4` (28 Sep 2019) and `1.19.3` (3 Nov 2020) have passed ~10 months, and nginx 1.19.3 has been released on 29 Sep 2020.
73+
¹ Note: Between OpenResty compatibility for `1.17.4` (28 Sep 2019) and `1.19.3` (3 Nov 2020) have passed ~10 months, and nginx 1.19.3 has been released on 29 Sep 2020.
7474

7575
## Features
7676

@@ -642,7 +642,6 @@ As for any pre-built image usage, it is the image user's responsibility to ensur
642642
- [Lua License](https://www.lua.org/license.html)
643643
- [OpenResty License](https://github.com/openresty/openresty#copyright--license)
644644

645-
646645
[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Ffabiocicerchia%2Fnginx-lua.svg?type=large)](https://app.fossa.com/projects/git%2Bgithub.com%2Ffabiocicerchia%2Fnginx-lua?ref=badge_large)
647646

648647
### `fabiocicerchia/nginx-lua`

bin/generate-supported-versions.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ fetch_latest() {
2828
set -eux
2929

3030
DISTRO=nginx
31-
VER_NGINX=$(wget -q https://registry.hub.docker.com/v1/repositories/$DISTRO/tags -O - | sed -e 's/[][]//g' -e 's/"//g' -e 's/ //g' | tr '}' '\n' | cut -d: -f3 | grep -E "[0-9]+\.[0-9]+\.[0-9]+" | grep -E -v "alpine|perl" | sort -Vr | head -n 1)
31+
VER_NGINX=$(wget -q https://registry.hub.docker.com/v1/repositories/$DISTRO/tags -O - | sed -e 's/[][]//g' -e 's/"//g' -e 's/ //g' | tr '}' '\n' | cut -d: -f3 | grep -E "[0-9]+\.[0-9]+\.[0-9]+" | grep -E -v "alpine|perl" | sort -Vr | head -n 1)
3232
NGINX=()
3333
for VER in $VER_NGINX; do
3434
NGINX+=("$VER")

bin/update-readme.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22

33
head -n "$(grep -n START_SUPPORTED_TAGS README.md | cut -d: -f1)" README.md >README.md.tmp
44
./bin/readme-tags.sh >>README.md.tmp
5-
tail -n "$(($(wc -l <README.md) - $(grep -n END_SUPPORTED_TAGS README.md | cut -d: -f1)+1))" README.md >>README.md.tmp
5+
tail -n "$(($(wc -l <README.md) - $(grep -n END_SUPPORTED_TAGS README.md | cut -d: -f1) + 1))" README.md >>README.md.tmp
66
mv README.md.tmp README.md

docs/examples/docker-compose.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
web:
55
image: fabiocicerchia/ginx-lua
66
volumes:
7-
- ./templates:/etc/nginx/templates
7+
- ./templates:/etc/nginx/templates
88
ports:
9-
- "8080:80"
9+
- "8080:80"
1010
environment:
11-
- NGINX_HOST=foobar.com
12-
- NGINX_PORT=80
11+
- NGINX_HOST=foobar.com
12+
- NGINX_PORT=80
1313
```

docs/examples/lua-nginx-module.md

+43-20
Original file line numberDiff line numberDiff line change
@@ -91,26 +91,49 @@ server {
9191
}
9292
9393
location / {
94-
client_max_body_size 100k;
95-
client_body_buffer_size 100k;
96-
97-
access_by_lua_block {
98-
-- check the client IP address is in our black list
99-
if ngx.var.remote_addr == "132.5.72.3" then
100-
ngx.exit(ngx.HTTP_FORBIDDEN)
101-
end
102-
103-
-- check if the URI contains bad words
104-
if ngx.var.uri and
105-
string.match(ngx.var.request_body, "evil")
106-
then
107-
return ngx.redirect("/terms_of_use.html")
108-
end
109-
110-
-- tests passed
111-
}
112-
113-
# proxy_pass/fastcgi_pass/etc settings
94+
client_max_body_size 100k;
95+
client_body_buffer_size 100k;
96+
97+
access_by_lua_block {
98+
-- check the client IP address is in our black list
99+
if ngx.var.remote_addr == "132.5.72.3" then
100+
ngx.exit(ngx.HTTP_FORBIDDEN)
101+
end
102+
103+
-- body may get buffered in a temp file:
104+
local file = ngx.req.get_body_file()
105+
if file then
106+
ngx.say("body is in file ", file)
107+
else
108+
ngx.say("no body found")
109+
end
110+
}
111+
}
112+
113+
# transparent non-blocking I/O in Lua via subrequests
114+
# (well, a better way is to use cosockets)
115+
location = /lua {
116+
# MIME type determined by default_type:
117+
default_type 'text/plain';
118+
119+
content_by_lua_block {
120+
local res = ngx.location.capture("/some_other_location")
121+
if res then
122+
ngx.say("status: ", res.status)
123+
ngx.say("body:")
124+
ngx.print(res.body)
125+
end
126+
}
127+
}
128+
129+
location = /foo {
130+
rewrite_by_lua_block {
131+
res = ngx.location.capture("/memc",
132+
{ args = { cmd = "incr", key = ngx.var.uri } }
133+
)
134+
}
135+
136+
# proxy_pass/fastcgi_pass/etc settings
114137
}
115138
}
116139
```

0 commit comments

Comments
 (0)