Docker

[doc-wallarm-mode]:           ../../../admin-en/configure-parameters-en.md#wallarm_mode
[doc-config-params]:          ../../../admin-en/configure-parameters-en.md
[waf-mode-instr]:                   ../../../admin-en/configure-wallarm-mode.md
[logging-instr]:                    ../../../admin-en/configure-logging.md
[proxy-balancer-instr]:             ../../../admin-en/using-proxy-or-balancer-en.md
[process-time-limit-instr]:         ../../../admin-en/configure-parameters-en.md#wallarm_process_time_limit
[allocating-memory-guide]:          ../../../admin-en/configuration-guides/allocate-resources-for-node.md
[nginx-waf-directives]:             ../../../admin-en/configure-parameters-en.md
[graylist-docs]:                    ../../../user-guides/ip-lists/overview.md
[filtration-modes-docs]:            ../../../admin-en/configure-wallarm-mode.md
[application-configuration]:        ../../../user-guides/settings/applications.md
[ptrav-attack-docs]:                ../../../attacks-vulns-list.md#path-traversal
[attacks-in-ui-image]:              ../../../images/admin-guides/test-attacks-quickstart.png
[versioning-policy]:                ../../../updating-migrating/versioning-policy.md#version-list
[node-status-docs]:                 ../../../admin-en/configure-statistics-service.md
[node-token]:                       ../../../quickstart/getting-started.md#deploy-the-wallarm-filtering-node
[api-token]:                        ../../../user-guides/settings/api-tokens.md
[wallarm-token-types]:              ../../../user-guides/nodes/nodes.md#api-and-node-tokens-for-node-creation
[platform]:                         ../../supported-deployment-options.md
[oob-advantages-limitations]:       ../overview.md#limitations
[web-server-mirroring-examples]:    overview.md#configuration-examples-for-traffic-mirroring
[memory-instr]:                     ../../../admin-en/configuration-guides/allocate-resources-for-node.md
[ip-lists-docs]:                    ../../../user-guides/ip-lists/overview.md
[aws-ecs-docs]:                     ../../cloud-platforms/aws/docker-container.md
[gcp-gce-docs]:                     ../../cloud-platforms/gcp/docker-container.md
[azure-container-docs]:             ../../cloud-platforms/azure/docker-container.md
[alibaba-ecs-docs]:                 ../../cloud-platforms/alibaba-cloud/docker-container.md
[api-policy-enf-docs]:              ../../../api-specification-enforcement/overview.md
[link-wallarm-health-check]:        ../../../admin-en/uat-checklist-en.md

# Docker Görüntüsünden Wallarm OOB Dağıtımı

Bu makale, [NGINX tabanlı Docker image](https://hub.docker.com/r/wallarm/node) kullanılarak [Wallarm OOB](overview.md) dağıtımı için talimatlar sağlar. Burada tanımlanan çözüm, bir web veya proxy sunucu tarafından aynalanan trafiği analiz etmek üzere tasarlanmıştır.

## Kullanım Senaryoları

Among all supported [Wallarm deployment options][platform], 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][aws-ecs-docs], [GCP GCE][gcp-gce-docs], [Azure Container Instances][azure-container-docs], [Alibaba ECS][alibaba-ecs-docs].

## Gereksinimler

* [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/) 
* 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. Please ensure the access is not blocked by a firewall
* Access to the IP addresses below for downloading updates to attack detection rules and [API specifications][api-policy-enf-docs], as well as retrieving precise IPs for your [allowlisted, denylisted, or graylisted][ip-lists-docs] countries, regions, or data centers

    === "US Cloud"
        ```
        34.96.64.17
        34.110.183.149
        35.235.66.155
        34.102.90.100
        34.94.156.115
        35.235.115.105
        ```
    === "EU Cloud"
        ```
        34.160.38.183
        34.144.227.90
        34.90.110.226
        ```

## 1. Trafik Aynalamasını Yapılandırın

Configure your environment to mirror incoming traffic to an instance with the Wallarm node you are deploying. For configuration details, we recommend to refer to documentation on the solution you are going to use to produce the traffic mirror (web server, proxy server, etc.).

Inside the [link][web-server-mirroring-examples], you will find the example configuration for NGINX, Traefik, Envoy.

## 2. Aynalanan Trafik Analizi ve Diğer İşlemler için Bir Yapılandırma Dosyası Hazırlayın

Wallarm düğümlerinin aynalanan trafiği analiz etmesi için, ayrı bir dosyada ek ayarlar yapılandırmanız ve bunu Docker konteynerine monte etmeniz gerekmektedir. Değiştirilmesi gereken varsayılan yapılandırma dosyası, Docker image içinde `/etc/nginx/sites-enabled/default` konumunda bulunmaktadır.

Bu dosyada, aynalanan trafiği işlemek için Wallarm düğüm yapılandırmasını ve diğer gerekli ayarları belirtmeniz gerekmektedir. Bunu yapmak için şu talimatları izleyin:

1. Aşağıdaki içerikle `default` adında yerel bir NGINX yapılandırma dosyası oluşturun:

    ```
    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_force server_addr $http_x_server_addr;
            wallarm_force server_port $http_x_server_port;
            # Change 222.222.222.22 to the address of the mirroring server
            set_real_ip_from  222.222.222.22;
            real_ip_header    X-Forwarded-For;
            real_ip_recursive on;
            wallarm_force response_status 0;
            wallarm_force response_time 0;
            wallarm_force response_size 0;

            wallarm_mode monitoring;

            location / {

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

    * `set_real_ip_from` ve `real_ip_header` yönergeleri, Wallarm Console'un [saldırganların IP adreslerini görüntülemesi][proxy-balancer-instr] için gereklidir.
    * `wallarm_force response_status`, `wallarm_force response_time` ve `wallarm_force response_size` yönergeleri, aynalanan trafikten alınan kopyalar hariç tüm isteklerin analizini devre dışı bırakmak için gereklidir.
    * `wallarm_mode` yönergesi, trafik analiz [modu][waf-mode-instr]'dur. Kötü niyetli istekler [engellenemez][oob-advantages-limitations] olduğundan, Wallarm'ın kabul ettiği tek mod monitoring’dir. In-line dağıtımda, ayrıca safe blocking ve blocking modları da mevcuttur; ancak `wallarm_mode` yönergesini monitoring dışında bir değere ayarlasanız bile, düğüm yalnızca trafiği izlemeye ve kötü niyetli trafiği kaydetmeye devam eder (kapalı moda ayarlanmış olan durum dışında).
1. Diğer gerekli Wallarm yönergelerini belirtin. Sizin için hangi ayarların faydalı olacağını anlamak üzere [Wallarm configuration parameters](../../../admin-en/configure-parameters-en.md) dokümantasyonuna ve [configuration use cases](#configuring-the-use-cases) bölümüne bakabilirsiniz.
1. Gerekirse, NGINX'in davranışını özelleştirmek için diğer NGINX ayarlarını değiştirin. Yardım için [NGINX documentation](https://nginx.org/en/docs/beginners_guide.html)'a bakın.

Ayrıca, gerekirse aşağıdaki konteyner dizinlerine diğer dosyaları monte edebilirsiniz:

* `/etc/nginx/conf.d` — ortak ayarlar
* `/etc/nginx/sites-enabled` — sanal ana bilgisayar ayarları
* `/opt/wallarm/usr/share/nginx/html` — statik dosyalar

## 3. Düğümü Cloud'a Bağlamak için Bir Token Edinin

İlgili türde bir Wallarm token'ı edinin [wallarm-token-types]:

=== "API token"

    1. Wallarm Console'a gidin → **Settings****API tokens** [US Cloud](https://us1.my.wallarm.com/settings/api-tokens) veya [EU Cloud](https://my.wallarm.com/settings/api-tokens) üzerinden.
    1. `Deploy` kaynak rolüne sahip bir API token'ı bulun veya oluşturun.
    1. Bu token'ı kopyalayın.

=== "Node token"

    1. Wallarm Console'a gidin → **Nodes** [US Cloud](https://us1.my.wallarm.com/nodes) veya [EU Cloud](https://my.wallarm.com/nodes) üzerinden.
    1. Aşağıdakilerden birini yapın: 
        * **Wallarm node** türünde bir düğüm oluşturun ve oluşturulan token'ı kopyalayın.
        * Mevcut düğüm grubunu kullanın - düğüm menüsünden → **Copy token** seçeneğiyle token'ı kopyalayın.

## 4. Düğüm ile Docker Konteynerini Çalıştırın

Az önce oluşturduğunuz yapılandırma dosyasını [mounting](https://docs.docker.com/storage/volumes/) ederek düğüm ile Docker konteynerini çalıştırın.

=== "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/sites-enabled/default -p 80:80 wallarm/node:5.3.0
    ```
=== "EU Cloud"
    ```bash
    docker run -d -e WALLARM_API_TOKEN='XXXXXXX' -e WALLARM_LABELS='group=<GROUP>' -v /configs/default:/etc/nginx/sites-enabled/default -p 80:80 wallarm/node:5.3.0
    ```

Konteynere aşağıdaki ortam değişkenleri geçirilmelidir:

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></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][api-token] 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][what-is-new-wstore]) | [Amount of memory][allocating-memory-guide] 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][filtration-modes]) but not exported to Wallarm Cloud. Meanwhile, [API Discovery][api-discovery-docs] 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][sensitive-data-rule] if needed. [More details][apid-only-mode-details]<br>By default: `false`. | No

## 5. Wallarm Düğüm Çalışmasını Test Etme

1. Send the request with test [Path Traversal][ptrav-attack-docs] 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/search) or [EU Cloud](https://my.wallarm.com/search) and make sure the attack is displayed in the list.

    ![Attacks in the interface][attacks-in-ui-image]

1. Optionally, [test][link-wallarm-health-check] other aspects of the node functioning.

## Günlük Kaydı Yapılandırması

Günlük kaydı varsayılan olarak etkinleştirilmiştir. Günlük dizinleri şunlardır:

* `/var/log/nginx` — NGINX günlükleri
* `/opt/wallarm/var/log/wallarm` — [Wallarm node logs][logging-instr]

## Kullanım Senaryolarının Yapılandırılması

Docker konteynerine monte edilen yapılandırma dosyası, [kullanılabilir yönergeler](../../../admin-en/configure-parameters-en.md) arasında filtreleme düğümü yapılandırmasını tanımlamalıdır. Aşağıda, yaygın olarak kullanılan bazı filtreleme düğümü yapılandırma seçenekleri verilmiştir:

* [Allocating resources for Wallarm nodes][memory-instr]
* [Logging Wallarm node variables][logging-instr]
* [Using the balancer of the proxy server behind the filtering node][proxy-balancer-instr]
* [Limiting the single request processing time in the directive `wallarm_process_time_limit`][process-time-limit-instr]
* [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)