Skip to content

Commit 67254cc

Browse files
committed
before merging master
1 parent c5c69d3 commit 67254cc

2 files changed

Lines changed: 91 additions & 2 deletions

File tree

Examples/Nginx/README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,9 @@ Update the configuration file relative to the location you want to be protected
6060
}
6161
```
6262

63-
- Replace the following two placeholders in the above code `{CUSTOMER_ID}` and `{SECRET_KEY}` with respective values located in GO Queue-it platform.
64-
- NOTE: In this example `rewrite_by_lua_block` directive was added to default location `/` but you must decide what makes sense in your case.
63+
Replace the following two placeholders in the above code `{CUSTOMER_ID}` and `{SECRET_KEY}` with respective values located in GO Queue-it platform.
64+
65+
NOTE: In this example `rewrite_by_lua_block` directive was added to default location `/` but you must decide what makes sense in your case.
6566

6667

6768
### 4) Provide the `integrationconfig.json`...

Examples/Nginx/README_new.md

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
# Nginx Lua Connector
2+
3+
## Implementation
4+
5+
NOTES:
6+
- The following implementation steps have been developed and tested using this [Docker image](https://github.com/fabiocicerchia/nginx-lua).
7+
- The following example uses `./usr/queueit` as the base path for storing all the Queue-it related files. Review and modify it to your needs.
8+
9+
10+
### 1. Copy the necessary files to your NGINX filesystem
11+
12+
Copy the following two folders from this repository to your NGINX filesystem:
13+
- [SDK](https://github.com/queueit/KnownUser.V3.Lua/tree/master/SDK) -> `./usr/queueit/SDK`
14+
- [Helpers](https://github.com/queueit/KnownUser.V3.Lua/tree/master/Helpers) -> `./usr/queueit/Helpers`
15+
16+
Copy the main handler script:
17+
18+
- [Handlers/KnownUserNginxHandler.lua](https://github.com/queueit/KnownUser.V3.Lua/blob/master/Handlers/KnownUserNginxHandler.lua) -> `./usr/queueit/KnownUserNginxHandler.lua`
19+
20+
21+
### 2. Update the package paths
22+
23+
Update or add the `lua_package_path` configuration option in the `http` section of your main configuration file (typically `nginx.conf`) to include the new paths you created in Step 1. Make sure to keep `;;` in the end which means default path:
24+
25+
```
26+
http {
27+
lua_package_path "./usr/queueit/?.lua;./usr/queueit/SDK/?.lua;./usr/queueit/Helpers/?/?.lua;;";
28+
}
29+
```
30+
31+
32+
### 3. Add the Queue-it handler to a specific location
33+
34+
Update the configuration file relative to the location you want to be protected by Queue-it (`conf.d/default.conf` or similar):
35+
36+
```
37+
server {
38+
location / {
39+
rewrite_by_lua_block {
40+
local customerId = "{CUSTOMER_ID}"
41+
local secretKey = "{SECRET_KEY}"
42+
43+
-- Basic example where integration configuration file is loaded from disk.
44+
-- You will need to decide where to store and load this file (caching layer, database ect.).
45+
-- Remember this will be done on all requests, so the selected option must be fast (not causing bottlenecks).
46+
local integrationConfigFilePath = "./usr/queueit/integrationconfig.json"
47+
local integrationConfigFile = io.open(integrationConfigFilePath, "r")
48+
local integrationConfigJson = integrationConfigFile:read("*a")
49+
integrationConfigFile:close()
50+
51+
local qit = require("KnownUserNginxHandler")
52+
53+
-- If you want to enable secure or http only cookie settings then change options below.
54+
-- httpOnly: Only enable if you use pure server-side integration e.g. not JS Hybrid.
55+
-- secure: Only enable if your website runs purely on https.
56+
qit.setOptions({ httpOnly = false, secure = false })
57+
58+
qit.handleByIntegrationConfig(customerId, secretKey, integrationConfigJson)
59+
}
60+
}
61+
```
62+
63+
Replace the following two placeholders in the above code `{CUSTOMER_ID}` and `{SECRET_KEY}` with respective values located in GO Queue-it platform.
64+
65+
NOTE: In this example `rewrite_by_lua_block` directive was added to default location `/` but you must decide what makes sense in your case.
66+
67+
68+
### 4) Provide the `integrationconfig.json`...
69+
70+
71+
72+
## Request body trigger (advanced)
73+
Nginx handler (incl. Lua SDK) supports triggering on request body content. Example could be a POST call with specific item ID where you want end-users to queue up for.
74+
You will need to contact queue-it support if this functionality is needed, so it can be enabled on your GO Queue-it platform account.
75+
When enabled you also need to add extra settings to `location` in `conf.d/default.conf`:
76+
77+
```
78+
location / {
79+
...
80+
# enabling reading of request body
81+
lua_need_request_body on;
82+
83+
# ensure large buffer for requst body (PLEASE DECIDE WHAT BUFFER SIZE IS RELEVANT IN YOUR CASE)
84+
client_body_buffer_size 64k;
85+
...
86+
}
87+
```
88+

0 commit comments

Comments
 (0)