DEV Community

Cover image for Fix Trusted Host Settings error in Drupal status report
nabbisen
nabbisen

Posted on

Fix Trusted Host Settings error in Drupal status report

Summary

I installed Drupal 9 on OpenBSD few days ago. An error on "Trusted Host Settings" seemed to remain after installation via the web installer.
The cover image of this post is screenshot of the error.

Description

In order to fix it, all what to do is edit settings.php in web/sites.

$ doas nvim /var/www/.../<drupal-dir>/web/sites/default/settings.php
$ # settings.php is read-only by default
Enter fullscreen mode Exit fullscreen mode

When <fqdn> is "sub.orroot.domain" in actual, add lines like this:

  /**
   * Trusted host configuration.
   *
   * Drupal core can use the Symfony trusted host mechanism to prevent HTTP Host
   * header spoofing.
   ...
   * For example:
   * @code
   * $settings['trusted_host_patterns'] = [
   *   '^www\.example\.com$',
   * ];
   * @endcode
   * will allow the site to only run from www.example.com.
   ...
   */
+ $settings['trusted_host_patterns'] = [   
+   '^sub\.orroot\.domain$',   
+ ];
Enter fullscreen mode Exit fullscreen mode

Refreshing "Status report" page will bring comfortable result that all tests are passed.

Reference

Top comments (0)