業務自動化とプログラミングのためのTips

自動化.work

Azure

Application Gatewayで502, 403が表示されるときの製品名を削除する

投稿日:

製品名が表示される

デフォルトだとApplication GatewayはHTTP Statusが502や403のときに製品名が含まれる。
セキュリティ的な観点からこの情報を隠したい場合がある。一応完全ではないものの、製品名を隠す方法はある。

Application Gateway V1の場合

デフォルトのエラーページ

Application Gateway V1 502 error

ヘッダー

Application Gateway V1 502 error header

"Microsoft-IIS/10.0"という文字列が含まれている。

Application Gateway V2の場合

デフォルトのエラーページ

Application Gateway V2 502 error

ヘッダー

Application Gateway V2 502 error header

既定のエラーページ、ヘッダーともに"Microsoft-Azure-Application-Gateway/v2"という文字列が含まれている。

製品名の削除方法

ページの表示に関しては、V1、V2ともにカスタムエラーページを設定することで表示するHTMLの内容を変えられる。
Azure Application Gateway のカスタム エラー ページを作成する | Microsoft Docs

Application Gateway V2はヘッダーの書き換えができるので、それで製品名をヘッダーから削除することができる。
V1はヘッダーの書き換えができないのでHTTPレスポンスから製品名を削除することはできない。

HTTP応答のヘッダー書き換え設定

Application Gateway V2 header rewrite 設定

設定後のHTTP応答ヘッダー中身

Application Gateway V2 header rewrite 結果

ただし、502,403以外のエラーコードを返す場合はカスタムエラーページも設定できないし、ヘッダーから製品名削除もできないようだ。以下は curlコマンドでtraceしてみた結果。

curl -v -X TRACE http://52.191.237.125/
* Trying 52.191.237.125:80...
* TCP_NODELAY set
* Connected to 52.191.237.125 (52.191.237.125) port 80 (#0)
> TRACE / HTTP/1.1
> Host: 52.191.237.125
> User-Agent: curl/7.68.0
> Accept: */*
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 405 Not Allowed
< Server: Microsoft-Azure-Application-Gateway/v2
< Date: Sun, 04 Oct 2020 17:04:11 GMT
< Content-Type: text/html
< Content-Length: 183
< Connection: close
<
<html>
<head><title>405 Not Allowed</title></head>
<body>
<center><h1>405 Not Allowed</h1></center>
<hr><center>Microsoft-Azure-Application-Gateway/v2</center>
</body>
</html>
* Closing connection 0

参考リンク


-Azure
-

Copyright© 自動化.work , 2023 All Rights Reserved.