انتقل إلى المحتوى

نشر صورة Docker التابعة لـ Wallarm على Azure

يقدم هذا الدليل السريع الخطوات اللازمة لنشر صورة Docker للعقدة التي تعتمد على NGINX لـ Wallarm على منصة السحابة Microsoft Azure باستخدام خدمة Azure Container Instances.

قيود التعليمات

هذه التعليمات لا تغطي تكوين توازن الحمولة والتطبيق التلقائي للعقدة. إذا قمت بإعداد هذه المكونات بنفسك، نوصي بقراءة التوثيق على Azure Application Gateway.

حالات الاستخدام

Among all supported Wallarm deployment options, Wallarm deployment on Azure Container Instances using the Docker image is recommended in these use cases:

  • If your applications leverage a microservices architecture, and are already containerized and operational on Azure Container Instances.

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

المتطلبات

خيارات تكوين حاوية 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 المحتواة والتي تم تكوينها فقط من خلال المتغيرات البيئية، يمكنك استخدام الأدوات التالية:

في هذه التعليمات، يتم نشر الحاوية باستخدام Azure CLI.

  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. قم بتسجيل الدخول إلى Azure CLI باستخدام الأمر az login:

    az login
    
  3. قم بإنشاء مجموعة موارد باستخدام الأمر az group create. على سبيل المثال، أنشئ الفرقة myResourceGroup في منطقة East US بالأمر التالي:

    az group create --name myResourceGroup --location eastus
    
  4. قم بتعيين المتغير البيئي المحلي برمز العقدة Wallarm الذي سيتم استخدامه لربط الوحدة بالسحابة Wallarm:

    export WALLARM_API_TOKEN='<WALLARM_API_TOKEN>'
    
  5. قم بإنشاء المورد Azure من حاوية Docker الخاصة بالعقدة Wallarm باستخدام الأمر az container create:

    az container create \
       --resource-group myResourceGroup \
       --name wallarm-node \
       --dns-name-label wallarm \
       --ports 80 \
       --image registry-1.docker.io/wallarm/node:4.10.4-1 \
       --environment-variables WALLARM_API_TOKEN=${WALLARM_API_TOKEN} NGINX_BACKEND='example.com' WALLARM_API_HOST='us1.api.wallarm.com' WALLARM_LABELS='group=<GROUP>'
    
    az container create \
       --resource-group myResourceGroup \
       --name wallarm-node \
       --dns-name-label wallarm \
       --ports 80 \
       --image registry-1.docker.io/wallarm/node:4.10.4-1 \
       --environment-variables WALLARM_API_TOKEN=${WALLARM_API_TOKEN} NGINX_BACKEND='example.com' WALLARM_LABELS='group=<GROUP>'
    
    • --resource-group: اسم مجموعة الموارد التي تم إنشاؤها في الخطوة الثانية.
    • --name: اسم الحاوية.
    • --dns-name-label: تسمية اسم DNS للحاوية.
    • --ports: النافذة التي تستمع العقدة التصفية عليها.
    • --image: اسم صورة Docker الخاصة بالعقدة Wallarm.
    • --environment-variables: المتغيرات البيئية بتكوينات العقدة التصفية (المتغيرات المتاحة مدرجة في الجدول أدناه). يرجى ملاحظة أنه لا يوصى بتمرير قيمة WALLARM_API_TOKEN بشكل صريح.

      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
  6. قم بفتح Azure portal وتأكد من عرض المورد المنشئ في قائمة الموارد.

  7. اختبر عملية تصفية العقدة.

نشر حاوية Docker للعقدة Wallarm المكوّنة من خلال الملف المثبت

لنشر العقدة التصفية الخاصة بـ Wallarm المحتواة والتي تم تكوينها من خلال المتغيرات البيئية والملف المثبت، يمكن استخدام Azure CLI فقط.

لنشر الحاوية بالمتغيرات البيئية وملف التكوين المثبت:

  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. قم بتسجيل الدخول إلى Azure CLI باستخدام الأمر az login:

    az login
    
  3. قم بإنشاء مجموعة موارد باستخدام الأمر az group create. على سبيل المثال، أنشئ الفرقة myResourceGroup في منطقة East US بالأمر التالي:

    az group create --name myResourceGroup --location eastus
    
  4. قم بإنشاء ملف التكوين المحلي مع إعدادات العقدة التصفية. على سبيل المثال، ملف بالإعدادات القليلة:

    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;
        }
    }
    

    مجموعة التوجيهات التصفية للعقدة التي يمكن تحديدها في ملف التكوين →

  5. حدد موقع الملف التكوين إحدى الطرق المناسبة لتثبيت أحجام البيانات في Azure. تتم مناقشة جميع الأساليب في قسم تثبيت أحجام البيانات لتوثيقات Azure.

    في هذه التعليمات، يتم تثبيت ملف التكوين من المستودع Git.

  6. قم بتعيين المتغير البيئي المحلي برمز العقدة Wallarm الذي سيتم استخدامه لربط الوحدة بالسحابة Wallarm:

    export WALLARM_API_TOKEN='<WALLARM_API_TOKEN>'
    
  7. قم بإنشاء مورد Azure من حاوية Docker الخاصة بالعقدة Wallarm باستخدام الأمر az container create:

    az container create \
       --resource-group myResourceGroup \
       --name wallarm-node \
       --dns-name-label wallarm \
       --ports 80 \
       --image registry-1.docker.io/wallarm/node:4.10.4-1 \
       --gitrepo-url <URL_OF_GITREPO> \
       --gitrepo-mount-path /etc/nginx/sites-enabled \
       --environment-variables WALLARM_API_TOKEN=${WALLARM_API_TOKEN} WALLARM_API_HOST='us1.api.wallarm.com' WALLARM_LABELS='group=<GROUP>'
    
    az container create \
       --resource-group myResourceGroup \
       --name wallarm-node \
       --dns-name-label wallarm \
       --ports 80 \
       --image registry-1.docker.io/wallarm/node:4.10.4-1 \
       --gitrepo-url <URL_OF_GITREPO> \
       --gitrepo-mount-path /etc/nginx/sites-enabled \
       --environment-variables WALLARM_API_TOKEN=${WALLARM_API_TOKEN} WALLARM_LABELS='group=<GROUP>'
    
    • --resource-group: اسم مجموعة الموارد التي تم إنشاؤها في الخطوة الثانية.
    • --name: اسم الحاوية.
    • --dns-name-label: تسمية اسم DNS للحاوية.
    • --ports: النافذة التي تستمع العقدة التصفية عليها.
    • --image: اسم صورة Docker الخاصة بالعقدة Wallarm.
    • --gitrepo-url: URL لمستودع Git الذي يحتوي على ملف التكوين. إذا كان الملف موجودًا في جذر المستودع، فكل ما تحتاج إليه هو تمرير هذا المعلمة فقط. إذا كان الملف موجود في دليل مستودع Git منفصل، يرجى مرور مسار الدليل في المعلمة --gitrepo-dir (على سبيل المثال،
      --gitrepo-dir ./dir1).
    • --gitrepo-mount-path: دليل الحاوية لتثبيت ملف التكوين عليه. يمكن تثبيت ملفات التكوين على الدلائل التالية من الحاوية التي يستخدمها NGINX:

      • /etc/nginx/conf.d — الإعدادات المشتركة
      • /etc/nginx/sites-enabled — إعدادات الاستضافة الافتراضية
      • /var/www/html — الملفات الثابتة

      يجب وصف توجيهات العقدة التصفية في ملف /etc/nginx/sites-enabled/default.

    • --environment-variables: المتغيرات البيئية التي تحتوي على إعدادات العقدة التصفية واتصال Wallarm Cloud (المتغيرات المتاحة مدرجة في الجدول أدناه). يرجى ملاحظة أنه لا يوصى بتمرير قيمة WALLARM_API_TOKEN بصراحة.

      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
  8. افتح Azure portal وتأكد من عرض المورد المنشئ في قائمة الموارد.

  9. اختبر عملية تصفية العقدة.

اختبار عملية تصفية العقدة

  1. افتح المورد المنشئ على Azure portal وانسخ قيمة FQDN.

    Settig up container instance

    إذا كان حقل FQDN فارغًا، يرجى التأكد من أن الحاوية في الحالة Running.

  2. أرسل الطلب بالهجوم Path Traversal الاختباري إلى النطاق المنسوخ:

    curl http://<COPIED_DOMAIN>/etc/passwd
    
  3. افتح Wallarm Console → Attacks في السحابة الأمريكية أو السحابة الأوروبية وتأكد من عرض الهجوم في القائمة.
    Attacks in UI

تظهر التفاصيل الخاصة بالأخطاء التي حدثت أثناء نشر الحاوية على التبويب ContainersLogs من تفاصيل المورد على Azure portal. إذا كان المورد غير متوفر، يرجى التأكد من تمرير الوحدة المطلوبة للعقدة التصفية بقيم صحيحة إلى الحاوية.