Wallarm Docker İmajının AWS'ye Dağıtımı¶
Bu hızlı kılavuz, NGINX tabanlı Wallarm düğümünün Docker imajını, Amazon Elastic Container Service (Amazon ECS) kullanarak Amazon bulut platformuna dağıtma adımlarını sağlar.
Talimatların sınırlamaları
Bu talimatlar, yük dengeleme ve düğüm otomatik ölçeklendirme yapılandırmasını kapsamaz. Bu bileşenleri kendiniz kuracaksanız, AWS talimatlarının ilgili bölümünü incelemenizi öneririz.
Güvenlik notu
Bu çözüm, AWS güvenlik en iyi uygulamalarını takip edecek şekilde tasarlanmıştır. Dağıtım için AWS kök hesabını kullanmaktan kaçınmanızı öneririz. Bunun yerine, sadece gerekli izinlere sahip IAM kullanıcılarını veya rolleri kullanın.
Dağıtım süreci, Wallarm bileşenlerini sağlamak ve işletmek için yalnızca asgari erişimin verildiği en az ayrıcalık ilkesini varsayar.
Bu dağıtım için AWS altyapı maliyetlerini tahmin etmeye yönelik rehberlik için AWS'de Wallarm Dağıtımı İçin Maliyet Rehberi sayfasına bakın.
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 izinlerine sahip AWS hesabı ve kullanıcısı
-
AWS CLI 1 veya AWS CLI 2'nin doğru şekilde kurulmuş ve yapılandırılmış olması
-
US Cloud veya EU Cloud için Wallarm Console'da Administrator rolüne sahip hesaba erişim
-
Saldırı tespit kurallarına ve API spesifikasyonlarına güncellemeleri indirmek ve ayrıca allowlist'e, denylist'e veya graylist'e alınmış ülkeleriniz, bölgeleriniz veya veri merkezleriniz için kesin IP'leri almak amacıyla aşağıdaki IP adreslerine erişim
Wallarm düğümü Docker konteyneri yapılandırma seçenekleri¶
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ılmış Wallarm düğümü Docker konteynerinin dağıtımı¶
Yalnızca ortam değişkenleriyle yapılandırılan konteynerleştirilmiş Wallarm filtreleme düğümünü dağıtmak için AWS Management Console ve AWS CLI kullanılır.
-
Get Wallarm token of the appropriate type:
-
AWS Management Console → Services listesi → Elastic Container Service bölümüne giriş yapın.
-
Create Cluster düğmesi ile küme oluşturma işlemine ilerleyin:
- Şablon olarak EC2 Linux + Networking seçin.
- Küme adını belirtin, örneğin:
wallarm-cluster
. - Gerekirse, diğer ayarları AWS talimatlarını izleyerek yapın.
- Kümeyi kaydedin.
-
Wallarm Cloud’a bağlanmak için gereken hassas verileri (düğüm belirteci) AWS Secrets Manager veya AWS Systems Manager → Parameter Store kullanarak şifreleyin.
Bu talimatlarda, hassas veriler AWS Secrets Manager’da saklanır.
Hassas veri deposuna erişim
Docker konteynerinin şifrelenmiş hassas verileri okuyabilmesi için AWS ayarlarının aşağıdaki gereksinimleri karşıladığından emin olun:
- Hassas veriler, Docker konteynerinin çalıştırıldığı bölgedeki depoda saklanır.
- SecretsManagerReadWrite IAM politikası, görev tanımındaki
executionRoleArn
parametresinde belirtilen kullanıcıya iliştirilmiştir. IAM politikaları kurulumu hakkında daha fazla bilgi →
-
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:6.5.1" } ], "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:6.5.1" } ], "family": "wallarm-api-security-node" }
<AWS_ACCOUNT_ID>
: AWS hesap kimliğiniz.environment
nesnesi, Docker konteynerine metin formatında iletilmesi gereken ortam değişkenlerini ayarlar. Kullanılabilir ortam değişkenlerinin kümesi aşağıdaki tabloda açıklanmıştır.WALLARM_API_TOKEN
değişkenininsecrets
nesnesi içinde iletilmesi önerilir.-
secret
nesnesi, ortam değişkenlerinin hassas veri deposuna bağlantılar olarak Docker konteynerine iletilmesini ayarlar. Değerlerin formatı seçilen depoya bağlıdır (daha fazla bilgi için AWS Secrets Manager veya AWS Systems Manager → Parameter Store belgelerine bakın).WALLARM_API_TOKEN
değişkenininsecrets
nesnesi içinde 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 theDeploy
role. Sets thegroup
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 Cloudapi.wallarm.com
for the EU Cloud
api.wallarm.com
.No WALLARM_MODE
Node mode: block
to block malicious requestssafe_blocking
to block only those malicious requests originated from graylisted IP addressesmonitoring
to analyze but not block requestsoff
to disable traffic analyzing and processing
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)Amount of memory allocated to wstore. The value can be a float (a dot .
is a decimal separator). By default: 1.0 (1 gygabyte).
Note that when passing this variable in Dockerrun
command with the-e
, the variable is not recorded in any configuration file within the container, but it is still used whenwstore
starts.No NGINX_PORT
Sets a port that NGINX will use inside the Docker container.
Starting from the Docker image4.0.2-1
, thewallarm-status
service automatically runs on the same port as NGINX.
Default value (if the variable is not passed to the container) is80
.
Syntax isNGINX_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 istrue
, 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 APIFW_METRICS_ENABLED
(6.4.1 and higher)Enables Prometheus metrics for the API Specification Enforcement module.
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.
By default::9010
.No APIFW_METRICS_ENDPOINT_NAME
(6.4.1 and higher)Defines the HTTP path of the API Specification Enforcement metrics endpoint
By default:metrics
.No WALLARM_WSTORE__METRICS__LISTEN_ADDRESS
Defines the host and port on which [Postanalytics and general system metrics][wstore-metrics] are exposed.
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: "tcp"
- dual-stack mode (listens on both IPv4 and IPv6)"tcp4"
- IPv4 only"tcp6"
- IPv6 only
"tcp4"
.No -
Tüm yapılandırma dosyası parametreleri AWS belgelerinde açıklanmıştır.
-
JSON yapılandırma dosyasına dayalı görev tanımını
aws ecs register‑task‑definition
komutunu kullanarak kaydedin:<PATH_TO_JSON_FILE>
: yerel makinedeki görev tanımı JSON dosyasının yolu.<JSON_FILE_NAME>
: görev tanımı JSON dosyasının adı ve uzantısı.
-
Kümede görevi
aws ecs run-task
komutunu kullanarak çalıştırın:<CLUSTER_NAME>
: ilk adımda oluşturulan kümenin adı. Örneğin,wallarm-cluster
.<FAMILY_PARAM_VALUE>
: oluşturulan görev tanımının adı. Değer, görev tanımı JSON dosyasında belirtilenfamily
parametresi değeriyle aynı olmalıdır. Örneğin,wallarm-api-security-node
.
-
AWS Management Console → Elastic Container Service → çalışan göreve sahip küme → Tasks bölümünü açın ve görevin listede görüntülendiğinden emin olun.
Bağlanmış dosya ile yapılandırılmış Wallarm düğümü Docker konteynerinin dağıtımı¶
Ortam değişkenleri ve bağlanmış dosya ile yapılandırılmış konteynerleştirilmiş Wallarm filtreleme düğümünü dağıtmak için AWS Management Console ve AWS CLI kullanılır.
Bu talimatlarda, yapılandırma dosyası AWS EFS dosya sisteminden bağlanır. Dosyayı bağlamanın diğer yöntemlerini AWS belgelerinde inceleyebilirsiniz.
AWS EFS'den bağlanmış yapılandırma dosyası ve ortam değişkenleri ile konteyneri dağıtmak için:
-
Get Wallarm token of the appropriate type:
-
AWS Management Console → Services listesi → Elastic Container Service bölümüne giriş yapın.
-
Create Cluster düğmesi ile küme oluşturma işlemine ilerleyin:
- Template:
EC2 Linux + Networking
. - Cluster name:
wallarm-cluster
(örnek olarak). - 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: örnekteki için SSH bağlantısı için key pair. Yapılandırma dosyasını depoya yüklemek için örneğe SSH ile bağlanmanız gerekecektir.
- Diğer ayarlar varsayılan olarak bırakılabilir. Diğer ayarları değiştirirken, AWS EFS kurulumu talimatlarının izlenmesi önerilir.
- Template:
-
AWS EFS depolamayı AWS talimatlarının 2-4. adımlarını izleyerek yapılandırın.
-
AWS talimatlarının 4. adımında,
default
adlı yapılandırma dosyasını oluşturun ve dosyayı varsayılan olarak bağlama için kullanılan dosyaları depolayan dizine yerleştirin.default
dosyası filtreleme düğümü yapılandırmasını kapsamalıdır. Asgari ayarlara sahip 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; } }
Yapılandırma dosyasında belirtilebilecek filtreleme düğümü direktifleri kümesi →
-
Wallarm Cloud’a bağlanmak için gereken hassas verileri (düğüm belirteci) AWS Secrets Manager veya AWS Systems Manager → Parameter Store kullanarak şifreleyin.
Bu talimatlarda, hassas veriler AWS Secrets Manager’da saklanır.
Hassas veri deposuna erişim
Docker konteynerinin şifrelenmiş hassas verileri okuyabilmesi için AWS ayarlarının aşağıdaki gereksinimleri karşıladığından emin olun:
- Hassas veriler, Docker konteynerinin çalıştırıldığı bölgedeki depoda saklanır.
- SecretsManagerReadWrite IAM politikası, görev tanımındaki
executionRoleArn
parametresinde belirtilen kullanıcıya iliştirilmiştir. IAM politikaları kurulumu hakkında daha fazla bilgi →
-
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:6.5.1" } ], "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/http.d", "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:6.5.1" } ], "volumes": [ { "name": "default", "efsVolumeConfiguration": { "fileSystemId": "<EFS_FILE_SYSTEM_ID>", "transitEncryption": "ENABLED" } } ], "family": "wallarm-api-security-node" }
<AWS_ACCOUNT_ID>
: AWS hesap kimliğiniz.-
<PATH_FOR_MOUNTED_CONFIG>
: yapılandırma dosyasının bağlanacağı konteyner dizini. Yapılandırma dosyaları, NGINX tarafından kullanılan aşağıdaki konteyner dizinlerine bağlanabilir:/etc/nginx/conf.d
— ortak ayarlar/etc/nginx/http.d
— sanal ana bilgisayar ayarları/var/www/html
— statik dosyalar
Filtreleme düğümü direktifleri
/etc/nginx/http.d/default.conf
dosyasında tanımlanmalıdır. -
<NAME_FROM_VOLUMES_OBJECT>
: bağlanan dosyanın AWS EFS depolama yapılandırmasını içerenvolumes
nesnesinin adı (<VOLUME_NAME>
ile aynı olmalıdır). <VOLUME_NAME>
: bağlanan dosyanın AWS EFS depolama yapılandırmasını içerenvolumes
nesnesinin adı.<EFS_FILE_SYSTEM_ID>
: konteynere bağlanması gereken dosyayı içeren AWS EFS dosya sisteminin kimliği. Kimlik, AWS Management Console → Services → EFS → File 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 kümesi aşağıdaki tabloda açıklanmıştır.WALLARM_API_TOKEN
değişkenininsecrets
nesnesi içinde iletilmesi önerilir.-
secret
nesnesi, ortam değişkenlerinin hassas veri deposuna bağlantılar olarak Docker konteynerine iletilmesini ayarlar. Değerlerin formatı seçilen depoya bağlıdır (daha fazla bilgi için AWS Secrets Manager veya AWS Systems Manager → Parameter Store belgelerine bakın).WALLARM_API_TOKEN
değişkenininsecrets
nesnesi içinde 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 Cloudapi.wallarm.com
for the EU Cloud
api.wallarm.com
.No WALLARM_LABELS
Available starting from node 4.6. Works only if
WALLARM_API_TOKEN
is set to API token with theDeploy
role. Sets thegroup
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)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 APIFW_METRICS_ENABLED
(6.4.1 and higher)Enables Prometheus metrics for the API Specification Enforcement module.
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.
By default::9010
.No APIFW_METRICS_ENDPOINT_NAME
(6.4.1 and higher)Defines the HTTP path of the API Specification Enforcement metrics endpoint
By default:metrics
.No WALLARM_WSTORE__METRICS__LISTEN_ADDRESS
Defines the host and port on which [Postanalytics and general system metrics][wstore-metrics-mount] are exposed.
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: "tcp"
- dual-stack mode (listens on both IPv4 and IPv6)"tcp4"
- IPv4 only"tcp6"
- IPv6 only
"tcp4"
.No -
Tüm yapılandırma dosyası parametreleri AWS belgelerinde açıklanmıştır.
-
JSON yapılandırma dosyasına dayalı görev tanımını
aws ecs register‑task‑definition
komutunu kullanarak kaydedin:<PATH_TO_JSON_FILE>
: yerel makinedeki görev tanımı JSON dosyasının yolu.<JSON_FILE_NAME>
: görev tanımı JSON dosyasının adı ve uzantısı.
-
Kümede görevi
aws ecs run-task
komutunu kullanarak çalıştırın:<CLUSTER_NAME>
: ilk adımda oluşturulan kümenin adı. Örneğin,wallarm-cluster
.<FAMILY_PARAM_VALUE>
: oluşturulan görev tanımının adı. Değer, görev tanımı JSON dosyasında belirtilenfamily
parametresi değeriyle aynı olmalıdır. Örneğin,wallarm-api-security-node
.
-
AWS Management Console → Elastic Container Service → çalışan göreve sahip küme → Tasks bölümünü açın ve görevin listede görüntülendiğinden emin olun.
Filtreleme düğümünün çalışmasının test edilmesi¶
-
AWS Management Console’da, çalışan görevi açın ve konteynerin IP adresini External Link alanından kopyalayın.
IP adresi boşsa, lütfen konteynerin RUNNING durumunda olduğundan emin olun.
-
Kopyalanan adrese test Path Traversal saldırısı içeren isteği gönderin:
-
Wallarm Console → Attacks bölümünü US Cloud veya EU Cloud ortamında açın ve saldırının listede görüntülendiğinden emin olun.
-
İsteğe bağlı olarak, düğümün diğer çalışma yönlerini [test edin][link-docs-check-operation].
Konteyner dağıtımı sırasında oluşan hatalara ilişkin ayrıntılar, AWS Management Console’daki görev ayrıntılarında görüntülenir. Konteyner erişilemezse, gerekli filtreleme düğümü parametrelerinin doğru değerlerle konteynere iletildiğinden emin olun.