Ana içeriğe geç

AWS'e Wallarm Docker Görüntüsünün Dağıtımı

Bu hızlı rehber, NGINX tabanlı Wallarm node'un Docker görüntüsünü Amazon Elastic Container Service (Amazon ECS) kullanarak Amazon bulut platformuna dağıtmak için gerekli adımları sağlar.

The instructions limitations

Bu talimatlar, yük dengeleme ve node otomatik ölçeklendirmesinin yapılandırılmasını kapsamaz. Bu bileşenleri kendiniz kuruyorsanız, AWS instructions uygun bölümünü gözden geçirmenizi tavsiye ederiz.

Kullanım Senaryoları

Among all supported Wallarm deployment options, Wallarm deployment on AWS 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 AWS 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

  • admin yetkilerine sahip AWS hesabı ve kullanıcısı

  • Doğru bir şekilde kurulmuş ve yapılandırılmış AWS CLI 1 veya AWS CLI 2

  • US Cloud veya EU Cloud için Wallarm Console'da iki faktörlü kimlik doğrulaması kapalı olan Administrator rolüne sahip hesaba erişim

  • Saldırı tespit kuralları ve API specifications güncellemelerini indirmek; ayrıca allowlisted, denylisted, or graylisted ülkeler, bölgeler veya veri merkezleri için hassas IP'leri almak 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ırımı 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.

Ortam Değişkenleriyle Yapılandırılan Wallarm node Docker Konteynerinin Dağıtımı

Sadece ortam değişkenleriyle yapılandırılan kapsayıcı Wallarm filtreleme node'unu dağıtmak için AWS Management Console ve AWS CLI kullanılı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. AWS Management Console'a giriş yapın → Services listesinden → Elastic Container Service'i seçin.

  3. Create Cluster butonuna basarak küme oluşturma işlemine başlayın:

    1. EC2 Linux + Networking şablonunu seçin.
    2. Küme adını belirtin, örneğin: wallarm-cluster.
    3. Gerekirse, diğer ayarları AWS instructions yönergelerine göre yapılandırın.
    4. Küme kaydedin.
  4. Wallarm Cloud'a bağlanmak için gerekli hassas verileri (node token) AWS Secrets Manager veya AWS Systems Manager → Parameter Store kullanarak şifreleyin.

    Bu talimatlarda, hassas veriler AWS Secrets Manager'de saklanır.

    Access to the sensitive data storage

    Docker konteynerinin şifrelenmiş hassas verilere erişebilmesi için, lütfen AWS ayarlarının aşağıdaki gereksinimleri karşıladığından emin olun:

    • Hassas veriler, Docker konteynerinin çalıştığı bölgede saklanmalıdır.
    • executionRoleArn parametresinde belirtilen kullanıcıya SecretsManagerReadWrite IAM politikası eklenmiş olmalıdır. IAM policies setup hakkında daha fazla detay →
  5. Aşağıdaki yerel JSON dosyasını task definition ile oluşturun (task definition, Docker konteynerinin çalışma senaryosunu belirler):

    {
        "executionRoleArn": "arn:aws:iam::<AWS_ACCOUNT_ID>:role/ecsTaskExecutionRole",
        "containerDefinitions": [
            {
                "memory": 128,
                "portMappings": [
                   {
                       "hostPort": 80,
                       "containerPort": 80,
                       "protocol": "tcp"
                   }
                ],
                "essential": true,
                "environment": [
                   {
                       "name": "WALLARM_API_HOST",
                       "value": "us1.api.wallarm.com"
                   },
                   {
                       "name": "NGINX_BACKEND",
                       "value": "<HOST_TO_PROTECT_WITH_WALLARM>"
                   },
                   {
                       "name": "WALLARM_LABELS",
                       "value": "group=<GROUP>"
                   }
                ],
                "secrets": [
                   {
                       "name": "WALLARM_API_TOKEN",
                       "valueFrom": "arn:aws:secretsmanager:<SECRETS_MANAGER_AWS_REGION>:<AWS_ACCOUNT_ID>:secret:<SECRET_NAME>:<WALLARM_API_TOKEN_PARAMETER_NAME>::"
                   }
                ],
                "name": "wallarm-container",
                "image": "registry-1.docker.io/wallarm/node:5.3.0"
            }
        ],
        "family": "wallarm-api-security-node"
    }
    
    {
        "executionRoleArn": "arn:aws:iam::<AWS_ACCOUNT_ID>:role/ecsTaskExecutionRole",
        "containerDefinitions": [
            {
                "memory": 128,
                "portMappings": [
                   {
                       "hostPort": 80,
                       "containerPort": 80,
                       "protocol": "tcp"
                   }
                ],
                "essential": true,
                "environment": [
                   {
                       "name": "NGINX_BACKEND",
                       "value": "<HOST_TO_PROTECT_WITH_WALLARM>"
                   },
                   {
                       "name": "WALLARM_LABELS",
                       "value": "group=<GROUP>"
                   }
                ],
                "secrets": [
                   {
                       "name": "WALLARM_API_TOKEN",
                       "valueFrom": "arn:aws:secretsmanager:<SECRETS_MANAGER_AWS_REGION>:<AWS_ACCOUNT_ID>:secret:<SECRET_NAME>:<WALLARM_API_TOKEN_PARAMETER_NAME>::"
                   }
                ],
                "name": "wallarm-container",
                "image": "registry-1.docker.io/wallarm/node:5.3.0"
            }
        ],
        "family": "wallarm-api-security-node"
    }
    
    • <AWS_ACCOUNT_ID>: AWS hesap ID'niz.
    • environment nesnesi, Docker konteynerine metin formatında iletilmesi gereken ortam değişkenlerini ayarlar. Kullanılabilir ortam değişkenlerinin seti aşağıdaki tabloda açıklanmıştır. WALLARM_API_TOKEN değişkeninin secrets nesnesinde iletilmesi önerilir.
    • secret nesnesi, Docker konteynerine hassas veri deposuna yapılan bağlantılar şeklinde iletilmesi gereken ortam değişkenlerini ayarlar. Değerlerin formatı, seçilen depoya bağlıdır (daha fazla detay için AWS Secrets Manager veya AWS Systems Manager → Parameter Store dökümantasyonuna bakınız).

      WALLARM_API_TOKEN değişkeninin secrets nesnesinde iletilmesi önerilir.

      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
    • Tüm yapılandırma dosyası parametreleri AWS dökümantasyonunda açıklanmıştır.

  6. JSON yapılandırma dosyasına dayanarak aws ecs register‑task‑definition komutunu kullanarak task definition'ı kaydedin:

    aws ecs register-task-definition --cli-input-json file://<PATH_TO_JSON_FILE>/<JSON_FILE_NAME>
    
    • <PATH_TO_JSON_FILE>: JSON dosyasının yerel makinedeki yolu.
    • <JSON_FILE_NAME>: JSON dosyasının adı ve uzantısı.
  7. aws ecs run-task komutunu kullanarak görevi kümede çalıştırın:

    aws ecs run-task --cluster <CLUSTER_NAME> --launch-type EC2 --task-definition <FAMILY_PARAM_VALUE>
    
    • <CLUSTER_NAME>: İlk adımda oluşturulan kümenin adı. Örneğin, wallarm-cluster.
    • <FAMILY_PARAM_VALUE>: Oluşturulan task definition'ın adı. Bu değer, JSON dosyasında belirtilen family parametresiyle aynı olmalıdır. Örneğin, wallarm-api-security-node.
  8. AWS Management Console → Elastic Container Service → çalışan görevin bulunduğu küme → Tasks kısmını açın ve görevin listede görüntülendiğinden emin olun.

  9. Filtreleme node operasyonunu test edin.

Ayarlanmış Dosya ile Yapılandırılan Wallarm node Docker Konteynerinin Dağıtımı

Ortam değişkenleriyle yapılandırılan ve ayarlanmış dosya ile yapılandırılan kapsayıcı Wallarm filtreleme node'unu dağıtmak için AWS Management Console ve AWS CLI kullanılır.

Bu talimatlarda, yapılandırma dosyası AWS EFS dosya sisteminden monte edilmiştir. Dosya montajı için diğer yöntemleri AWS dökümantasyonunda inceleyebilirsiniz.

Ortam değişkenleriyle birlikte ve AWS EFS'den monte edilmiş yapılandırma dosyası ile konteyneri dağıtmak için:

  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. AWS Management Console'a giriş yapın → Services listesinden → Elastic Container Service'i seçin.

  3. Create Cluster butonuna basarak küme oluşturma işlemine başlayın:

    • Template: EC2 Linux + Networking.
    • Cluster name: örneğin, wallarm-cluster.
    • Provisioning Model: On-Demand Instance.
    • EC2 instance type: t2.micro.
    • Number of instances: 1.
    • EC2 AMI ID: Amazon Linux 2 Amazon ECS-optimized AMI.
    • Key pair: SSH bağlantısı için key pair. Yapılandırma dosyasını depolamaya yüklemek için instance’a SSH ile bağlanmanız gerekecektir.
    • Diğer ayarlar varsayılan bırakılabilir. Ek ayarları değiştirirken, AWS EFS kurulumu talimatlarını izlemeniz önerilir.
  4. AWS EFS depolamasını, AWS talimatlarının 2-4. adımlarını izleyerek yapılandırın.

  5. AWS talimatlarının 4. adımında, default adlı yapılandırma dosyasını oluşturun ve dosyayı varsayılan olarak monte edilen dosyaların bulunduğu dizine yerleştirin. default dosyası, filtreleme node yapılandırmasını içermelidir. Minimal ayarlarla 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önergeleri için monte edilebilecek direktifler →

  6. Wallarm Cloud'a bağlanmak için gerekli hassas verileri (node token) AWS Secrets Manager veya AWS Systems Manager → Parameter Store kullanarak şifreleyin.

    Bu talimatlarda, hassas veriler AWS Secrets Manager'de saklanır.

    Access to the sensitive data storage

    Docker konteynerinin şifrelenmiş hassas verilere erişebilmesi için, lütfen AWS ayarlarının aşağıdaki gereksinimleri karşıladığından emin olun:

    • Hassas veriler, Docker konteynerinin çalıştığı bölgede saklanmalıdır.
    • executionRoleArn parametresinde belirtilen kullanıcıya SecretsManagerReadWrite IAM politikası eklenmiş olmalıdır. IAM policies setup hakkında daha fazla detay →
  7. Aşağıdaki yerel JSON dosyasını task definition ile oluşturun (task definition, Docker konteynerinin çalışma senaryosunu belirler):

    {
        "executionRoleArn": "arn:aws:iam::<AWS_ACCOUNT_ID>:role/ecsTaskExecutionRole",
        "containerDefinitions": [
            {
                "memory": 128,
                "portMappings": [
                   {
                       "hostPort": 80,
                       "containerPort": 80,
                       "protocol": "tcp"
                   }
                ],
                "essential": true,
                "mountPoints": [
                   {
                       "containerPath": "<PATH_FOR_MOUNTED_CONFIG>",
                       "sourceVolume": "<NAME_FROM_VOLUMES_OBJECT>"
                   }
                ],
                "environment": [
                   {
                       "name": "WALLARM_API_HOST",
                       "value": "us1.api.wallarm.com"
                   },
                   {
                       "name": "WALLARM_LABELS",
                       "value": "group=<GROUP>"
                   }
                ],
                "secrets": [
                   {
                       "name": "WALLARM_API_TOKEN",
                       "valueFrom": "arn:aws:secretsmanager:<SECRETS_MANAGER_AWS_REGION>:<AWS_ACCOUNT_ID>:secret:<SECRET_NAME>:<WALLARM_API_TOKEN_PARAMETER_NAME>::"
                   }
                ],
                "name": "wallarm-container",
                "image": "registry-1.docker.io/wallarm/node:5.3.0"
            }
        ],
        "volumes": [
            {
                "name": "<VOLUME_NAME>",
                "efsVolumeConfiguration": {
                    "fileSystemId": "<EFS_FILE_SYSTEM_ID>",
                    "transitEncryption": "ENABLED"
                }
            }
        ],
        "family": "wallarm-api-security-node"
    }
    
    {
        "executionRoleArn": "arn:aws:iam::<AWS_ACCOUNT_ID>:role/ecsTaskExecutionRole",
        "containerDefinitions": [
            {
                "memory": 128,
                "portMappings": [
                   {
                       "hostPort": 80,
                       "containerPort": 80,
                       "protocol": "tcp"
                   }
                ],
                "essential": true,
                "mountPoints": [
                   {
                       "containerPath": "/etc/nginx/sites-enabled",
                       "sourceVolume": "default"
                   }
                ],
                "environment": [
                   {
                       "name": "WALLARM_LABELS",
                       "value": "group=<GROUP>"
                   }
                ],
                "secrets": [
                   {
                       "name": "WALLARM_API_TOKEN",
                       "valueFrom": "arn:aws:secretsmanager:<SECRETS_MANAGER_AWS_REGION>:<AWS_ACCOUNT_ID>:secret:<SECRET_NAME>:<WALLARM_API_TOKEN_PARAMETER_NAME>::"
                   }
                ],
                "name": "wallarm-container",
                "image": "registry-1.docker.io/wallarm/node:5.3.0"
            }
        ],
        "volumes": [
            {
                "name": "default",
                "efsVolumeConfiguration": {
                    "fileSystemId": "<EFS_FILE_SYSTEM_ID>",
                    "transitEncryption": "ENABLED"
                }
            }
        ],
        "family": "wallarm-api-security-node"
    }
    
    • <AWS_ACCOUNT_ID>: AWS hesap ID'niz.
    • <PATH_FOR_MOUNTED_CONFIG>: Yapılandırma dosyasının konteynere monte edileceği dizin. Yapılandırma dosyaları, NGINX tarafından aşağıdaki dizinlere 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.
      * <NAME_FROM_VOLUMES_OBJECT>: AWS EFS depolamasından monte edilen yapılandırma dosyasını içeren volumes nesnesinin adı (değer, <VOLUME_NAME> ile aynı olmalıdır).
      * <VOLUME_NAME>: AWS EFS depolamasından monte edilen yapılandırma dosyasının yapılandırmasını içeren volumes nesnesinin adı.
      * <EFS_FILE_SYSTEM_ID>: Konteynere monte edilmesi gereken dosyayı içeren AWS EFS dosya sisteminin ID'si. ID, AWS Management Console → ServicesEFSFile systems bölümünde görüntülenir.
      * environment nesnesi, Docker konteynerine metin formatında iletilmesi gereken ortam değişkenlerini ayarlar. Kullanılabilir ortam değişkenlerinin seti aşağıdaki tabloda açıklanmıştır. WALLARM_API_TOKEN değişkeninin secrets nesnesinde iletilmesi önerilir.
      * secret nesnesi, Docker konteynerine hassas veri deposuna bağlantılar şeklinde iletilmesi gereken ortam değişkenlerini ayarlar. Değerlerin formatı, seçilen depoya bağlıdır (daha fazla detay için AWS Secrets Manager veya AWS Systems Manager → Parameter Store dökümantasyonuna bakınız).

      WALLARM_API_TOKEN değişkeninin secrets nesnesinde iletilmesi önerilir.

      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
    • Tüm yapılandırma dosyası parametreleri AWS dökümantasyonunda açıklanmıştır.

  8. JSON yapılandırma dosyasına dayanarak aws ecs register‑task‑definition komutunu kullanarak task definition'ı kaydedin:

    aws ecs register-task-definition --cli-input-json file://<PATH_TO_JSON_FILE>/<JSON_FILE_NAME>
    
    • <PATH_TO_JSON_FILE>: JSON dosyasının yerel makinedeki yolu.
    • <JSON_FILE_NAME>: JSON dosyasının adı ve uzantısı.
  9. aws ecs run-task komutunu kullanarak görevi kümede çalıştırın:

    aws ecs run-task --cluster <CLUSTER_NAME> --launch-type EC2 --task-definition <FAMILY_PARAM_VALUE>
    
    • <CLUSTER_NAME>: İlk adımda oluşturulan kümenin adı. Örneğin, wallarm-cluster.
    • <FAMILY_PARAM_VALUE>: Oluşturulan task definition'ın adı. Bu değer, JSON dosyasında belirtilen family parametresiyle aynı olmalıdır. Örneğin, wallarm-api-security-node.
  10. AWS Management Console → Elastic Container Service → çalışan görevin bulunduğu küme → Tasks kısmını açın ve görevin listede görüntülendiğinden emin olun.

  11. Filtreleme node operasyonunu test edin.

Filtreleme Node Operasyonunun Test Edilmesi

  1. AWS Management Console'da, çalışan görevi açın ve External Link alanından konteynerin IP adresini kopyalayın.

    Settig up container instance

    Eğer IP adresi boşsa, lütfen konteynerin RUNNING durumunda olduğundan emin olun.

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

    curl http://<COPIED_IP>/etc/passwd
    
  3. Wallarm Console → Attacks bölümünü US Cloud veya EU Cloud üzerinden açın ve saldırının listede görüntülendiğinden emin olun.
    Attacks in UI

Konteyner dağıtımı sırasında meydana gelen hatalara ilişkin detaylar, AWS Management Console'daki görev detaylarında görüntülenir. Eğer konteyner erişilemez durumdaysa, lütfen konteynere doğru değerlerle iletilmesi gereken filtreleme node parametrelerinin sağlandığından emin olun.