|
| 1 | +--- |
| 2 | +title: webhook() source options |
| 3 | +src: 'webhook' |
| 4 | +id: adm-src-webhook-opt |
| 5 | +description: >- |
| 6 | + This section describes the options of the webhook source in {{ site.product.short_name }}. |
| 7 | +--- |
| 8 | + |
| 9 | +The `webhook()` and `webhook-json()` drivers have the following options: |
| 10 | + |
| 11 | +## auth_token() |
| 12 | + |
| 13 | +|Type:| string| |
| 14 | +|Default:| none| |
| 15 | + |
| 16 | +*Description:* You can request an authentication token from the clients as an additional method of validation. Do not use this under plain HTTP. When `auth_token("<token>")` is set, {{ site.product.short_name }} only accepts requests that contain the Authorization: Basic \<token\>, Authorization: Bearer \<token\>, or a similar header. Other requests will be rejected with `403`. |
| 17 | + |
| 18 | +### Example: |
| 19 | + |
| 20 | +```config |
| 21 | +auth_token("dGVzdF9zZWdlskfoe0aF90b2tlbg==") |
| 22 | +``` |
| 23 | + |
| 24 | +## include_request_headers() |
| 25 | + |
| 26 | +|Type:| `yes`, `no`| |
| 27 | +|Default:| `no`| |
| 28 | + |
| 29 | +*Description:* If enabled, the HTTP request headers from the webhook are available for processing as a JSON object under the `${webhook.headers}` field. This option works for `webhook()` and for `webhook-json()` as well. |
| 30 | + |
| 31 | +## paths() |
| 32 | + |
| 33 | +|Type:| JSON list| |
| 34 | +|Default:| `/.*`| |
| 35 | + |
| 36 | +*Description:* The `paths()` option sets the endpoints where the webhook will receive data. You can use static paths, or regular expressions. In regular expressions you can use named capture groups to automatically set the macro values. |
| 37 | + |
| 38 | +For example, the `/events/(?P<HOST>.*)` path specifies the hostname for the data received in the request based on the second part of the URL: a request to the `/events/my-example-host` URL sets the host field of that message to `my-example-host`. |
| 39 | + |
| 40 | +You can set multiple endpoints, for example, paths(["/events","/events/(?P\<HOST\>.*)"]) |
| 41 | + |
| 42 | +## port() |
| 43 | + |
| 44 | +|Type:| integer| |
| 45 | +|Default:| `80`(webhook), `443`(HTTPS webhook)| |
| 46 | + |
| 47 | +*Description:* Specifies the port-number where the webhook is listening on, for example, `8080`. Make sure to enable the port you have configured on the firewall of the {{ site.product.short_name }} host. The default value is `80` for HTTP webhooks, and `443` for HTTPS webhooks. |
| 48 | + |
| 49 | +## prefix() |
| 50 | + |
| 51 | +|Type:| string| |
| 52 | +|Default:| | |
| 53 | + |
| 54 | +*Description:* This option can be used to insert a prefix before the name part of the parsed name-value pairs to help further processing when using the `webhook-json()` source. For example, to insert the `webhook.` prefix, use the `prefix(webhook.)` option. |
| 55 | + |
| 56 | +Names starting with a dot (for example, .example) are reserved for use by {{ site.product.short_name }}. If you attempt use a macro name identical to the name of a parsed value, it will attempt to replace the original value of the macro (note that only soft macros can be overwritten, for more information, see Hard versus soft macros). To avoid such problems, use a prefix when naming the parsed values, for example, `prefix(my-parsed-data.)`. |
| 57 | + |
| 58 | +## proxy_header() |
| 59 | + |
| 60 | +|Type:| string| |
| 61 | +|Default:| | |
| 62 | + |
| 63 | +*Description:* By default, {{ site.product.short_name }} expects data to be sent directly, without a proxy, and sets the `${SOURCEIP}` and `${SOURCEPORT}` macros to the IP and port of the peer. |
| 64 | + |
| 65 | +When `proxy_header()` is set the following conditions apply: |
| 66 | +* `${SOURCEIP}` and `${SOURCEPORT}` macros will be set according to the proxy header defined in proxy_header(). |
| 67 | +* The `${PEERIP}` and `${PEERPORT}` macros will contain the IP and port of the proxy. |
| 68 | + |
| 69 | +### Example: getting proxy data from `x-forwarded-for` request header |
| 70 | + |
| 71 | +```config |
| 72 | +webhook(port(8080) proxy-header("x-forwarded-for")); |
| 73 | +``` |
| 74 | + |
| 75 | +Header in the request: |
| 76 | + |
| 77 | +```config |
| 78 | +curl -H "X-Forwarded-FOR: 1.2.3.4" -X POST --data "{}" http://127.0.0.1:8080/ |
| 79 | +``` |
| 80 | + |
| 81 | +**NOTE:** |
| 82 | +Note that {{ site.product.short_name }} only trusts the header that is specified in the `proxy_header()` option. If the request includes multiple headers with the specified name, the last one is used. |
| 83 | +{: .notice--info} |
| 84 | + |
| 85 | +{% include doc/admin-guide/options/ca-dir.md %} |
| 86 | + |
| 87 | +{% include doc/admin-guide/options/ca-file.md %} |
| 88 | + |
| 89 | +{% include doc/admin-guide/options/cert-file.md %} |
| 90 | + |
| 91 | +{% include doc/admin-guide/options/key-file.md %} |
| 92 | + |
| 93 | +{% include doc/admin-guide/options/peer-verify.md %} |
| 94 | + |
| 95 | +{% include doc/admin-guide/options/use-system-cert-store.md %} |
| 96 | + |
| 97 | +> *Copyright © 2025 Axoflow* |
0 commit comments