NGINX Host Webhook Unit

Webhooks are useful for creating an endpoint that, when accessed, runs a command on the server hosting the webhook.This is commonly used by REST APIs as a way to subscribe to an event. For example, GitHub's APIscan call a webhook whenever a push has been made to a Git repository.

Features

adnanh/webhook 2.6.2

Usage

Configuration

It is highly recommended that you use container orchestration software such asDocker Compose when using this NGINX Host unit as several Dockercontainers are required for operation. This guide will assume that you are using Docker Compose.

To begin, start with a basic docker-compose.yml file as described in theNGINX Host configuration guide. Then, add aservice for the NGINX Host webhook unit (named webhooks):

We mount /opt/container/webhooks.json using the local file /home/me/webhooks.json. This is a file containing ourwebhook configuration. Refer to the documentation forinformation on the contents of this file.

As with any other NGINX Host unit, we mount our data volume, in this case named data, to /opt/container/shared.

Finally, we need to create a link in our NGINX Host container to the webhooks container in order to host thewebhooks. Here is our final docker-compose.yml file:

This will result in making the webhooks available at https://mysite.com/webhooks.

Running the NGINX Host Webhook Unit

Assuming you are using Docker Compose, simply run docker-compose up in the same directory as yourdocker-compose.yml file. Otherwise, you will need to start each container with docker run or a suitablealternative, making sure to add the appropriate environment variables and volume references.

Reference

Environment Variables

WEBHOOK_VERBOSE

Used to show verbose webhook logging (e.g., rule matching, command execution) if set to true.

Default value: false

Others

Please see the NGINX Host documentation for informationon additional environment variables understood by this unit.