Skip to content

Instantly share code, notes, and snippets.

@martin-klima
Created February 1, 2020 09:58
Show Gist options
  • Save martin-klima/ac501d79d4a7d60ab715e84e59382b58 to your computer and use it in GitHub Desktop.
Save martin-klima/ac501d79d4a7d60ab715e84e59382b58 to your computer and use it in GitHub Desktop.
Drupal 8 settings.production.php template
// Include this file into setting.php
$databases['default']['default'] = array (
'database' => '',
'username' => '',
'password' => '',
'prefix' => '',
'host' => 'localhost',
'port' => '',
'namespace' => 'Drupal\\Core\\Database\\Driver\\mysql',
'driver' => 'mysql',
);
$settings['install_profile'] = 'minimal';
$config_directories['sync'] = 'config/sync';
$settings['hash_salt'] = '';
/**
* Shield settings.
*/
//$config['shield.settings']['allow_cli'] = TRUE;
//$config['shield.settings']['credentials']['shield']['user'] = '';
//$config['shield.settings']['credentials']['shield']['pass'] = '';
//$config['shield.settings']['print'] = 'Be patient... going to live soon.';
/**
* Performance settings override.
*/
$config['system.logging']['error_level'] = 'none';
$config['system.performance']['cache']['page']['max_age'] = 180;
$config['system.performance']['css']['preprocess'] = TRUE;
$config['system.performance']['js']['preprocess'] = TRUE;
/**
* Mail settings.
*/
$config['swiftmailer.transport']['smtp_credentials']['swiftmailer']['username'] = '';
$config['swiftmailer.transport']['smtp_credentials']['swiftmailer']['password'] = '';
// Exclude local development modules - no export them.
$settings['config_exclude_modules'] = ['devel'];
// Set trusted URLs.
$settings['trusted_host_patterns'] = [
'^domain\.com$',
'^www\.domain\.com$',
];
// Set Cloudways reverse proxy.
$settings['reverse_proxy'] = TRUE;
$settings['reverse_proxy_addresses'] = ['127.0.0.1'];
// Redirect to HTTPS.
if ( (!array_key_exists('HTTPS', $_SERVER)) && (PHP_SAPI !== 'cli') ) {
if (substr($_SERVER['HTTP_HOST'], 0, 4) <> 'www.') {
$new_url = 'www.' . $_SERVER['HTTP_HOST'];
} else {
$new_url = $_SERVER['HTTP_HOST'];
}
$new_url .= $_SERVER['REQUEST_URI'];
header('HTTP/1.1 301 Moved Permanently');
header('Location: https://'. $new_url);
exit();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment