CloudFront と オリジンに発行される HTTP リクエストの Host ヘッダーについて記載します。
ドメイン |
---|
example.com |
オリジン | オリジンドメイン |
---|---|
オリジン1 | origin1.example.com |
オリジン2 | origin2.example.com |
パスパターン | オリジン |
---|---|
https://example.com | origin1.example.com |
https://example.com/blog | origin2.example.com |
Name ベースの VirtualHost を設定している。 設定ファイルは以下 ServerName ディレクティブを指定したファイルのみとして進める。
オリジン | ServerName ディレクティブ |
---|---|
origin1.example.com | origin1.example.com |
origin2.example.com | origin2.example.com |
オリジンリクエストポリシー | 表示 | Apache アクセスログの Host ヘッダー |
---|---|---|
AllViewer | ◯ | example.com |
AllViewerExceptHostHeader | ◯ | origin2.example.com |
HTTP リクエストの Host ヘッダーを記録するように Apache のアクセスログのフォーマットを変更する。
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Host}i\"" combinedhost
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combinedhost
ビューワーが https://example.com/blog/index.html に HTTP リクエストをした表示フロー。
HTTP 1.1 ではHostヘッダーは必須になるが、HTTP/2では代わりに疑似ヘッダーである:authorityにホスト名とポート番号が値として入る。