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?

同一 VNet の別サブネットから PE 付き App Service に繋ぐときは規定ドメインを指定する

0
Last updated at Posted at 2026-10-23

概要

プライベートエンドポイント (PE) を付けた App Service に VNet 内の別サブネットから接続するときは、PE の IP アドレスではなく、規定ドメイン (xxx.azurewebsites.net) を指定する。
名前解決は、プライベート DNS ゾーンが PE の IP に変換してくれる。

実際に dig と curl で確認した。

App Service のパブリックネットワークアクセスで接続元サブネットを許可すれば、繋がると思う。(未検証)
ただ、PE 経由で VNet 内からプライベートに接続するのが基本の構成だと思う。

前提

  • App Service に PE を作成済み
  • プライベート DNS ゾーン privatelink.azurewebsites.net を作成し、VNet にリンク済み
  • 接続元は、同じ VNet の別サブネットにある踏み台 VM (Ubuntu)

検証

1. 名前解決を確認する

$ dig xxx.azurewebsites.net

;; ANSWER SECTION:
xxx.azurewebsites.net.              60 IN CNAME xxx.privatelink.azurewebsites.net.
xxx.privatelink.azurewebsites.net.  10 IN A     10.0.0.5
  1. パブリック DNS が xxx.azurewebsites.net に対して、xxx.privatelink.azurewebsites.net への CNAME を返す
  2. VNet にリンクされたプライベート DNS ゾーン privatelink.azurewebsites.net の中に xxx のレコードがあるため、PE のプライベート IP が返る

2. 規定ドメインで接続する

$ curl -v https://xxx.azurewebsites.net/
* IPv4: 10.0.0.5
*   Trying 10.0.0.5:443...
* Connected to xxx.azurewebsites.net (10.0.0.5) port 443
*  subject: C=US; ST=WA; L=Redmond; O=Microsoft Corporation; CN=*.azurewebsites.net
*  subjectAltName: host "xxx.azurewebsites.net" matched cert's "*.azurewebsites.net"
*  SSL certificate verify ok.
> GET / HTTP/1.1
> Host: xxx.azurewebsites.net
< HTTP/1.1 307 Temporary Redirect
  • 接続先は PE の IP (10.0.0.5)
  • PE 経由で返ってきた App Service の証明書 (*.azurewebsites.net) が、接続先のホスト名と一致して検証が通る
  • アプリまで到達して応答が返る (307 はアプリ側のリダイレクト)

3. PE の IP を直接指定すると失敗する

$ curl -v https://10.0.0.5/
* Connected to 10.0.0.5 (10.0.0.5) port 443
* Server certificate:
*  subject: ... CN=*.azurewebsites.net
*  subjectAltName does not match 10.0.0.5
* SSL: no alternative certificate subject name matches target host name '10.0.0.5'
curl: (60) SSL: no alternative certificate subject name matches target host name '10.0.0.5'
  • TCP 接続と TLS ハンドシェイクまでは成功していて、ネットワークは問題なし
  • 返ってくる証明書は、規定ドメインで接続したときと同じ App Service の証明書
  • 証明書の対象は *.azurewebsites.net のドメインで、接続先の IP (10.0.0.5) は対象外のため、検証に失敗する

なぜ規定ドメインを指定するのか

When you set up this DNS configuration, you can reach your app privately with the default name mywebapp.azurewebsites.net. You must use this name, because the default certificate is issued for *.azurewebsites.net.

(Use private endpoints for Azure App Service apps | Microsoft Learn)

PE は通信を App Service に引き渡すだけで、証明書は持っていない。
TLS を終端して証明書を返すのは App Service で、その証明書の対象は *.azurewebsites.net ドメイン。
IP アドレスは対象外のため、URL に IP を書くとホスト名の検証に失敗する。

プライベート DNS ゾーンが接続元の VNet にリンクされていないと、規定ドメインはパブリック IP に解決され、403 になる。(自動でリンクされなくてハマった...)
繋がらないときは、まず dig で PE の IP に解決されているかを確認するとよい。

まとめ

  • PE 付き App Service には、規定ドメインで接続する
  • 名前解決は、次の順で PE の IP になる
    • xxx.azurewebsites.net の CNAME レコード (パブリック DNS)
    • → xxx.privatelink.azurewebsites.net の A レコード (プライベート DNS ゾーン)
    • → PE の IP
  • PE の IP を直接指定すると、証明書の対象外のため、検証で失敗する

参考

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?