2021年8月6日 星期五

重置 Drupal 使用者密碼

 在 Drupal的安裝目錄內,scripts目錄下,找到password-hash.sh這支程式,執行

php 路徑/password-hash.sh '新密碼' > newpassword.txt

用 Hash 產生的 的密碼,會寫入 newpassword.txt,打開 newpassword.txt 即可看到如下內容:

password: '新密碼'

hash: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

將hash密碼,直接利用資料庫工具,貼入使用者的 密碼 欄位 即可!

Using a load balancer or reverse proxy in drupal

 修改 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
}

資料來源:

https://www.drupal.org/node/425990