Skip to content

Commit d4c0588

Browse files
committed
Release 0.1-1: Update Rockspec and Documentation
1 parent ccd2926 commit d4c0588

File tree

6 files changed

+108
-45
lines changed

6 files changed

+108
-45
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
.vscode
1+
.vscode
2+
*.rock

README.md

Lines changed: 75 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,86 @@
11
# Lua Resty Whitelist
22

3-
Dynamic whitelist in Lua based on ngx_lua for NGINX and OpenResty
3+
This module can be used to implement a dynamic whitelist in NGINX/OpenResty. This is especially useful to allow access only to some SaaS and Cloud services with dynamic IP addresses, such as Cloudflare, AWS, Azure, etc. For example, some of them may offer security features such as DDOS protection, WAF, etc. but can be bypassed if the origin IP is leaked and the server allows access from any IP address.
4+
The module accepts any format of the whitelist (e.g JSON, YAML, plain text, etc.) as long as they contain IPs and/or CIDRs.
45

5-
:warning: Under construction
6+
:warning: This project is still in beta. Use at your own risk.
67

7-
## Publish to LuaRocks
8+
## How to use
89

9-
```sh
10-
# Upload to LuaRocks
11-
luarocks upload lua-resty-whitelist-*.rockspec
10+
Installation:
11+
12+
```bash
13+
luarocks install lua-resty-whitelist
14+
```
15+
16+
Use it in your nginx configuration:
17+
18+
```nginx
19+
server {
20+
listen 80;
21+
server_name localhost;
22+
23+
# This is required for the module to make HTTP requests, you can use any DNS server
24+
resolver 1.1.1.1 ipv6=off;
25+
26+
location / {
27+
lua_code_cache on;
28+
access_by_lua_block {
29+
local whitelist = require "resty.whitelist"
30+
31+
local whitelist_urls = {
32+
"https://www.cloudflare.com/ips-v4", "https://d7uri8nf7uskq.cloudfront.net/tools/list-cloudfront-ips"
33+
}
34+
whitelist.new(whitelist_urls)
35+
36+
-- Or sinlge URL
37+
38+
local whitelist_url = "https://www.cloudflare.com/ips-v4"
39+
whitelist.new(whitelist_url)
40+
}
41+
}
42+
}
43+
```
1244

13-
# Create a source rock
14-
luarocks pack lua-resty-whitelist-*.rockspec
45+
## What's missing
46+
47+
- IPv6 support
48+
- Caching of the whitelist and sharing it between workers
49+
- Tests
50+
- Better error handling and logging
51+
- Better documentation
52+
53+
## Contrubuting
54+
55+
### Publish the package
56+
57+
#### Publish to LuaRocks
58+
59+
```bash
60+
mv lua-resty-whitelist-*.rockspec lua-resty-whitelist-X.Y-Z.rockspec
61+
sed -i -E 's/"([0-9]+\.[0-9]+-[0-9]+)"/"X.Y-Z"/g' lua-resty-whitelist-X.Y-Z.rockspec
62+
63+
git add .
64+
git commit -m "Release X.Y-Z"
65+
git push
66+
67+
git tag vX.Y-Z
68+
git push origin vX.Y-Z
69+
70+
luarocks upload lua-resty-whitelist-X.Y-Z.rockspec
1571
```
1672

17-
## Running the demo
73+
#### Publish to GitHub
74+
75+
- A `lua-resty-whitelist-X.Y-Z.src.rock` file will be created in the current directory after publishing to LuaRocks
76+
- Visit <https://github.com/esidate/lua-resty-whitelist/tags> and click on the tag `vX.Y-Z`
77+
- Click on "Create release from tag"
78+
- Click on "Generate release notes" and upload the `lua-resty-whitelist-X.Y-Z.src.rock` file
79+
- Publish the release
80+
81+
### Running the demo
82+
83+
The demo is also sort of the development environment.
1884

1985
```sh
2086
cd demo

demo/default.conf

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ server {
44
listen 80;
55
server_name localhost;
66

7+
# This is required for the module to make HTTP requests, you can use any DNS server
78
resolver 1.1.1.1 ipv6=off;
89

910
location / {
@@ -14,7 +15,7 @@ server {
1415
local whitelist_urls = {
1516
"http://172.18.0.1:9001/list-cloudfront-ips.json", "http://172.18.0.1:9001/list-cloudflare-ips.txt"
1617
}
17-
local whitelist = whitelist.new(whitelist_urls)
18+
whitelist.new(whitelist_urls)
1819
}
1920
}
2021
}

dist.ini

Lines changed: 0 additions & 9 deletions
This file was deleted.

lua-resty-whitelist-0.1-0.rockspec

Lines changed: 0 additions & 25 deletions
This file was deleted.

lua-resty-whitelist-0.1-1.rockspec

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package = "lua-resty-whitelist"
2+
version = "0.1-1"
3+
4+
source = {
5+
url = "git+https://github.com/esidate/lua-resty-whitelist",
6+
tag = "v0.1-0",
7+
}
8+
9+
description = {
10+
summary = "Dynamic whitelist in Lua based on ngx_lua for NGINX and OpenResty",
11+
detailed = "This module can be used to implement a dynamic whitelist in NGINX/OpenResty. This is especially useful to allow access only to some SaaS and Cloud services with dynamic IP addresses, such as Cloudflare, AWS, Azure, etc. For example, some of them may offer security features such as DDOS protection, WAF, etc. but can be bypassed if the origin IP is leaked and the server allows access from any IP address.",
12+
homepage = "https://github.com/esidate/lua-resty-whitelist",
13+
issues_url = "https://github.com/esidate/lua-resty-whitelist/issues",
14+
maintainer = "https://www.linkedin.com/in/el-mahdi-sidate/",
15+
license = "MIT",
16+
}
17+
18+
dependencies = {
19+
"lua >= 5.1",
20+
"resty.iputils >= 0.3",
21+
"resty.http >= 0.15",
22+
}
23+
24+
build = {
25+
type = "builtin",
26+
modules = {
27+
["resty.whitelist"] = "lib/resty/whitelist.lua",
28+
},
29+
}

0 commit comments

Comments
 (0)