نشر صورة Docker لـ Wallarm على AWS¶
يقدم هذا الدليل السريع الخطوات لنشر صورة Docker للعقدة Wallarm باستخدام NGINX على منصة السحابة Amazon باستخدام خدمة الحاويات المرنة من Amazon (Amazon ECS).
قيود التعليمات
هذه التعليمات لا تغطي تكوين التوازن الحمولي وتكبير العقدة تلقائيًا. إذا كنت تقوم بإعداد هذه المكونات بنفسك, نوصي أن تراجع جزءاً مناسباً من تعليمات AWS.
حالات الاستخدام¶
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.
المتطلبات¶
-
حساب AWS ومستخدم بصلاحيات مدير
-
الوصول إلى الحساب بدور المدير وتعطيل التوثيق ذو العاملين في وحدة تحكم Wallarm لـ السحابة الأمريكية أو السحابة الأوروبية
خيارات تكوين حاوية Docker للعقدة Wallarm¶
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.
نشر حاوية Docker للعقدة Wallarm المكونة عبر المتغيرات البيئية¶
لنشر العقدة الفلترة لـ Wallarm المحسنة في حاوية عبر المتغيرات البيئية فقط، يتم استخدام وحدة تحكم AWS و AWS CLI.
-
Get Wallarm token of the appropriate type:
-
قم بتسجيل الدخول إلى وحدة تحكم AWS → قائمة الخدمات → خدمة الحاويات المرنة.
-
انتقل إلى إنشاء الكتلة عبر الزر إنشاء الكتلة :
- حدد القالب EC2 Linux + Networking.
- حدد اسم الكتلة، على سبيل المثال:
wallarm-cluster
. - إذا كان لازماً، قم بتعيين الإعدادات الأخرى بتتبع تعليمات AWS.
- حفظ الكتلة.
-
قم بتشفير البيانات الحساسة المطلوبة للاتصال بـ Cloud Wallarm (رمز العقدة) باستخدام إدارة الأسرار AWS أو نظام AWS Manager → متجر البارامتر.
في هذه التعليمات، يتم تخزين البيانات الحساسة في إدارة الأسرار AWS.
الوصول إلى تخزين البيانات الحساسة
للسماح للحاوية Docker بقراءة البيانات الحساسة المشفرة، يرجى التأكد من أن إعدادات AWS تلبي الشروط التالية:
- البيانات الحساسة مخزنة في المنطقة المستخدمة لتشغيل حاوية Docker.
- سياسة IAM SecretsManagerReadWrite مرتبطة بالمستخدم المحدد في البارامتر
executionRoleArn
لتعريف المهمة. المزيد من التفاصيل عن إعداد سياسات IAM →
-
قم بإنشاء الملف الـ JSON المحلي التالي بـتعريف المهمة (يحدد تعريف المهمة سيناريو تشغيل الحاوية Docker) :
{ "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:4.10.4-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:4.10.4-1" } ], "family": "wallarm-api-security-node" }
<AWS_ACCOUNT_ID>
: معرف حساب AWS الخاص بك.- يكون الكائن
environment
مجموعة المتغيرات البيئية التي يجب تمريرها إلى حاوية Docker في شكل نصي. يتم توصيف مجموعة المتغيرات البيئية المتاحة في الجدول أدناه. يوصى بتمرير المتغيرWALLARM_API_TOKEN
في الكائنsecrets
. -
يضبط الكائن
secret
المتغيرات البيئية التي يجب تمريرها إلى حاوية Docker كروابط لتخزين البيانات الحساسة. يعتمد شكل القيم على التخزين المحدد (انظر المزيد من التفاصيل في AWS Secrets Manager أو AWS Systems Manager → متجر البارامتر التوثيق).يُوصى بتمرير المتغير
WALLARM_API_TOKEN
في الكائنsecrets
.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][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 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 -
توضح جميع معلمات الملف التكويني في توثيق AWS.
-
قم بتسجيل تعريف المهمة استناداً إلى الملف التكويني JSON باستخدام الأمر
aws ecs register‑task‑definition
:<PATH_TO_JSON_FILE>
: الرابط إلى الملف JSON مع تعريف المهمة على الجهاز المحلي.<JSON_FILE_NAME>
: اسم وإمتداد الملف JSON مع تعريف المهمة.
-
تشغيل المهمة في الكتلة استخدام الامر
aws ecs run-task
:<CLUSTER_NAME>
: اسم الكتلة التي تم إنشاؤها في الخطوة الأولى. على سبيل المثال،wallarm-cluster
.<FAMILY_PARAM_VALUE>
: اسم تعريف المهمة المُنشأ. يجب أن تتوافق القيمة مع قيمة البارامترfamily
المحددة في الملف JSON مع تعريف المهمة. على سبيل المثال،wallarm-api-security-node
.
-
افتح وحدة تحكم AWS → خدمة الحاويات المرنة → الكتلة مع المهمة المُشغلة → المهام وتأكد من عرض المهمة في القائمة.
نشر حاوية Docker للعقدة Wallarm المكونة من خلال الملف المثبت¶
لنشر العقدة الفلترة لـ Wallarm المحسنة في حاوية عن طريق المتغيرات البيئية والملف المثبت، يتم استخدام وحدة تحكم AWS و AWS CLI.
في هذه التعليمات، يتم تركيب الملف التكويني من نظام الملفات AWS EFS. يمكنك مراجعة الأساليب الأخرى لتركيب الملف في التوثيق AWS.
لنشر الحاوية مع المتغيرات البيئية وملف التكوين المركب من AWS EFS:
-
Get Wallarm token of the appropriate type:
-
قم بتسجيل الدخول إلى وحدة تحكم AWS → القائمة الخدمات → خدمة الحاويات المرنة.
-
انتقل إلى إنشاء الكتلة بواسطة الزر إنشاء الكتلة:
- قالب:
EC2 Linux + Networking
. - اسم الكتلة:
wallarm-cluster
(كمثال). - نموذج الإعداد:
على الطلب الفوري
. - نوع الحالة EC2:
t2.micro
. - عدد الحالات:
1
. - معرّف EC2 AMI:
صورة AMI TTL منتظمة من Amazon Linux 2
. - زوج المفاتيح: زوج المفاتيح للاتصال SSH بالحالة. سوف تحتاج إلى الاتصال بالحالة عبر SSH لتحميل ملف التكوين إلى التخزين.
- يمكن ترك الإعدادات الأخرى وفقًا للإعدادات الافتراضية. عند تغيير الإعدادات الأخرى، يُوصى باتباع التعليمات المتعلقة بإعداد AWS EFS.
- قالب:
-
قم بتكوين تخزين AWS EFS وفقاً لخطوات 2-4 من التعليمات AWS.
-
في الخطوة الرابعة من التعليمات AWS، قم بإنشاء ملف التكوين
default
ووضع الملف في الدليل الذي يخزن الملفات للتعليق بشكل افتراضي. يجب أن يغطي ملفdefault
الضبط الفلترة. مثال على الملف مع الإعدادات الدنيا: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; } }
-
قم بتشفير البيانات الحساسة المطلوبة للاتصال بـ Cloud Wallarm (رمز العقدة) باستخدام إدارة الأسرار AWS أو نظام AWS Manager → متجر البارامتر.
في هذه التعليمات، يتم تخزين البيانات الحساسة في إدارة الأسرار AWS.
الوصول إلى تخزين البيانات الحساسة
للسماح للحاوية Docker بقراءة البيانات الحساسة المشفرة، يرجى التأكد من أن إعدادات AWS تلبي الشروط التالية:
- البيانات الحساسة مخزنة في المنطقة المستخدمة لتشغيل حاوية Docker.
- سياسة IAM SecretsManagerReadWrite مرتبطة بالمستخدم المحدد في البارامتر
executionRoleArn
لتعريف المهمة. المزيد من التفاصيل عن إعداد سياسات IAM →
-
قم بإنشاء الملف الـ JSON المحلي التالي بـتعريف المهمة (يحدد تعريف المهمة سيناريو تشغيل الحاوية Docker) :
{ "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:4.10.4-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/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:4.10.4-1" } ], "volumes": [ { "name": "default", "efsVolumeConfiguration": { "fileSystemId": "<EFS_FILE_SYSTEM_ID>", "transitEncryption": "ENABLED" } } ], "family": "wallarm-api-security-node" }
<AWS_ACCOUNT_ID>
: معرف حساب AWS الخاص بك.-
<PATH_FOR_MOUNTED_CONFIG>
: دليل الحاوية لتركيب ملف التكوين عليها. يمكن تثبيت ملفات التكوين على الدلائل التالية المستخدمة من قبل NGINX:/etc/nginx/conf.d
— الإعدادات العامة/etc/nginx/sites-enabled
— إعدادات المضيف الافتراضي/var/www/html
— الملفات الثابتة
يجب أن يتم وصف التوجيهات الفلترة في ملف
/etc/nginx/sites-enabled/default
. -
<NAME_FROM_VOLUMES_OBJECT>
: اسم الكائنvolumes
الذي يحتوي على تكوين تخزين الملف المثبت في AWS EFS (يجب أن تكون القيمة نفسها باسم<VOLUME_NAME>
). <VOLUME_NAME>
: اسم الكائنvolumes
الذي يحتوي على تكوين تخزين الملف المثبت في AWS EFS.<EFS_FILE_SYSTEM_ID>
: معرف نظام الملفات EFS الذي يحتوي على الملف الذي يجب تثبيته على الحاوية. يتم عرض المعرف في وحدة تحكم AWS → الخدمات → EFS → أنظمة الملف.- يكون الكائن
environment
مجموعة المتغيرات البيئية التي يجب تمريرها إلى حاوية Docker في شكل نصي. يتم توصيف مجموعة المتغيرات البيئية المتاحة في الجدول أدناه. يوصى بتمرير المتغيرWALLARM_API_TOKEN
في الكائنsecrets
. -
يضبط الكائن
secret
المتغيرات البيئية التي يجب تمريرها إلى حاوية Docker كروابط لتخزين البيانات الحساسة. يعتمد شكل القيم على التخزين المحدد (انظر المزيد من التفاصيل في AWS Secrets Manager أو AWS Systems Manager → متجر البارامتر التوثيق).يُوصى بتمرير المتغير
WALLARM_API_TOKEN
في الكائنsecrets
.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][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 -
توضح جميع معلمات الملف التكويني في توثيق AWS.
-
قم بتسجيل تعريف المهمة استناداً إلى الملف التكويني JSON باستخدام الأمر
aws ecs register‑task‑definition
:<PATH_TO_JSON_FILE>
: الرابط إلى الملف JSON مع تعريف المهمة على الجهاز المحلي.<JSON_FILE_NAME>
: اسم وإمتداد الملف JSON مع تعريف المهمة.
-
تشغيل المهمة في الكتلة استخدام الامر
aws ecs run-task
:<CLUSTER_NAME>
: اسم الكتلة التي تم إنشاؤها في الخطوة الأولى. على سبيل المثال،wallarm-cluster
.<FAMILY_PARAM_VALUE>
: اسم تعريف المهمة المُنشأ. يجب أن تتوافق القيمة مع قيمة البارامترfamily
المحددة في الملف JSON مع تعريف المهمة. على سبيل المثال،wallarm-api-security-node
.
-
افتح وحدة تحكم AWS → خدمة الحاويات المرنة → الكتلة مع المهمة المُشغلة → المهام وتأكد من عرض المهمة في القائمة.
اختبار تشغيل العقدة الفلترة¶
-
في وحدة تحكم AWS، افتح المهمة المشتغلة وانسخ عنوان IP الخاص بالحاوية من الحقل الرابط الخارجي.
إذا كان عنوان IP فارغاً، يرجى التأكد من أن الحاوية في حالة التشغيل.
-
أرسل الطلب مع الهجوم Path Traversal إلى العنوان المنسوخ:
-
افتح وحدة تحكم Wallarm → الهجمات في السحابة الأمريكية أو السحابة الأوروبية وتأكد من أن الهجوم مُعروض في القائمة.
تتم عرض التفاصيل حول الأخطاء التي حدثت أثناء نشر الحاوية في تفاصيل المهمة في وحدة تحكم AWS. إذا كانت الحاوية غير متاحة، يرجى التأكد من تمرير المعلمات المطلوبة للعقدة الفلترة مع القيم الصحيحة إلى الحاوية.