DEV Community ๐Ÿ‘ฉโ€๐Ÿ’ป๐Ÿ‘จโ€๐Ÿ’ป

DEV Community ๐Ÿ‘ฉโ€๐Ÿ’ป๐Ÿ‘จโ€๐Ÿ’ป is a community of 963,673 amazing developers

We're a place where coders share, stay up-to-date and grow their careers.

Create account Log in
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)

๐ŸŒš Browsing with dark mode makes you a better developer by a factor of exactly 40.

It's a scientific fact.