0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Cloud RunとCloud Load Balancingでカスタムドメインを設定する with Cloud Armor

Posted at

はじめに

Cloud Runにアプリをデプロイして、カスタムドメインを設定する必要があり、
やり方を調べてみたんですが、全然なかったので、備忘録がてらここに残します。

※この記事では画像ベースで手順を紹介しています
※Zennでは、Terraformを使って同じ内容のデプロイに挑戦しようと思います(準備中)

Cloud Runをデプロイ

1. Cloud Runのページからサービスを作成します

image.png

2. 画像の項目を選択して、「作成」ボタンを押す

image.png

image.png

3. 作成したCloud Runのデフォルトのエンドポイントを有効化のチェックを外す

1.png

Cloud Domainsでドメインを取得

Cloud Domainsのページからドメインを取得します

image.png

必要項目を入力していき、ドメインを登録します

image.png

image.png

image.png

image.png

Certificate Managerで証明書を発行

Certificate Managerの画面から証明書を発行します

image.png

先ほど登録したドメインを入力して、マネージドの証明書を作成する

image.png

Cloud Load Balancingでロードバランサーを設定

Cloud Load Balancingのページからロードバランサーを作成

image.png

それぞれの項目を選択して、グローバル外部アプリケーションロードバランサーを構成する

image.png

フロントエンドを構成していき、IPアドレスを作成します

image.png

image.png

先ほど作成した証明書を選択して、「HTTP から HTTPS へのリダイレクトを有効にする」をチェックする

image.png

image.png

バックエンドを構成します

image.png

項目を入力していき、新しいバックエンドで、サーバーレスネットワークエンドポイントグループの作成を選択

1.png

項目を入力し、作成したCloud Runサービスを選択して、作成します

1.png

セキュリティより下の項目を入力して、作成します

1.png

次のルーティングルールはそのままの内容で、ロードバランサーを作成します

image.png

Cloud DNSでドメインとIPアドレスを紐づける

Cloud DNSのページから取得したドメインを選択します

1.png

レコードセットを追加するために、「標準を追加します」ボタンを押下

1.png

Aレコードを追加して、作成したロードバランサーのIPを入力して作成する

1.png

Cloud ArmorでIP直叩きを防ぐ

Cloud Armorのページに行き、ロードバランサーが作成された時のポリシーを編集する

image.png

ルールを追加します

image.png

以下の詳細なルールを入力して、そのルールに該当する項目を拒否します

!request.headers['Host'].contains('yourdomain.com')

取得したドメインに変更してにゅうりょく

image.png

image.png

お疲れ様でした

しばらくすると、登録したドメインからアクセスできます。

ロードバランサーのIPアドレスを直打ちしても403が出てアクセスできないようになっています

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?