CMS - Drupal - トラブルシュート - 信頼のおけるホストの設定

クラウディア 
1. 概要
2. 現象
3. 設定

1. 概要

 これは、2020年1月20日、「drupal-8.8.1」でおきた現象です。

2. 現象

 サイト構築直後に、「サイトの状態」というページに  こんなん出てます。
「Drupal 8.8.1」-「サイトの状態」「見つかったエラー」「信頼のおけるホストの設定」

 調べると、「Trusted Host Settings の無効を有効にする | Drupal8を始めました。- ドルーパル初心者・入門者向け情報 -」と題するサイトに有用な記事がありました。
 (参考サイトを掲載していましたが、リンク切れになりました)

3. 設定


vi /drupal ドキュメントルートパス/sites/default/settings.php
 例題は、ここに載っていました。

/**
 * Trusted host configuration.
 *
 * Drupal core can use the Symfony trusted host mechanism to prevent HTTP Host
 * header spoofing.
 *
 * To enable the trusted host mechanism, you enable your allowable hosts
 * in $settings['trusted_host_patterns']. This should be an array of regular
 * expression patterns, without delimiters, representing the hosts you would
 * like to allow.
 *
 * For example:
 * @code
 * $settings['trusted_host_patterns'] = [
 *   '^www\.example\.com$',
 * ];
 * @endcode
 * will allow the site to only run from www.example.com.
 *
 * If you are running multisite, or if you are running your site from
 * different domain names (eg, you don't redirect http://www.example.com to
 * http://example.com), you should specify all of the host patterns that are
 * allowed by your site.
 *
 * For example:
 * @code
 * $settings['trusted_host_patterns'] = [
 *   '^example\.com$',
 *   '^.+\.example\.com$',
 *   '^example\.org$',
 *   '^.+\.example\.org$',
 * ];
 * @endcode
 * will allow the site to run off of all variants of example.com and
 * example.org, with all subdomains included.
 */
 つまり

$settings['trusted_host_patterns'] = [
    '^example\.com$',
    '^.+\.example\.com$',
    '^example\.org$',
    '^.+\.example\.org$',
  ];
 てな感じで表現するらしく、ドメイン名を正規表現で表現すればよいわけだな。  すなわち、本サイトであれば

$settings['trusted_host_patterns'] = [
    '^freebsd\.ne\.jp$',
  ];
 てな感じかしら。  本サイトでは、検証しておりませんので、不確かな情報です。  検証ホストでやってみたのですが、一応、記述をしてエラーはなくなるのですが、「apache」を再起動しても反映されず・・・。  結局、ホスト自体を再起動、ブラウザのキャッシュを削除して表示されなくなりました。
earthcar(アースカー)