修改 settings.php
<?php # global settings.php
/**
* Tell all Drupal sites that we're running behind an HTTPS proxy.
*/
// Drupal 7 configuration.
if (explode('.', VERSION)[0] == 7) {
$conf['reverse_proxy'] = TRUE;
$conf['reverse_proxy_addresses'] = ['1.2.3.4', ...];
// Force the protocol provided by the proxy. This isn't always done
// automatically in Drupal 7. Otherwise, you'll get mixed content warnings
// and/or some assets will be blocked by the browser.
if (php_sapi_name() != 'cli') {
if (isset($_SERVER['SITE_SUBDIR']) && isset($_SERVER['RAW_HOST'])) {
// Handle subdirectory mode (e.g. example.com/site1).
$base_url = $_SERVER['HTTP_X_FORWARDED_PROTO'] . '://' . $_SERVER['RAW_HOST'] . '/' . $_SERVER['SITE_SUBDIR'];
}
else {
$base_url = $_SERVER['HTTP_X_FORWARDED_PROTO'] . '://' . $_SERVER['SERVER_NAME'];
}
}
}
// Drupal 8 configuration.
else {
$settings['reverse_proxy'] = TRUE;
$settings['reverse_proxy_addresses'] = ['1.2.3.4', ...];
// See https://symfony.com/doc/current/deployment/proxies.html.
$settings['reverse_proxy_trusted_headers'] = \Symfony\Component\HttpFoundation\Request::HEADER_X_FORWARDED_ALL
}
資料來源: