backdrop-ops / backdrop-pantheon

Version of Backdrop CMS that runs on the Pantheon hosting platform.
GNU General Public License v2.0
5 stars 8 forks source link

Fatal error for live pantheon sites after update (to 1.18.1?) #46

Closed jenlampton closed 2 years ago

jenlampton commented 3 years ago

I notice that we introduced to set trusted host patterns for pantheon domains:

if (defined('PANTHEON_ENVIRONMENT')) {
  if (in_array($_ENV['PANTHEON_ENVIRONMENT'], array('dev', 'test', 'live'))) {
    $settings['trusted_host_patterns'][] = "{$_ENV['PANTHEON_ENVIRONMENT']}-{$_ENV['PANTHEON_SITE_NAME']}.pantheon.io";
    $settings['trusted_host_patterns'][] = "{$_ENV['PANTHEON_ENVIRONMENT']}-{$_ENV['PANTHEON_SITE_NAME']}.pantheonsite.io";
  }
}

The problem with this is that it can cause immediate downtime for live sites, after updating to the version where this was added.

From a client:

After that update the live site (that is not on the default pantheon URL) stopped working with an error, trusted_hosts_pattern. We had to add the live domain to the trusted hosts pattern to bring the site back up. Before we had not configured that at all, so i guess all URL's worked. Now not.

I think we need to add an if isset($settings['trusted_host_patterns']) before we add the pantheon domains, so that this setting remains optional for sites that didn't have any domains defined before.

jenlampton commented 3 years ago

This surprised me a little because I wasn't expecting pantheon to apply changes to the settings.php file in an update, but it looks like it does.

herbdool commented 2 years ago

According to https://github.com/pantheon-systems/drops-8/blob/233160dc7e502f9742f87dc710cac43afa813c7f/sites/default/settings.pantheon.php#L179 we can just allow all domains and this would avoid the headache:

/**
 * "Trusted host settings" are not necessary on Pantheon; traffic will only
 * be routed to your site if the host settings match a domain configured for
 * your site in the dashboard.
 */
if (isset($_ENV['PANTHEON_ENVIRONMENT'])) {
  $settings['trusted_host_patterns'][] = '.*';
}
herbdool commented 2 years ago

@jenlampton I've got a new PR. Pantheon says trust_host_patterns not needed.