AWSへのWallarm Dockerイメージのデプロイ¶
このクイックガイドでは、NGINXベースのWallarmノードのDockerイメージをAmazon Elastic Container Service (Amazon ECS)を使用してAmazonクラウドプラットフォームへデプロイする手順を示します。
手順の制限
これらの手順は、ロードバランシングやノードのオートスケーリングの設定についてはカバーしておりません。これらのコンポーネントを自分で設定する場合は、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.
必要条件¶
-
admin 権限を持つAWSアカウントおよびユーザー
-
US CloudまたはEU CloudのWallarm Consoleにおいて、Administratorロールで二要素認証が無効のアカウントへのアクセス
-
攻撃検出ルールの更新ダウンロードやAPI仕様書の取得、allowlisted, denylisted, or graylisted国、地域、またはデータセンターの正確なIP取得用に、下記の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フィルタリングノードをデプロイするために、AWS Management ConsoleおよびAWS CLIを使用します。
-
Get Wallarm token of the appropriate type:
-
AWS Management Console にサインインし、ServicesリストからElastic Container Serviceを選択します。
-
Create Clusterボタンをクリックしてクラスター作成に進みます:
- テンプレートとしてEC2 Linux + Networkingを選択します。
- クラスター名を指定します(例:
wallarm-cluster
)。 - 必要に応じて、AWSの手順に従いその他の設定を行います。
- クラスターを保存します。
-
Wallarm Cloudに接続するために必要な機微なデータ(ノードトークン)を、AWS Secrets ManagerまたはAWS Systems Manager → Parameter Storeを使用して暗号化します。
本手順では、機微なデータはAWS Secrets Managerに保存されます。
機微なデータストレージへのアクセス
Dockerコンテナが暗号化された機微なデータを読み取れるようにするため、AWSの設定が以下の要件を満たしていることを確認してください:
- 機微なデータはDockerコンテナ実行に使用するリージョンに保存されていること。
- タスク定義の
executionRoleArn
パラメータに指定されたユーザーに、IAMポリシーSecretsManagerReadWriteがアタッチされていること。IAMポリシーの設定の詳細 →
-
タスク定義(タスク定義はDockerコンテナの動作シナリオを設定します)の内容を記述した以下のローカルJSONファイルを作成します:
{ "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:5.3.0" } ], "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:5.3.0" } ], "family": "wallarm-api-security-node" }
<AWS_ACCOUNT_ID>
: あなたのAWSアカウントID。environment
オブジェクトは、テキスト形式でDockerコンテナに渡す環境変数を設定します。利用可能な環境変数の一覧は以下の表に記載されています。変数WALLARM_API_TOKEN
はsecrets
オブジェクトで渡すことを推奨します。-
secrets
オブジェクトは、機微なデータストレージへのリンクとしてDockerコンテナに渡す環境変数を設定します。値のフォーマットは選択したストレージに依存します(詳細はAWS Secrets ManagerまたはAWS Systems Manager → Parameter Storeのドキュメントを参照してください)。変数
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>
: 1番目のステップで作成したクラスター名(例:wallarm-cluster
)。<FAMILY_PARAM_VALUE>
: 作成したタスク定義の名前。JSONファイル内で指定されたfamily
パラメータの値に対応する必要があります(例:wallarm-api-security-node
)。
-
AWS Management ConsoleでElastic Container Service→実行中のタスクがあるクラスター→Tasksを開き、タスクが一覧に表示されていることを確認します。
マウントファイルによる設定が適用されたWallarmノードDockerコンテナのデプロイ¶
環境変数とマウントされたファイルによって構成されたコンテナ化されたWallarmフィルタリングノードをデプロイするために、AWS Management ConsoleおよびAWS CLIを使用します。
本手順では、設定ファイルはAWS EFSファイルシステムからマウントされます。ファイルのマウントその他の方法については、AWSのドキュメントを確認してください。
環境変数およびAWS EFSからマウントされた設定ファイルでコンテナをデプロイするには:
-
Get Wallarm token of the appropriate type:
-
AWS Management Console にサインインし、ServicesリストからElastic Container Serviceを選択します。
-
Create Clusterボタンをクリックしてクラスター作成に進みます:
- Template:
EC2 Linux + Networking
- Cluster name: 例として
wallarm-cluster
- 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: SSH接続用のkey pair(設定ファイルをストレージへアップロードするために、SSHでインスタンスに接続する必要があります)
- その他の設定はデフォルトのままで構いません。他の設定を変更する場合は、AWS EFSの設定手順に従うことを推奨します。
- Template:
-
AWSの手順のステップ2~4に従い、AWS EFSストレージを設定します。
-
AWSの手順4において、設定ファイル
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; } }
-
Wallarm Cloudに接続するために必要な機微なデータ(ノードトークン)を、AWS Secrets ManagerまたはAWS Systems Manager → Parameter Storeを使用して暗号化します。
本手順では、機微なデータはAWS Secrets Managerに保存されます。
機微なデータストレージへのアクセス
Dockerコンテナが暗号化された機微なデータを読み取れるようにするため、AWSの設定が以下の要件を満たしていることを確認してください:
- 機微なデータはDockerコンテナ実行に使用するリージョンに保存されていること。
- タスク定義の
executionRoleArn
パラメータに指定されたユーザーに、IAMポリシーSecretsManagerReadWriteがアタッチされていること。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:5.3.0" } ], "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:5.3.0" } ], "volumes": [ { "name": "default", "efsVolumeConfiguration": { "fileSystemId": "<EFS_FILE_SYSTEM_ID>", "transitEncryption": "ENABLED" } } ], "family": "wallarm-api-security-node" }
<AWS_ACCOUNT_ID>
: あなたのAWSアカウントID。-
<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>
: マウントされた設定ファイルのAWS EFSストレージの構成が記述されたvolumes
オブジェクトの名称(値は<VOLUME_NAME>
と一致させる必要があります)。 <VOLUME_NAME>
: マウントされた設定ファイルのAWS EFSストレージの構成が記述されたvolumes
オブジェクトの名称。<EFS_FILE_SYSTEM_ID>
: コンテナにマウントするファイルが存在するAWS EFSファイルシステムのID。IDはAWS Management ConsoleのServices→EFS→File systemsに表示されます。environment
オブジェクトは、テキスト形式でDockerコンテナに渡す環境変数を設定します。利用可能な環境変数の一覧は以下の表に記載されています。変数WALLARM_API_TOKEN
はsecrets
オブジェクトで渡すことを推奨します。-
secrets
オブジェクトは、機微なデータストレージへのリンクとしてDockerコンテナに渡す環境変数を設定します。値のフォーマットは選択したストレージに依存します(詳細はAWS Secrets ManagerまたはAWS Systems Manager → Parameter Storeのドキュメントを参照してください)。変数
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>
: 1番目のステップで作成したクラスター名(例:wallarm-cluster
)。<FAMILY_PARAM_VALUE>
: 作成したタスク定義の名前。JSONファイル内で指定されたfamily
パラメータの値に対応する必要があります(例:wallarm-api-security-node
)。
-
AWS Management ConsoleでElastic Container Service→実行中のタスクがあるクラスター→Tasksを開き、タスクが一覧に表示されていることを確認します。
フィルタリングノードの動作テスト¶
-
AWS Management Consoleで実行中のタスクを開き、External LinkフィールドからコンテナのIPアドレスをコピーします。
IPアドレスが空の場合は、コンテナがRUNNING状態になっているか確認してください。
-
コピーしたアドレスに対して、テストPath Traversal攻撃のリクエストを送信します:
-
Wallarm ConsoleでUS CloudまたはEU CloudのAttacksを開き、攻撃が一覧に表示されていることを確認します。
コンテナデプロイ時に発生したエラーの詳細は、AWS Management Consoleのタスク詳細に表示されます。コンテナが利用できない場合は、必要なフィルタリングノードパラメータが正しい値でコンテナに渡されていることを確認してください。