Skip to content

Commit 569394d

Browse files
committed
Merge branch 'master' into nginx-docs
# Conflicts: # Examples/Nginx/README.md
2 parents 67254cc + 56705c3 commit 569394d

2 files changed

Lines changed: 37 additions & 57 deletions

File tree

Documentation/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@ Integration configuration contains valuable information like triggers and action
1616
2. You need to decorate the request by adding API key in the request header. You can get API key in the Go Queue-it self-service portal.
1717
3. Remember to add Host header in the request if your framework doesn't do that automatically. A missing host header will result in a 400 Bad Request response.
1818

19-
curl --request GET https://[your-customer-id].queue-it.net/status/integrationconfig/secure/[your-customer-id] --header 'api-key: [Customer API-Key]' --header 'Host: queue-it.net'
19+
curl --request GET https://[your-customer-id].queue-it.net/status/integrationconfig/secure/[your-customer-id] --header "api-key: [Customer API-Key]" --header "Host: queue-it.net"

Examples/Nginx/README.md

Lines changed: 36 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -2,74 +2,54 @@
22

33
## Implementation
44

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.
5+
NOTE: The following implementation steps have been developed and tested using this [Docker image](https://github.com/fabiocicerchia/nginx-lua).
86

7+
Copy [KnownUserNginxHandler.lua](https://github.com/queueit/KnownUser.V3.Lua/blob/master/Handlers/KnownUserNginxHandler.lua) and folders ([SDK](https://github.com/queueit/KnownUser.V3.Lua/tree/master/SDK) and [Helpers](https://github.com/queueit/KnownUser.V3.Lua/tree/master/Helpers)) incl. their content to your NGINX filesystem (in the following example we have added it to `usr/queueit`).
98

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:
9+
Then update/add `lua_package_path` in your `nginx.conf` to include the new path (keep `;;` in the end which means default path):
2410

2511
```
2612
http {
2713
lua_package_path "./usr/queueit/?.lua;./usr/queueit/SDK/?.lua;./usr/queueit/Helpers/?/?.lua;;";
2814
}
2915
```
3016

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-
}
17+
Then update `conf.d/default.conf`:
18+
```
19+
server {
20+
location / {
21+
rewrite_by_lua_block {
22+
local customerId = "{CUSTOMER_ID}"
23+
local secretKey = "{SECRET_KEY}"
24+
25+
-- Basic example where integration configuration file is loaded from disk.
26+
-- Please use this for testing / PoC etc., e.g. not on production environment.
27+
-- For production / final integration you need to decide where to store and load this file.
28+
-- Could be a caching layer, environment variable, database ect.
29+
-- It's important that the selected option is fast,
30+
-- not causing any performance bottlenecks because the file would be loaded on each request.
31+
local integrationConfigFilePath = "./usr/queueit/integrationconfig.json"
32+
local integrationConfigFile = io.open(integrationConfigFilePath, "rb")
33+
local integrationConfigJson = integrationConfigFile:read("*all")
34+
integrationConfigFile:close()
35+
36+
local qit = require("KnownUserNginxHandler")
37+
38+
-- If you want to enable secure or http only cookie settings then change options below.
39+
-- httpOnly: Only enable if you use pure server-side integration e.g. not JS Hybrid.
40+
-- secure: Only enable if your website runs purely on https.
41+
qit.setOptions({ httpOnly = false, secure = false })
42+
43+
qit.handleByIntegrationConfig(customerId, secretKey, integrationConfigJson)
6044
}
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-
45+
}
46+
```
47+
In this example `rewrite_by_lua_block` have been added to default location `/` but you must decide what makes sense in your case.
48+
Especially excluding any static content you don't want queue-it protection triggering on. This could be images (.png, .jpg), style (.css) and pages (.html).
7049

50+
Please note the comments in the code about providing `integrationconfig.json` ([read more](https://github.com/queueit/KnownUser.V3.Lua#1-providing-the-queue-configuration)) and replacing `CUSTOMER_ID` and `SECRET_KEY` with correct credentials located in GO Queue-it platform.
7151

72-
## Request body trigger (advanced)
52+
### Request body trigger (advanced)
7353
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.
7454
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.
7555
When enabled you also need to add extra settings to `location` in `conf.d/default.conf`:

0 commit comments

Comments
 (0)