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サブスクリプション
-
Wallarm Consoleで二要素認証が無効化されたUS CloudまたはEU CloudのAdministratorロールを持つアカウントへのアクセス
-
以下のIPアドレスへのアクセス(攻撃検知ルールおよびAPI仕様の更新ダウンロード、ならびにallowlisted, denylisted, or graylistedされた国、地域、またはデータセンターの正確なIP取得のため)
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を使用してコンテナをデプロイします。
-
Get Wallarm token of the appropriate type:
-
az login
コマンドを使用してAzure CLIにサインインします。 -
az group create
コマンドを使用してリソースグループを作成します。例えば、East USリージョンにmyResourceGroup
グループを以下のコマンドで作成します。 -
Wallarm Cloudへ接続するために使用するWallarmノードのトークンをローカル環境変数に設定します。
-
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:5.3.0 \ --environment-variables WALLARM_API_TOKEN=${WALLARM_API_TOKEN} NGINX_BACKEND='example.com' WALLARM_API_HOST='us1.api.wallarm.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 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
-
Azure portalを開き、作成されたリソースがリソース一覧に表示されていることを確認します。
-
フィルタリングノードの動作テストを実施します。
マウントされたファイルによって構成されたWallarmノードDockerコンテナのデプロイ¶
環境変数とマウントされたファイルによって構成されたコンテナ化されたWallarmフィルタリングノードをデプロイするには、Azure CLIのみが使用可能です。
環境変数とマウントされた構成ファイルを使用してコンテナをデプロイするには:
-
Get Wallarm token of the appropriate type:
-
az login
コマンドを使用してAzure CLIにサインインします。 -
az group create
コマンドを使用してリソースグループを作成します。例えば、East USリージョンにmyResourceGroup
グループを以下のコマンドで作成します。 -
ローカルでフィルタリングノードの設定を記述した構成ファイルを作成します。最低限の設定例として、以下のようなファイルを作成します。
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; } }
-
Azureでのデータボリュームのマウントに適した方法のいずれかで構成ファイルを配置します。すべての方法は、AzureドキュメントのMount data volumesセクションに記載されています。
本手順では、Gitリポジトリから構成ファイルをマウントします。
-
Wallarm Cloudへ接続するために使用するWallarmノードのトークンをローカル環境変数に設定します。
-
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:5.3.0 \ --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:5.3.0 \ --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
: 2番目の手順で作成したリソースグループの名前です。--name
: コンテナの名前です。--dns-name-label
: コンテナのDNSネームラベルです。--ports
: フィルタリングノードが待ち受けるポートです。--image
: WallarmノードDockerイメージの名前です。--gitrepo-url
: 構成ファイルを含むGitリポジトリのURLです。ファイルがリポジトリのルートにある場合は、このパラメータのみを渡します。ファイルが別のディレクトリにある場合は、--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 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
-
Azure portalを開き、作成されたリソースがリソース一覧に表示されていることを確認します。
-
フィルタリングノードの動作テストを実施します。
フィルタリングノードの動作テスト¶
-
Azure portalで作成されたリソースを開き、FQDNの値をコピーします。
FQDNフィールドが空の場合は、コンテナがRunningステータスであることを確認して下さい。
-
コピーしたドメインに対して、テストPath Traversal攻撃のリクエストを送信します:
-
Wallarm Consoleで、US CloudまたはEU CloudのAttacksを開き、攻撃が一覧に表示されていることを確認します。
コンテナのデプロイ中に発生したエラーの詳細は、Azure portalのリソース詳細内のContainers → Logsタブに表示されます。リソースが利用できない場合は、必要なフィルタリングノードパラメータが正しい値でコンテナに渡されているか確認して下さい。