コンテンツにスキップ

AzureへのWallarm Dockerイメージのデプロイ

このクイックガイドでは、NGINXベースのWallarmノードのDockerイメージAzure Container Instancesサービスを使用してMicrosoft Azureクラウドプラットフォームにデプロイする手順を説明します。

この手順の制限事項

本手順には負荷分散およびノードの自動スケーリングの設定は含まれていません。これらのコンポーネントを自身で設定する場合は、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.

前提条件

  • 有効なAzureサブスクリプション

  • Azure CLIがインストールされていること

  • US CloudまたはEU CloudのWallarm ConsoleでAdministratorロールを持つアカウントへのアクセス

  • 攻撃検出ルールやAPI仕様の更新をダウンロードし、さらにallowlisted、denylisted、graylistedの国・地域・データセンターの正確なIPを取得するために、以下のIPアドレスへのアクセス

    node-data0.us1.wallarm.com - 34.96.64.17
    node-data1.us1.wallarm.com - 34.110.183.149
    us1.api.wallarm.com - 35.235.66.155
    34.102.90.100
    34.94.156.115
    35.235.115.105
    
    node-data1.eu1.wallarm.com - 34.160.38.183
    node-data0.eu1.wallarm.com - 34.144.227.90
    api.wallarm.com - 34.90.110.226
    

WallarmノードDockerコンテナーの構成オプション

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.

環境変数で構成されたWallarmノードDockerコンテナーのデプロイ

環境変数のみで構成されたコンテナ化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. az loginコマンドでAzure CLIにサインインします:

    az login
    
  3. az group createコマンドでリソースグループを作成します。例えば、以下のコマンドでEast USリージョンにmyResourceGroupグループを作成します:

    az group create --name myResourceGroup --location eastus
    
  4. インスタンスをWallarm Cloudに接続するために使用するWallarmノードトークンをローカル環境変数に設定します:

    export WALLARM_API_TOKEN='<WALLARM_API_TOKEN>'
    
  5. az container createコマンドを使用して、WallarmノードDockerコンテナーからAzureリソースを作成します:

    az container create \
       --resource-group myResourceGroup \
       --name wallarm-node \
       --dns-name-label wallarm \
       --ports 80 \
       --image registry-1.docker.io/wallarm/node:6.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:6.4.1 \
       --environment-variables WALLARM_API_TOKEN=${WALLARM_API_TOKEN} NGINX_BACKEND='example.com' WALLARM_LABELS='group=<GROUP>'
    
    • --resource-group: 2番目の手順で作成したリソースグループ名。
    • --name: コンテナー名。
    • --dns-name-label: コンテナーのDNS名ラベル。
    • --ports: フィルタリングノードが待ち受けるポート。
    • --image: WallarmノードDockerイメージ名。
    • --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) 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
      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 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
      By default: "tcp4".
      No
  6. Azure portalを開き、作成したリソースがリソース一覧に表示されていることを確認します。

  7. フィルタリングノードの動作をテストします。

マウントしたファイルで構成されたWallarmノードDockerコンテナーのデプロイ

環境変数とマウントしたファイルで構成されたコンテナ化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. az loginコマンドでAzure CLIにサインインします:

    az login
    
  3. az group createコマンドでリソースグループを作成します。例えば、以下のコマンドでEast USリージョンにmyResourceGroupグループを作成します:

    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 Cloudに接続するために使用するWallarmノードトークンをローカル環境変数に設定します:

    export WALLARM_API_TOKEN='<WALLARM_API_TOKEN>'
    
  7. az container createコマンドを使用して、WallarmノードDockerコンテナーからAzureリソースを作成します:

    az container create \
       --resource-group myResourceGroup \
       --name wallarm-node \
       --dns-name-label wallarm \
       --ports 80 \
       --image registry-1.docker.io/wallarm/node:6.4.1 \
       --gitrepo-url <URL_OF_GITREPO> \
       --gitrepo-mount-path /etc/nginx/http.d \
       --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:6.4.1 \
       --gitrepo-url <URL_OF_GITREPO> \
       --gitrepo-mount-path /etc/nginx/http.d \
       --environment-variables WALLARM_API_TOKEN=${WALLARM_API_TOKEN} WALLARM_LABELS='group=<GROUP>'
    
    • --resource-group: 2番目の手順で作成したリソースグループ名。
    • --name: コンテナー名。
    • --dns-name-label: コンテナーのDNS名ラベル。
    • --ports: フィルタリングノードが待ち受けるポート。
    • --image: WallarmノードDockerイメージ名。
    • --gitrepo-url: 構成ファイルを含むGitリポジトリのURL。ファイルがリポジトリのルートにある場合はこのパラメータのみを渡します。ファイルがGitリポジトリ内の別ディレクトリにある場合は、--gitrepo-dirパラメータにディレクトリへのパスも渡してください(例:
      --gitrepo-dir ./dir1)。
    • --gitrepo-mount-path: 構成ファイルをマウントするコンテナー内のディレクトリ。構成ファイルは、NGINXが使用する次のコンテナーディレクトリにマウントできます:

      • /etc/nginx/conf.d — 共通設定
      • /etc/nginx/http.d — 仮想ホスト設定
      • /var/www/html — 静的ファイル

      フィルタリングノードのディレクティブは/etc/nginx/http.d/default.confファイルに記述します。

    • --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) 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__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
      By default: "tcp4".
      No
  8. Azure portalを開き、作成したリソースがリソース一覧に表示されていることを確認します。

  9. フィルタリングノードの動作をテストします。

フィルタリングノードの動作テスト

  1. Azure portalで作成済みリソースを開き、FQDNの値をコピーします。

    コンテナーインスタンスの設定

    FQDNフィールドが空の場合は、コンテナーがRunningステータスであることを確認してください。

  2. コピーしたドメインにテスト用のPath Traversal攻撃を含むリクエストを送信します:

    curl http://<COPIED_DOMAIN>/etc/passwd
    
  3. Wallarm Console → AttacksUS CloudまたはEU Cloudで開き、攻撃が一覧に表示されていることを確認します。
    UIのAttacks

  4. 任意で、ノードの他の動作も[テスト][link-docs-check-operation]します。

コンテナーのデプロイ中に発生したエラーの詳細は、Azure portalのリソース詳細のContainersLogsタブに表示されます。リソースにアクセスできない場合は、必要なフィルタリングノードのパラメーターが正しい値でコンテナーに渡されていることを確認してください。