我遇到一个非常随机的问题。每当我通过 http 协议(protocol)访问我的网站时,都会下载 wp-blog-header.php 文件,或者我只是从 cloudflare(我正在使用的)那里收到 502 错误。该文件内容如下:
<?php
/**
* Front to the WordPress application. This file doesn't do anything, but loads
* wp-blog-header.php which does and tells WordPress to load the theme.
*
* @package WordPress
*/
/**
* Tells WordPress to load the WordPress theme and output it.
*
* @var bool
*/
define('WP_USE_THEMES', true);
/** Loads the WordPress Environment and Template */
require('./wp-blog-header.php');
当我通过 https 协议(protocol)访问网站时,我没有遇到这个问题。
我的 wp-config.php 文件中有以下内容
define('WP_HOME','https://somersetbaby.com');
define('WP_SITEURL','https://somersetbaby.com');
下面是我的站点的 nginx 配置文件:
server {
listen 443 ssl default_server;
listen [::]:443 ssl default_server;
ssl on;
ssl_certificate /not/here/somersetbaby.pem;
ssl_certificate_key /not/here/somersetbaby.key;
server_name somersetbaby.com www.somersetbaby.com;
access_log /var/log/nginx/somersetbaby.com.access.log rt_cache;
error_log /var/log/nginx/somersetbaby.com.error.log;
root /var/www/somersetbaby.com/htdocs;
index index.php index.html index.htm;
include common/wpfc-php7.conf;
include common/wpcommon-php7.conf;
include common/locations-php7.conf;
include /var/www/somersetbaby.com/conf/nginx/*.conf;
我也有一个默认文件,但如果我删除它,我会收到 521 错误,网站将不断重新加载,如果我包含它,我无法让网站强制使用 SSL。
如有任何帮助,我们将不胜感激。
谢谢
最佳答案
这是因为 wordpress 检测 HTTPS 的方式,一个便宜的 hack 是将以下内容放在 wp-config.php
if ($_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https') {
$_SERVER['HTTPS'] = 'on';
$_SERVER['SERVER_PORT'] = 443;
}
关于php - 非 https 在 AWS EC2 Nginx 上下载 wp-header 文件,但 SSL 有效吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44765535/