Wordpress 环境使用HTTPS Nginx + Apache


nginx反向代理apache,运行wordpress  , 使用https访问 wordpress无法获取当前是否使用https访问,导致资源无法加载
 

1. 修改nginx配置

location / {
  proxy_pass http://后端:8080/;
  proxy_set_header X-Forwarded-Host $host;
  proxy_set_header X-Forwarded-Proto $scheme;
}

2. 修改wordpress 配置文件   wp-config.php

define 后面增加以下代码

 

 if ($_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https')
    $_SERVER['HTTPS']='on';

if (isset($_SERVER['HTTP_X_FORWARDED_HOST'])) {
    $_SERVER['HTTP_HOST'] = $_SERVER['HTTP_X_FORWARDED_HOST'];
}

 

3. 设置里面,把站点url  HTTP 改为https

免备案空间专题