Azure App Gateway (高度な設定)

Azure App Gatewayサービスを使用してKeeper AutomatorをAzure Container Instancesにデプロイ

概要

本ガイドでは、Azure Application Gatewayを使用して安全なVNetでKeeper Automatorを公開するための手順を解説します。この方式は、Azureコンテナーアプリの設定よりも高度となりますので、Azure App Gatewayや暗号化されたSAMLリクエストを使用する必要がない場合は、Azureコンテナーアプリ方式をご使用ください。

この方式では、すでにSSL証明書をお持ちであることを確かにしてください。お持ちでない場合は、カスタムSSL証明書ページの手順をご参照ください。

手順

(1) Azureクラウドシェルを開く

portal.azure.comにログインし、クラウドシェルのアイコンをクリックします。

(2) ご希望の地域でリソースグループを作成

Azureにリソースグループがまだ存在しない場合は作成します。こちらの例ではeastusの地域を使用していますが、必ずお客様の地域をご使用ください。

az group create --name keeper_automator_rg --location eastus

(3) ストレージアカウントの作成

ストレージアカウントがまだ存在しない場合は作成します。正しい地域(useeast)と上のリソースグループ名を使用するようにします。注: keeperautomatotorstorageを置き換えるのに選択する名前は、azureではグローバルで他に存在しないものである必要があります。

az storage account create -n -g keeper_automator_rg -l eastus --sku Standard_LRS

(4) ファイルシェアの作成

ファイルシェアが存在しない場合は作成します。

az storage share create --account-name --name keeperautomatorfileshare

現在のシェアを表示します。

az storage share list --account-name 

(5) コンテナー用にバーチャルネットワーク(VNet)と1件のSubnetを作成

az network vnet create --address-prefixes 10.100.0.0/16 --name keeper_automator_vnet --resource-group keeper_automator_rg --subnet-name keeper_automator_subnet --subnet-prefixes 10.100.2.0/24

(6) バーチャルネットワークをサービスエンドポイントで更新

az network vnet subnet update -g keeper_automator_rg -n keeper_automator_subnet --vnet-name keeper_automator_vnet --service-endpoints Microsoft.Storage --delegations Microsoft.ContainerInstance/containerGroups

(7) ストレージキーの取得

アカウントのストレージキーを見つけるには以下のコマンドを使用します。 ストレージアカウント名は実際の名前に置き換えます。

az storage account keys list --resource-group keeper_automator_rg --account-name 

以下のようなkey1の値をコピーします。

"value": "zuVgm9xnQNnxCQzY=5n4Ec6kxhDn2xMZSfpwZnTeqsyGaHd5Abn584mpAP3xamg3rGns4=Fd7FeFsaR6AgtnqW=="

(8) サブネットIDの取得

サブネットIDを見つけるには以下のコマンドを実行します。

az network vnet subnet list --resource-group keeper_automator_rg --vnet-name keeper_automator_vnet | grep "id"

サブネットIDのパスを _subnetで終わるところまで全部コピーします。以下はその例です。

"id": "/subscriptions/abc123-abc123-abc-123/resourceGroups/keeper_automator_rg/providers/Microsoft.Network/virtualNetworks/keeper_automator_vnet/subnets/keeperautomator_appgw_subnet"

(9) YAMLコンテナーファイルの作成

ローカルで、automatorなどの名前でフォルダを作成します。

任意のエディタを使用して、そのフォルダー内に以下の内容を含むautomator.ymlというファイルを作成します。

automator.yml
apiVersion: '2021-07-01'
location: eastus
name: keeperautomatorcontainer
properties:
  containers:
  - name: keeperautomatorcontainer
    properties:
      image: keeper/automator:latest
      ports:
      - port: 443
        protocol: TCP
      resources:
        requests:
          cpu: 1.0
          memoryInGB: 1.5
      volumeMounts:
        - name: automatorvolume
          mountPath: /usr/mybin/config
  osType: Linux
  restartPolicy: Always
  sku: Standard
  volumes:
  - name: automatorvolume
    azureFile:
      shareName: keeperautomatorfileshare
      readOnly: false
      storageAccountName: 
      storageAccountKey: 
  subnetids:
    - id: /subscriptions//path/to/subnets/keeper_automator_subnet
      name: keeper_automator_subnet
tags: null
type: Microsoft.ContainerInstance/containerGroups

前の手順の設定に基づいて文字列の値を変更する必要がある箇所が複数あります。

  • サブネットID は、手順8で取得したIDのフルパスと一致する必要があります。

  • storageAccountNameは手順3の値と一致する必要があります。

  • storageAccountKeyは手順7の値と一致する必要があります。

(10) SSL証明書とSSLパスワードファイルのアップロード

Azureインターフェイスから、[リソース グループ] > [ストレージ アカウント] > [ファイルシェア]に移動し、作成したAutomatorファイルシェアに移動します。ここから、automator.ymlファイル、SSL証明書ファイル、SSL証明書パスワードファイルをアップロードします。

ファイルの名前が automator.yml ssl-certificate.pfx および ssl-certificate-password.txt であることを確認してください。

(11) 3つのファイルをローカルのCLIワークスペースにコピーします

az storage copy -s https://keeperautomatorstorage.file.core.windows.net/keeperautomatorfileshare/automator.yml -d .

az storage copy -s https://keeperautomatorstorage.file.core.windows.net/keeperautomatorfileshare/ssl-certificate.pfx -d .

az storage copy -s https://keeperautomatorstorage.file.core.windows.net/keeperautomatorfileshare/ssl-certificate-password.txt -d .

(12) コンテナーインスタンスの作成

automator.ymlの設定を使用してコンテナーを作成します。

az container create -g keeper_automator_rg -f automator.yml

応答でコンテナの内部IPを取得します。

az container show --name keeperautomatorcontainer --resource-group keeper_automator_rg --query ipAddress.ip --output tsv

後で使用するために、このIPの変数を設定します。以下はその例となります。

$aciPrivateIp=10.100.2.4

(13) アプリケーションゲートウェイサブネットの作成

az network vnet subnet create --name keeperautomator_appgw_subnet --resource-group keeper_automator_rg --vnet-name keeper_automator_vnet --address-prefix 10.100.1.0/24

(14) アプリケーションゲートウェイの作成

az network application-gateway create --name KeeperAutomatorAppGateway --location eastus --resource-group keeper_automator_rg --sku Standard_v2 --public-ip-address AGPublicIPAddress --cert-file ssl-certificate.pfx --cert-password --vnet-name keeper_automator_vnet --subnet keeperautomator_appgw_subnet --frontend-port 443 --http-settings-port 443 --http-settings-protocol Https --servers 10.100.2.4 --priority 100

XXXXXXの箇所でSSL証明書のパスワードが置き換えられていることを確かにします。

(15) パブリックIPを見つける

Azure portalのインターフェイスで、[リソースグループ] > [アプリゲートウェイ]に移動し、パブリックIP アドレスをメモします。

(16) DNSのルーティング

AutomatorサービスのDNS(例: automator.company.com)が、Azureコンテナーサービスが手順 15で生成したIPアドレスを指していることを確かにします。

DNS名は SSL 証明書のサブジェクト名と一致する必要があります。一致しない場合、リクエストは失敗します。

(17) 正常性プローブの作成

正常性プローブは、Automatorサービスが実行されていることをApp Gatewayに通知します。Azure portalのインターフェイスからAutomator App Gatewayを開き、左側のメニューから[正常性プローブ]をクリックします。

次に、以下のスクリーンショットに見られる設定で新しい正常性プローブを作成します。必ずホストを手順 6で設定したFQDNに置き換えます。

[テスト]をクリックしてプローブを追加します。コンテナIPがホスト名に適切にアドレス指定されていれば、テストは成功します。

(18) ウェブアプリケーションファイアウォールの設定

Azure portalのインターフェイスからAutomator App Gatewayを開き、左側の[ウェブアプリケーションファイアウォール] をクリックします。 WAF V2を有効にして以下の画面のように設定します。

[ルール]タブをクリックし、[OWASP 3.2]に設定されたルールを選択して、[有効]および[保存]をクリックします(重要な手順となります)。

🎉 Azure内でのインストールは完了です。

最後にKeeper Commenderを使ってAutomatorの設定を行います。

(19) Keeper Commanderのインストール

この時点では、サービスは実行されていますがまだKeeperとは通信ができません。

ワークステーション、サーバー、コンピューターのどれかにKeeper Commander CLIをインストールします。初期設定にのみ使用します。バイナリインストーラーを含むインストール手順についてはこちらをご覧ください。 Commanderを開いた後、loginコマンドでログインします。AutomatorをセットアップするにはKeeper 管理者、またはSSOノードを管理する権限を持つ管理者としてログインする必要があります。

My Vault> login admin@company.com

(20) Commanderでの初期設定

Keeper Commanderにログインし、automator createで始まる一連のコマンドを使用してAutomatorを有効にします。

automator create --name="My Automator" --node="Azure Cloud"

ノード名 (この場合はAzure Cloud) は、以下のように管理コンソールのUIから取得します。

コマンドの出力には、IDプロバイダからのメタデータを含むAutomator設定が表示されます。

                    Automator ID: 1477468749950
                            Name: My Automator
                             URL: 
                         Enabled: No
                     Initialized: No
                          Skills: Device Approval

URLはまだ入力されていません。選択したFQDNを使用してURLを編集します。

automator edit --url=https://automator.lurey.com --skill=team --skill=team_for_user --skill=device "My Automator"

次に、キーを交換します。Automator公開キーで暗号化されたエンタープライズ秘密キーがAutomator に提供されます。

automator setup "My Automator"

新しい設定でAutomatorを初期化します。

automator init "My Automator"

サービスを有効にします。

automator enable "My Automator"

この時点で設定は完了です。

自動ヘルスチェックには以下のURLをご使用になれます。

https://<server>/health

以下はcurlコマンドを使用した例です。

$ curl https://automator.lurey.com/health
OK

当URLはWebブラウザでは開きません。

(21) AD FSを使用した環境の場合

IDプロバイダとしてAD FSを使用してKeeper Automatorを有効にする場合、以下の手順に従ってKeeper 証明書を更新するまでログインできません。

  • Keeper管理コンソールへログインします。

  • [管理] > [SSOノード] > [プロビジョニング]に移動し、SSOクラウド設定を見ます。

  • [Export SP Cert]をクリックします。

  • AD FS管理コンソールで、Keeper Cloud SSO証明書利用者信頼プロパティを選択します。

  • [暗号化]タブで、古い証明書をこの新しい証明書に置き換えます。

  • [署名]タブで、新しいSP証明書をこの新しい証明書に置き換えます。

セットアップは完了です。

これでAutomatorサービスが実行された状態になりました。

Azure Portal

Azure Portalの「コンテナーインスタンス」システムで、コンテナーが実行されているのを確認できます。 /bin/shを使用してコンテナーに接続し、実行ログを表示することもできます。

コンテナーの再起動時にIPを更新

この設定に基づいてコンテナーを再起動すると、/24サブネットから新しい IP アドレスが割り当てられることがあります。新しいIPをすばやく見つけて、正しいIPでApplication Gatewayバックエンドプールを更新するには、Azure CLIから以下のスクリプトを実行します。

# change these 3 variables according to your setup
RESOURCE_GROUP="keeper_automator_rg"
GATEWAY_NAME="KeeperAutomatorAppGateway"
CONTAINER_NAME="keeperautomatorcontainer"

BACKEND_POOL_NAME="appGatewayBackendPool"

CONTAINER_IP=$(az container show --resource-group $RESOURCE_GROUP --name $CONTAINER_NAME --query 'ipAddress.ip' --output tsv)

az network application-gateway address-pool update --resource-group $RESOURCE_GROUP --gateway-name $GATEWAY_NAME --name $BACKEND_POOL_NAME --servers $CONTAINER_IP

Automatorサービスのテスト

Keeper Automatorがデプロイされましたので、エンドユーザー体験のテストが可能です。ユーザーが SSO IDプロバイダーで認証した後は、承認を求めるプロンプトは必要ありません。

最も簡単なテスト方法は、ブラウザでシークレットモードのウィンドウを開いてKeeperウェブボルトへアクセスし、SSOクラウドでログインすることとなります。デバイスの承認を求めるプロンプトが表示されない場合、Automatorが正常に機能しています。

最終更新