# Running Docker NGINX‑based Image

The Wallarm NGINX-based filtering node can be deployed using a [Docker image](https://hub.docker.com/r/wallarm/node). This node supports both x86_64 and ARM64 architectures, which are automatically identified during installation. This article provides guidance on how to run the node from the Docker image for [inline traffic filtration](https://docs.wallarm.com/installation/inline/overview.md).

The Docker image is based on Alpine Linux and the NGINX version provided by Alpine. Currently, the latest image uses Alpine Linux version 3.23, which includes NGINX stable 1.28.3.

## Use cases

Among all supported [Wallarm deployment options](https://docs.wallarm.com/installation/supported-deployment-options.md), NGINX-based Docker image is recommended for Wallarm deployment in these **use cases**:

* If your organization utilizes Docker-based infrastructure, Wallarm Docker image is the ideal choice. It integrates effortlessly into your existing setup, whether you are employing a microservice architecture running on AWS ECS, Alibaba ECS, or other similar services. This solution also applies to those using virtual machines seeking a more streamlined management through Docker containers.
* If you require fine-grained control over each container, the Docker image excels. It affords a greater level of resource isolation than typically possible with traditional VM-based deployments.

For more information on running Wallarm's NGINX-based Docker image on popular public cloud container orchestration services, refer to our guides: [AWS ECS](https://docs.wallarm.com/installation/cloud-platforms/aws/docker-container.md), [GCP GCE](https://docs.wallarm.com/installation/cloud-platforms/gcp/docker-container.md), [Azure Container Instances](https://docs.wallarm.com/installation/cloud-platforms/azure/docker-container.md), [Alibaba ECS](https://docs.wallarm.com/installation/cloud-platforms/alibaba-cloud/docker-container.md).

## Requirements

* [Docker](https://docs.docker.com/engine/install/) installed on your host system
* Access to `https://hub.docker.com/r/wallarm/node` to download the Docker image. Please ensure the access is not blocked by a firewall
* Access to the account with the **Administrator** role in Wallarm Console in the [US Cloud](https://us1.my.wallarm.com/) or [EU Cloud](https://my.wallarm.com/), or [ME Cloud](https://me1.my.wallarm.com/) 
* Access to `https://us1.api.wallarm.com` if working with US Wallarm Cloud or to `https://api.wallarm.com` if working with EU Wallarm Cloud, to `https://me1.api.wallarm.com` if working with ME Wallarm Cloud. Please ensure the access is not blocked by a firewall
* Access to the IP addresses and their corresponding hostnames (if any) listed below. This is needed for downloading updates to attack detection rules and [API specifications](https://docs.wallarm.com/api-specification-enforcement/overview.md), as well as retrieving precise IPs for your [allowlisted, denylisted, or graylisted](https://docs.wallarm.com/user-guides/ip-lists/overview.md) countries, regions, or data centers

    **US Cloud:**

    ```
    node-data0.us1.wallarm.com - 34.96.64.17
    node-data1.us1.wallarm.com - 34.110.183.149
    us1.api.wallarm.com - 35.235.66.155
    34.102.90.100
    34.94.156.115
    35.235.115.105
    ```

    **EU Cloud:**

    ```
    node-data1.eu1.wallarm.com - 34.160.38.183
    node-data0.eu1.wallarm.com - 34.144.227.90
    api.wallarm.com - 34.90.110.226
    ```

    **ME Cloud:**

    ```
    node-data0.me1.wallarm.com - 34.166.82.208
    node-data1.me1.wallarm.com - 34.166.82.208
    me1.api.wallarm.com - 34.166.82.208
    ```
## Options for running the container

The filtering node configuration parameters should be passed to the deployed Docker container in one of the following ways:

* **In the environment variables**. This option allows for the configuration of only basic filtering node parameters. Most [directives](https://docs.wallarm.com/admin-en/configure-parameters-en.md) cannot be configured through environment variables.
* **In the mounted configuration file**. This option allows full filtering node configuration via any [directives](https://docs.wallarm.com/admin-en/configure-parameters-en.md). With this configuration method, environment variables with the filtering node and Wallarm Cloud connection settings are also passed to the container.
## Run the container passing the environment variables

To run the container:

1. Get Wallarm token of the [appropriate type](https://docs.wallarm.com/user-guides/nodes/nodes.md#api-and-node-tokens-for-node-creation):

    **API token:**


    1. Open Wallarm Console → **Settings** → **API tokens** in the [US Cloud](https://us1.my.wallarm.com/settings/api-tokens) or [EU Cloud](https://my.wallarm.com/settings/api-tokens), or [ME Cloud](https://me1.my.wallarm.com/settings/api-tokens).
    1. Find or create API token with the `Node deployment/Deployment` usage type.
    1. Copy this token.

    **Node token:**


    1. Open Wallarm Console → **Nodes** in the [US Cloud](https://us1.my.wallarm.com/nodes) or [EU Cloud](https://my.wallarm.com/nodes), or [ME Cloud](https://me1.my.wallarm.com/nodes).
    1. Do one of the following: 
        * Create the node of the **Wallarm node** type and copy the generated token.
        * Use existing node group - copy token using node's menu → **Copy token**.
1. Run the container with the node:

    **US Cloud:**

    ```bash
    docker run -d -e WALLARM_API_TOKEN='XXXXXXX' -e WALLARM_LABELS='group=<GROUP>' -e NGINX_BACKEND='example.com' -e WALLARM_API_HOST='us1.api.wallarm.com' -p 80:80 wallarm/node:6.12.1
    ```

    **EU Cloud:**

    ```bash
    docker run -d -e WALLARM_API_TOKEN='XXXXXXX' -e WALLARM_LABELS='group=<GROUP>' -e NGINX_BACKEND='example.com' -p 80:80 wallarm/node:6.12.1
    ```

    **ME Cloud:**

    ```bash
    docker run -d -e WALLARM_API_TOKEN='XXXXXXX' -e WALLARM_LABELS='group=<GROUP>' -e NGINX_BACKEND='example.com' -e WALLARM_API_HOST='me1.api.wallarm.com' -p 80:80 wallarm/node:6.12.1
    ```

You can pass the following basic filtering node settings to the container via the option `-e`:

Environment variable | Description| Required
--- | ---- | ----
`WALLARM_API_TOKEN` | Wallarm node or API token. | Yes
`WALLARM_LABELS` | <p>Available starting from node 4.6. Works only if `WALLARM_API_TOKEN` is set to [API token](https://docs.wallarm.com/user-guides/settings/api-tokens.md) with the `Deploy` role. Sets the `group` label for node instance grouping, for example:</p> <p>`WALLARM_LABELS="group=<GROUP>"`</p> <p>...will place node instance into the `<GROUP>` instance group (existing, or, if does not exist, it will be created).</p> | Yes (for API tokens)
`NGINX_BACKEND` | Domain or IP address of the resource to protect with the Wallarm solution. | Yes
`WALLARM_API_HOST` | Wallarm API server:<ul><li>`us1.api.wallarm.com` for the US Cloud</li><li>`api.wallarm.com` for the EU Cloud</li><li>`me1.api.wallarm.com` for the ME Cloud</li></ul>By default: `api.wallarm.com`. | No
`WALLARM_MODE` | Node mode:<ul><li>`block` to block malicious requests</li><li>`safe_blocking` to block only those malicious requests originated from [graylisted IP addresses](https://docs.wallarm.com/user-guides/ip-lists/overview.md)</li><li>`monitoring` to analyze but not block requests</li><li>`off` to disable traffic analyzing and processing</li></ul>By default: `monitoring`.<br>[Detailed description of filtration modes →](https://docs.wallarm.com/admin-en/configure-wallarm-mode.md) | No
`WALLARM_APPLICATION` | Unique identifier of the protected application to be used in the Wallarm Cloud. The value can be a positive integer except for `0`.<br><br>Default value (if the variable is not passed to the container) is `-1` which indicates the **default** application displayed in Wallarm Console → **Settings** → **Application**.<br><br>[More details on setting up applications →](https://docs.wallarm.com/user-guides/settings/applications.md) | No
`SLAB_ALLOC_ARENA` (`TARANTOOL_MEMORY_GB` [NGINX Node 5.x and earlier](https://docs.wallarm.com/updating-migrating/what-is-new.md#replacing-tarantool-with-wstore-for-postanalytics)) | [Amount of memory](https://docs.wallarm.com/admin-en/configuration-guides/allocate-resources-for-node.md) allocated to wstore. The value can be a float (a dot <code>.</code> is a decimal separator). By default: 1.0 (1 gygabyte).<br>Note that when passing this variable in Docker `run` command with the `-e`, the variable is not recorded in any configuration file within the container, but it is still used when `wstore` starts. | No
`NGINX_PORT` | Sets a port that NGINX will use inside the Docker container.<br><br>Starting from the Docker image `4.0.2-1`, the [`wallarm-status`](https://docs.wallarm.com/admin-en/configure-statistics-service.md) service automatically runs on the same port as NGINX.<br><br>Default value (if the variable is not passed to the container) is `80`.<br><br>Syntax is `NGINX_PORT='443'`. | No
<a name="wallarm-status-allow-env-var"></a>`WALLARM_STATUS_ALLOW` | Custom CIDRs that are allowed to access the [`/wallarm-status` endpoint](https://docs.wallarm.com/admin-en/configure-statistics-service.md) from outside the Docker container. Example value: `10.0.0.0/8`. If you need to pass several values, use a comma `,` as a separator. To access the service externally, use the Docker container's IP, specifying the `/wallarm-status` endpoint path. | No
`DISABLE_IPV6`| The variable with any value except for an empty one deletes the `listen [::]:80 default_server ipv6only=on;` line from the NGINX configuration file which will stop NGINX from IPv6 connection processing.<br><br>If the variable is not specified explicitly or has an empty value `""`, NGINX processes both IPv6 and IPv4 connections. | No
`WALLARM_APIFW_ENABLE` | This setting toggles [API Specification Enforcement](https://docs.wallarm.com/api-specification-enforcement/overview.md) on or off, available from release 4.10 onwards. Please note that activating this feature does not substitute for the required subscription and configuration through the Wallarm Console UI.<br><br>Its default value is `true`, enabling the functionality. | No
`WALLARM_APID_ONLY` (5.3.7 and higher) | In this mode, attacks detected in your traffic are blocked locally by the node (if [enabled](https://docs.wallarm.com/admin-en/configure-wallarm-mode.md#available-filtration-modes)) but not exported to Wallarm Cloud. Meanwhile, [API Discovery](https://docs.wallarm.com/api-discovery/overview.md) and some other features remain fully functional, detecting your API inventory and uploading it to the Cloud for visualization. This mode is for those who want to review their API inventory and identify sensitive data first, and plan controlled attack data export accordingly. However, disabling attack export is rare, as Wallarm securely processes attack data and provides [sensitive attack data masking](https://docs.wallarm.com/user-guides/rules/sensitive-data-rule.md) if needed. [More details](https://docs.wallarm.com/installation/nginx/all-in-one.md#api-discovery-only-mode)<br>By default: `false`. | No
`APIFW_METRICS_ENABLED` (6.4.1 and higher) | Enables Prometheus metrics for the API Specification Enforcement module.<br>By default: `false` (disabled). | No
`APIFW_METRICS_HOST` (6.4.1 and higher) | Defines the host and port on which the API Specification Enforcement exposes metrics.<br>By default: `:9010`. | No
`APIFW_METRICS_ENDPOINT_NAME` (6.4.1 and higher) | Defines the HTTP path of the API Specification Enforcement metrics endpoint<br>By default: `metrics`. | No
`WALLARM_WSTORE__METRICS__LISTEN_ADDRESS` | Defines the host and port on which [Postanalytics and general system metrics](https://docs.wallarm.com/admin-en/wstore-metrics.md) are exposed.<br>By default: `http://localhost:9001/metrics`. | No 
`WALLARM_WSTORE__SERVICE__PROTOCOL` (6.6.0 and higher) | Specifies the protocol family that **wstore** uses for incoming connections. Possible values:<ul><li>`"tcp"` - dual-stack mode (listens on both IPv4 and IPv6)</li><li>`"tcp4"` - IPv4 only</li><li>`"tcp6"` - IPv6 only</li></ul>By default: `"tcp4"`. | No
`WALLARM_WCLI__METRICS__LISTEN_ADDRESS` | Defines the host and port on which the [**wcli** Controller metrics](https://docs.wallarm.com/admin-en/wcli-metrics.md) are exposed.<br>By default: `http://localhost:9003/metrics`. | No 
`WALLARM_WCLI__METRICS__ENDPOINT` | Defines the HTTP path for the [**wcli** Controller metrics](https://docs.wallarm.com/admin-en/wcli-metrics.md) endpoint.<br>By default: `metrics`. | No 
The command does the following:

* Creates the file `default.conf` with minimal NGINX configuration and passes filtering node configuration in the `/etc/nginx/http.d` container directory.
* Creates files with filtering node credentials to access the Wallarm Cloud in the `/opt/wallarm/etc/wallarm` container directory:
    * `node.yaml` with filtering node UUID and secret key
    * `private.key` with Wallarm private key
* Protects the resource `http://NGINX_BACKEND:80`.

## Run the container mounting the configuration file

You can mount the prepared configuration file to the Docker container via the `-v` option. The file must contain the following settings:

* [Filtering node directives](https://docs.wallarm.com/admin-en/configure-parameters-en.md)
* [NGINX settings](https://nginx.org/en/docs/beginners_guide.html)

To run the container:

1. Get Wallarm token of the [appropriate type](https://docs.wallarm.com/user-guides/nodes/nodes.md#api-and-node-tokens-for-node-creation):

    **API token:**


    1. Open Wallarm Console → **Settings** → **API tokens** in the [US Cloud](https://us1.my.wallarm.com/settings/api-tokens) or [EU Cloud](https://my.wallarm.com/settings/api-tokens), or [ME Cloud](https://me1.my.wallarm.com/settings/api-tokens).
    1. Find or create API token with the `Node deployment/Deployment` usage type.
    1. Copy this token.

    **Node token:**


    1. Open Wallarm Console → **Nodes** in the [US Cloud](https://us1.my.wallarm.com/nodes) or [EU Cloud](https://my.wallarm.com/nodes), or [ME Cloud](https://me1.my.wallarm.com/nodes).
    1. Do one of the following: 
        * Create the node of the **Wallarm node** type and copy the generated token.
        * Use existing node group - copy token using node's menu → **Copy token**.
1. Run the container with the node:

    **US Cloud:**

    ```bash
    docker run -d -e WALLARM_API_TOKEN='XXXXXXX' -e WALLARM_LABELS='group=<GROUP>' -e WALLARM_API_HOST='us1.api.wallarm.com' -v /configs/default:/etc/nginx/http.d/default.conf -p 80:80 wallarm/node:6.12.1
    ```

    **EU Cloud:**

    ```bash
    docker run -d -e WALLARM_API_TOKEN='XXXXXXX' -e WALLARM_LABELS='group=<GROUP>' -v /configs/default:/etc/nginx/http.d/default.conf -p 80:80 wallarm/node:6.12.1
    ```

    **ME Cloud:**

    ```bash
    docker run -d -e WALLARM_API_TOKEN='XXXXXXX' -e WALLARM_LABELS='group=<GROUP>' -e WALLARM_API_HOST='me1.api.wallarm.com' -v /configs/default:/etc/nginx/http.d/default.conf -p 80:80 wallarm/node:6.12.1
    ```

    * The `-e` option passes the following required environment variables to the container:

        Environment variable | Description| Required
        --- | ---- | ----
        `WALLARM_API_TOKEN` | Wallarm node or API token. | Yes
        `WALLARM_API_HOST` | Wallarm API server:<ul><li>`us1.api.wallarm.com` for the US Cloud</li><li>`api.wallarm.com` for the EU Cloud</li><li>`me1.api.wallarm.com` for the ME Cloud</li></ul>By default: `api.wallarm.com`. | No
        `WALLARM_LABELS` | <p>Available starting from node 4.6. Works only if `WALLARM_API_TOKEN` is set to [API token](https://docs.wallarm.com/user-guides/settings/api-tokens.md) with the `Deploy` role. Sets the `group` label for node instance grouping, for example:</p> <p>`WALLARM_LABELS="group=<GROUP>"`</p> <p>...will place node instance into the `<GROUP>` instance group (existing, or, if does not exist, it will be created).</p> | Yes (for API tokens)
        `SLAB_ALLOC_ARENA` (`TARANTOOL_MEMORY_GB` [NGINX Node 5.x and earlier](https://docs.wallarm.com/updating-migrating/what-is-new.md#replacing-tarantool-with-wstore-for-postanalytics)) | [Amount of memory](https://docs.wallarm.com/admin-en/configuration-guides/allocate-resources-for-node.md) allocated to wstore. The value can be a float (a dot <code>.</code> is a decimal separator). By default: 1.0 (1 gygabyte). | No
        `WALLARM_APID_ONLY` (5.3.7 and higher) | In this mode, attacks detected in your traffic are blocked locally by the node (if [enabled](https://docs.wallarm.com/admin-en/configure-wallarm-mode.md#available-filtration-modes)) but not exported to Wallarm Cloud. Meanwhile, [API Discovery](https://docs.wallarm.com/api-discovery/overview.md) and some other features remain fully functional, detecting your API inventory and uploading it to the Cloud for visualization. This mode is for those who want to review their API inventory and identify sensitive data first, and plan controlled attack data export accordingly. However, disabling attack export is rare, as Wallarm securely processes attack data and provides [sensitive attack data masking](https://docs.wallarm.com/user-guides/rules/sensitive-data-rule.md) if needed. [More details](https://docs.wallarm.com/installation/nginx/all-in-one.md#api-discovery-only-mode)<br>By default: `false`. | No
        `APIFW_METRICS_ENABLED` (6.4.1 and higher) | Enables Prometheus metrics for the API Specification Enforcement module.<br>By default: `false` (disabled). | No
        `APIFW_METRICS_HOST` (6.4.1 and higher) | Defines the host and port on which the API Specification Enforcement exposes metrics.<br>By default: `:9010`. | No
        `APIFW_METRICS_ENDPOINT_NAME` (6.4.1 and higher) | Defines the HTTP path of the API Specification Enforcement metrics endpoint<br>By default: `metrics`. | No
        `WALLARM_WSTORE__METRICS__LISTEN_ADDRESS` | Defines the host and port on which [Postanalytics and general system metrics](https://docs.wallarm.com/admin-en/wstore-metrics.md) are exposed.<br>By default: `http://localhost:9001/metrics`. | No 
        `WALLARM_WSTORE__SERVICE__PROTOCOL` (6.6.0 and higher) | Specifies the protocol family that **wstore** uses for incoming connections. Possible values:<ul><li>`"tcp"` - dual-stack mode (listens on both IPv4 and IPv6)</li><li>`"tcp4"` - IPv4 only</li><li>`"tcp6"` - IPv6 only</li></ul>By default: `"tcp4"`. | No
        `WALLARM_WCLI__METRICS__LISTEN_ADDRESS` | Defines the host and port on which the [**wcli** Controller metrics](https://docs.wallarm.com/admin-en/wcli-metrics.md) are exposed.<br>By default: `http://localhost:9003/metrics`. | No 
        `WALLARM_WCLI__METRICS__ENDPOINT` | Defines the HTTP path for the [**wcli** Controller metrics](https://docs.wallarm.com/admin-en/wcli-metrics.md) endpoint.<br>By default: `metrics`. | No 
    * The `-v` option mounts the directory with the configuration file `default.conf` to the `/etc/nginx/http.d` container directory.

        ??? info "See the example `/etc/nginx/http.d/default.conf` minimal content"
            ```bash
            server {
                    listen 80 default_server;
                    listen [::]:80 default_server ipv6only=on;
                    #listen 443 ssl;

                    server_name localhost;

                    #ssl_certificate cert.pem;
                    #ssl_certificate_key cert.key;

                    root /usr/share/nginx/html;

                    index index.html index.htm;

                    wallarm_mode monitoring;

                    location / {
                            
                            proxy_pass http://example.com;
                            include proxy_params;
                    }
            }
            ```

        ??? info "Mounting other configuration files"
            The container directories used by NGINX:

            * `/etc/nginx/nginx.conf` - This is the main NGINX configuration file. If you decide to mount this file, additional steps are necessary for proper Wallarm functionality:

                1. In `nginx.conf`, add the following setting at the top level:

                    ```
                    include /etc/nginx/modules/*.conf;
                    ```
                1. In `nginx.conf`, add the `wallarm_srv_include /etc/nginx/wallarm-apifw-loc.conf;` directive in the `http` block. This specifies the path to the configuration file for [API Specification Enforcement](https://docs.wallarm.com/api-specification-enforcement/overview.md).
                1. Mount the `wallarm-apifw-loc.conf` file to the specified path. The content should be:

                    ```
                    location ~ ^/wallarm-apifw(.*)$ {
                            wallarm_mode off;
                            proxy_pass http://127.0.0.1:8088$1;
                            error_page 404 431         = @wallarm-apifw-fallback;
                            error_page 500 502 503 504 = @wallarm-apifw-fallback;
                            allow 127.0.0.8/8;
                            deny all;
                    }

                    location @wallarm-apifw-fallback {
                            wallarm_mode off;
                            return 500 "API FW fallback";
                    }
                    ```
                1. Mount the `/etc/nginx/conf.d/wallarm-status.conf` file with the content below. It is crucial not to modify any lines from the provided configuration as this may interfere with the successful upload of node metrics to the Wallarm cloud.

                    ```
                    server {
                      listen 127.0.0.8:80;

                      server_name localhost;

                      allow 127.0.0.0/8;
                      deny all;

                      wallarm_mode off;
                      disable_acl "on";
                      wallarm_enable_apifw off;
                      access_log off;

                      location ~/wallarm-status$ {
                        wallarm_status on;
                      }
                    }
                    ```
                1. Within your NGINX configuration file, set up the following configuration for the `/wallarm-status` endpoint:

                    ```
                    location /wallarm-status {
                        # Allowed addresses should match the WALLARM_STATUS_ALLOW variable value
                        allow xxx.xxx.x.xxx;
                        allow yyy.yyy.y.yyy;
                        deny all;
                        wallarm_status on format=prometheus;
                        wallarm_mode off;
                    }
                    ```
            * `/etc/nginx/conf.d` — common settings
            * `/etc/nginx/http.d` — virtual host settings
            * `/opt/wallarm/usr/share/nginx/html` — static files

            If required, you can mount any files to the listed container directories. The filtering node directives should be described in the `/etc/nginx/http.d/default.conf` file.

The command does the following:

* Mounts the file `default.conf` into the `/etc/nginx/http.d` container directory.
* Creates files with filtering node credentials to access Wallarm Cloud in the `/opt/wallarm/etc/wallarm` container directory:
    * `node.yaml` with filtering node UUID and secret key
    * `private.key` with Wallarm private key
* Protects the resource `http://example.com`.

## Logging configuration

The logging is enabled by default. The log directories are:

* `/var/log/nginx` — NGINX logs
* `/opt/wallarm/var/log/wallarm` — [Wallarm node logs](https://docs.wallarm.com/admin-en/configure-logging.md)

## Testing Wallarm node operation

1. Send the request with test [Path Traversal](https://docs.wallarm.com/attacks-vulns-list.md#path-traversal) attack to a protected resource address:

    ```
    curl http://localhost/etc/passwd
    ```

    If traffic is configured to be proxied to `example.com`, include the `-H "Host: example.com"` header in the request.
1. Open Wallarm Console → **Attacks** section in the [US Cloud](https://us1.my.wallarm.com/attacks) or [EU Cloud](https://my.wallarm.com/attacks), or [ME Cloud](https://me1.my.wallarm.com/attacks) and make sure the attack is displayed in the list.

    ![Attacks in the interface](https://docs.wallarm.com/images/admin-guides/test-attacks-quickstart.png)

1. Optionally, [test](https://docs.wallarm.com/admin-en/uat-checklist-en.md) other aspects of the node functioning.
## Configuring the use cases

The configuration file mounted to the Docker container should describe the filtering node configuration in the [available directive](https://docs.wallarm.com/admin-en/configure-parameters-en.md). Below are some commonly used filtering node configuration options:

* [Configuration of the filtration mode](https://docs.wallarm.com/admin-en/configure-wallarm-mode.md)
* [Logging Wallarm node variables](https://docs.wallarm.com/admin-en/configure-logging.md)
* [Limiting the single request processing time in the directive `wallarm_process_time_limit`](https://docs.wallarm.com/admin-en/configure-parameters-en.md#wallarm_process_time_limit)
* [Limiting the server reply waiting time in the NGINX directive `proxy_read_timeout`](https://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_read_timeout)
* [Limiting the maximum request size in the NGINX directive `client_max_body_size`](https://nginx.org/en/docs/http/ngx_http_core_module.html#client_max_body_size)
