Ana içeriğe geç

Wallarm Docker Image'ın Alibaba Cloud'a Dağıtımı

Bu hızlı kılavuz, NGINX tabanlı Wallarm node'unun Docker görüntüsünü Alibaba Cloud Elastic Compute Service (ECS) kullanarak Alibaba Cloud platformuna dağıtım adımlarını sağlar.

Talimatların Sınırlamaları

Bu talimatlar, yük dengeleme ve node otomatik ölçeklendirmesinin yapılandırılmasını kapsamamaktadır. Bu bileşenleri kendiniz kuruyorsanız, ilgili Alibaba Cloud dokümantasyonunu okumanızı tavsiye ederiz.

Kullanım Durumları

Among all supported Wallarm deployment options, Wallarm deployment on Alibaba Cloud ECS using the Docker image is recommended in these use cases:

  • If your applications leverage a microservices architecture, and are already containerized and operational on Alibaba Cloud ECS.

  • 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.

Gereksinimler

  • [Alibaba Cloud Console]'ya erişim (https://account.alibabacloud.com/login/login.htm)

  • Wallarm Console için Administrator rolüne sahip ve iki faktörlü kimlik doğrulaması devre dışı bırakılmış hesaba erişim (US Cloud veya EU Cloud)

  • Saldırı tespit kuralları güncellemelerini indirmek, API specifications almak ve allowlisted, denylisted, or graylisted ülkeler, bölgeler veya veri merkezleri için doğru IP'leri elde etmek amacıyla aşağıdaki IP adreslerine erişim

    34.96.64.17
    34.110.183.149
    35.235.66.155
    34.102.90.100
    34.94.156.115
    35.235.115.105
    
    34.160.38.183
    34.144.227.90
    34.90.110.226
    

Wallarm node Docker konteyner yapılandırması için Seçenekler

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 cannot be configured through environment variables.

  • In the mounted configuration file. This option allows full filtering node configuration via any directives. With this configuration method, environment variables with the filtering node and Wallarm Cloud connection settings are also passed to the container.

Sadece ortam değişkenleri ile yapılandırılmış Wallarm node Docker konteynerinin Dağıtımı

Sadece ortam değişkenleriyle yapılandırılmış konteynerize Wallarm filtreleme node'unu dağıtmak için, bir Alibaba Cloud örneği oluşturmalı ve bu örnek üzerinde Docker konteynerini çalıştırmalısınız. Bu adımları Alibaba Cloud Console veya Alibaba Cloud CLI aracılığıyla gerçekleştirebilirsiniz. Bu talimatlarda Alibaba Cloud Console kullanılmaktadır.

  1. Get Wallarm token of the appropriate type:

    1. Open Wallarm Console → SettingsAPI tokens in the US Cloud or EU Cloud.
    2. Find or create API token with the Node deployment/Deployment usage type.
    3. Copy this token.
    1. Open Wallarm Console → Nodes in the US Cloud or EU Cloud.
    2. 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.
  2. Alibaba Cloud Console'u açın → hizmetler listesi → Elastic Compute ServiceInstances.

  3. Aşağıdaki yönergeler ve Alibaba Cloud talimatlarına uygun olarak örneği oluşturun:

    • Örneğin herhangi bir işletim sistemi görüntüsü temel alınarak oluşturulabilir.
    • Örneğin dış kaynaklara erişilebilir olmalıdır; bu nedenle örnek ayarlarında genel IP adresi veya alan adı yapılandırılmalıdır.
    • Örnek ayarları, örneğe bağlanmak için kullanılan yöntemi yansıtmalıdır.
  4. Aşağıda belirtilen Alibaba Cloud dokümantasyonunda açıklanan yöntemlerden biriyle örneğe bağlanın.

  5. Örnekte uygun işletim sistemi için talimatları izleyerek Docker paketlerini kurun.

  6. Örneği Wallarm Cloud'a bağlamak için kullanılacak kopyalanmış Wallarm token'ı ile ortam değişkenini ayarlayın:

    export WALLARM_API_TOKEN='<WALLARM_API_TOKEN>'
    
  7. Ortam değişkenleri ve monte edilmiş yapılandırma dosyası kullanılarak docker run komutu ile Wallarm node Docker konteynerini çalıştırın:

    docker run -d -e WALLARM_API_TOKEN=${WALLARM_API_TOKEN} -e WALLARM_LABELS='group=<GROUP>' -e NGINX_BACKEND=<HOST_TO_PROTECT_WITH_WALLARM> -e WALLARM_API_HOST='us1.api.wallarm.com' -p 80:80 wallarm/node:5.3.0
    
    docker run -d -e WALLARM_API_TOKEN=${WALLARM_API_TOKEN} -e WALLARM_LABELS='group=<GROUP>' -e NGINX_BACKEND=<HOST_TO_PROTECT_WITH_WALLARM> -p 80:80 wallarm/node:5.3.0
    
    • -p: Filtreleme node'unun dinlediği port. Değer, örnek portuyla aynı olmalıdır.
    • -e: Filtreleme node yapılandırmasını içeren ortam değişkenleri (kullanılabilir değişkenler aşağıdaki tabloda listelenmiştir). Lütfen WALLARM_API_TOKEN değerinin açıkça iletilmemesinin tavsiye edildiğini unutmayın.

      Environment variable Description Required
      WALLARM_API_TOKEN Wallarm node or API token. Yes
      WALLARM_LABELS

      Available starting from node 4.6. Works only if WALLARM_API_TOKEN is set to API token with the Deploy role. Sets the group label for node instance grouping, for example:

      WALLARM_LABELS="group=<GROUP>"

      ...will place node instance into the <GROUP> instance group (existing, or, if does not exist, it will be created).

      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:
      • us1.api.wallarm.com for the US Cloud
      • api.wallarm.com for the EU Cloud
      By default: api.wallarm.com.
      No
      WALLARM_MODE Node mode:
      • block to block malicious requests
      • safe_blocking to block only those malicious requests originated from graylisted IP addresses
      • monitoring to analyze but not block requests
      • off to disable traffic analyzing and processing
      By default: monitoring.
      Detailed description of filtration modes →
      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.

      Default value (if the variable is not passed to the container) is -1 which indicates the default application displayed in Wallarm Console → Settings → Application.

      More details on setting up applications →
      No
      SLAB_ALLOC_ARENA (TARANTOOL_MEMORY_GB [NGINX Node 5.x and earlier][what-is-new-wstore]) Amount of memory allocated to wstore. The value can be a float (a dot . is a decimal separator). By default: 1.0 (1 gygabyte). No
      NGINX_PORT Sets a port that NGINX will use inside the Docker container.

      Starting from the Docker image 4.0.2-1, the wallarm-status service automatically runs on the same port as NGINX.

      Default value (if the variable is not passed to the container) is 80.

      Syntax is NGINX_PORT='443'.
      No
      WALLARM_STATUS_ALLOW Custom CIDRs that are allowed to access the /wallarm-status endpoint 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.

      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 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.

      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) but not exported to Wallarm Cloud. Meanwhile, API Discovery 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 if needed. More details
      By default: false.
      No
  8. Filtreleme node'unun çalışmasını test edin.

Monte Edilmiş Dosya ile Yapılandırılmış Wallarm node Docker Konteynerinin Dağıtımı

Ortam değişkenleri ve monte edilmiş dosya ile yapılandırılmış konteynerize Wallarm filtreleme node'unu dağıtmak için, bir Alibaba Cloud örneği oluşturmalı, bu örnek dosya sisteminde filtreleme node yapılandırma dosyasını bulmalı ve Docker konteynerini bu örnekte çalıştırmalısınız. Bu adımları Alibaba Cloud Console veya Alibaba Cloud CLI aracılığıyla gerçekleştirebilirsiniz. Bu talimatlarda Alibaba Cloud Console kullanılmaktadır.

  1. Get Wallarm token of the appropriate type:

    1. Open Wallarm Console → SettingsAPI tokens in the US Cloud or EU Cloud.
    2. Find or create API token with the Node deployment/Deployment usage type.
    3. Copy this token.
    1. Open Wallarm Console → Nodes in the US Cloud or EU Cloud.
    2. 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.
  2. Alibaba Cloud Console'u açın → hizmetler listesi → Elastic Compute ServiceInstances.

  3. Aşağıdaki yönergeler ve Alibaba Cloud talimatlarına uygun olarak örneği oluşturun:

    • Örneğin herhangi bir işletim sistemi görüntüsü temel alınarak oluşturulabilir.
    • Örneğin dış kaynaklara erişilebilir olmalıdır; bu nedenle örnek ayarlarında genel IP adresi veya alan adı yapılandırılmalıdır.
    • Örnek ayarları, örneğe bağlanmak için kullanılan yöntemi yansıtmalıdır.
  4. Aşağıda belirtilen Alibaba Cloud dokümantasyonunda açıklanan yöntemlerden biriyle örneğe bağlanın.

  5. Örnekte uygun işletim sistemi için talimatları izleyerek Docker paketlerini kurun.

  6. Örneği Wallarm Cloud'a bağlamak için kullanılacak kopyalanmış Wallarm token'ı ile ortam değişkenini ayarlayın:

    export WALLARM_API_TOKEN='<WALLARM_API_TOKEN>'
    
  7. Örnekte, filtreleme node yapılandırmasını içeren default dosyasını barındıran bir dizin oluşturun (örneğin, dizin adı configs olabilir). Minimal ayarları içeren dosya örneği:

    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;
        # wallarm_application 1;
    
        location / {
                proxy_pass http://example.com;
                include proxy_params;
        }
    }
    

    Filtreleme node yönergelerinin yapılandırma dosyasında belirtilebilecek seti →

  8. Ortam değişkenleri ve monte edilmiş yapılandırma dosyası kullanılarak docker run komutu ile Wallarm node Docker konteynerini çalıştırın:

    docker run -d -e WALLARM_API_TOKEN=${WALLARM_API_TOKEN} -e WALLARM_LABELS='group=<GROUP>' -e WALLARM_API_HOST='us1.api.wallarm.com' -v <INSTANCE_PATH_TO_CONFIG>:<DIRECTORY_FOR_MOUNTING> -p 80:80 wallarm/node:5.3.0
    
    docker run -d -e WALLARM_API_TOKEN=${WALLARM_API_TOKEN} -e WALLARM_LABELS='group=<GROUP>' -v <INSTANCE_PATH_TO_CONFIG>:<CONTAINER_PATH_FOR_MOUNTING> -p 80:80 wallarm/node:5.3.0
    
    • <INSTANCE_PATH_TO_CONFIG>: Önceki adımda oluşturulan yapılandırma dosyasının yolu. Örneğin, configs.
    • <DIRECTORY_FOR_MOUNTING>: Yapılandırma dosyasının monte edileceği konteyner dizini. Yapılandırma dosyaları, NGINX tarafından kullanılan aşağıdaki konteyner dizinlerine monte edilebilir:

      • /etc/nginx/conf.d — ortak ayarlar
      • /etc/nginx/sites-enabled — sanal ana bilgisayar ayarları
      • /var/www/html — statik dosyalar

      Filtreleme node yönergeleri, /etc/nginx/sites-enabled/default dosyasında belirtilmelidir.

    • -p: Filtreleme node'unun dinlediği port. Değer, örnek portuyla aynı olmalıdır.

    • -e: Filtreleme node yapılandırmasını içeren ortam değişkenleri (kullanılabilir değişkenler aşağıdaki tabloda listelenmiştir). Lütfen WALLARM_API_TOKEN değerinin açıkça iletilmemesinin tavsiye edildiğini unutmayın.

      Environment variable Description Required
      WALLARM_API_TOKEN Wallarm node or API token. Yes
      WALLARM_API_HOST Wallarm API server:
      • us1.api.wallarm.com for the US Cloud
      • api.wallarm.com for the EU Cloud
      By default: api.wallarm.com.
      No
      WALLARM_LABELS

      Available starting from node 4.6. Works only if WALLARM_API_TOKEN is set to API token with the Deploy role. Sets the group label for node instance grouping, for example:

      WALLARM_LABELS="group=<GROUP>"

      ...will place node instance into the <GROUP> instance group (existing, or, if does not exist, it will be created).

      Yes (for API tokens)
      SLAB_ALLOC_ARENA (TARANTOOL_MEMORY_GB [NGINX Node 5.x and earlier][what-is-new-wstore]) Amount of memory allocated to wstore. The value can be a float (a dot . 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) but not exported to Wallarm Cloud. Meanwhile, API Discovery 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 if needed. More details
      By default: false.
      No
  9. Filtreleme node'unun çalışmasını test edin.

Filtreleme Node Çalışmasını Test Etme

  1. Alibaba Cloud Console'u açın → hizmetler listesi → Elastic Compute ServiceInstances ve örneğin IP address sütunundan genel IP adresini kopyalayın.

    Konteyner örneğinin kurulumu

    Eğer IP adresi boş ise, örneğin Running durumda olduğundan emin olun.

  2. Kopyaladığınız adrese test Path Traversal saldırısı içeren isteği gönderin:

    curl http://<COPIED_IP>/etc/passwd
    
  3. Wallarm Console'u açın → US Cloud veya EU Cloud içindeki Attacks bölümüne gidin ve saldırının listede görüntülendiğinden emin olun.
    UI'daki Saldırılar

Konteyner dağıtımı sırasında meydana gelen hataların ayrıntılarını görmek için, lütfen aşağıdaki yöntemlerden biriyle örneğe bağlanın ve konteyner günlüklerini kontrol edin. Eğer örnek kullanılamıyorsa, gerekli filtreleme node parametrelerinin doğru değerlerle konteynere iletildiğinden emin olun.