|
2 | 2 |
|
3 | 3 | ## Implementation |
4 | 4 |
|
5 | | -NOTE: The following implementation steps have been developed and tested using this [Docker image](https://github.com/fabiocicerchia/nginx-lua). |
| 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. |
6 | 8 |
|
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`). |
8 | 9 |
|
9 | | -Then update/add `lua_package_path` in your `nginx.conf` to include the new path (keep `;;` in the end which means default path): |
| 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: |
10 | 24 |
|
11 | 25 | ``` |
12 | 26 | http { |
13 | 27 | lua_package_path "./usr/queueit/?.lua;./usr/queueit/SDK/?.lua;./usr/queueit/Helpers/?/?.lua;;"; |
14 | 28 | } |
15 | 29 | ``` |
16 | 30 |
|
17 | | -Then update `conf.d/default.conf`: |
| 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 | + |
18 | 36 | ``` |
19 | 37 | server { |
20 | 38 | location / { |
@@ -44,15 +62,21 @@ server { |
44 | 62 | } |
45 | 63 | } |
46 | 64 | ``` |
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). |
49 | 65 |
|
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. |
| 66 | +Replace the following two placeholders in the above code `{CUSTOMER_ID}` and `{SECRET_KEY}` with respective values located in GO Queue-it platform. |
| 67 | + |
| 68 | +NOTE: In this example `rewrite_by_lua_block` directive was added to default location `/` but you must decide what makes sense in your case. In the specific, excluding any static content you don't want queue-it protection triggering on. This could be images (.png, .jpg), style sheets (.css) and pages (.html). |
| 69 | + |
| 70 | + |
| 71 | +### 4) Provide the configuration file |
| 72 | + |
| 73 | +The above code requires you to provide the `integrationconfig.json` file which contains the configuration you create on the Queue-it GO platform. There are various ways to provide this file. Please read the [specific documentation here](https://github.com/queueit/KnownUser.V3.Lua#1-providing-the-queue-configuration). |
| 74 | + |
51 | 75 |
|
52 | | -### Request body trigger (advanced) |
53 | | -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. |
54 | | -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. |
55 | | -When enabled you also need to add extra settings to `location` in `conf.d/default.conf`: |
| 76 | +## Request body trigger (advanced) |
| 77 | +The Nginx handler (incl. Lua SDK) supports triggering on request body content. An example could be a POST call with specific item ID where you want end-users to queue up for. |
| 78 | +For this to work, you will need to contact queue-it support, so it can be enabled on your GO Queue-it platform account. |
| 79 | +Once enabled, you will need to add these extra settings to your configuration: |
56 | 80 |
|
57 | 81 | ``` |
58 | 82 | location / { |
|
0 commit comments