Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 非https下载AWS EC2 Nginx上的wp头文件,但SSL可以工作吗?_Php_Wordpress_Ssl_Nginx - Fatal编程技术网

Php 非https下载AWS EC2 Nginx上的wp头文件,但SSL可以工作吗?

Php 非https下载AWS EC2 Nginx上的wp头文件,但SSL可以工作吗?,php,wordpress,ssl,nginx,Php,Wordpress,Ssl,Nginx,我得到一个非常随机的问题。每当我通过http协议访问我的站点时,就会下载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 l

我得到一个非常随机的问题。每当我通过http协议访问我的站点时,就会下载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');
以下是我的网站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的方式,一种廉价的黑客方法是将以下内容放入
wp config.php

if ($_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https') { 
    $_SERVER['HTTPS'] = 'on';
    $_SERVER['SERVER_PORT'] = 443;
}

我确实让它工作了,我必须看看我的另一个服务器设置,它正在工作

我创建了一个名为/etc/nginx/conf.d/force-ssl-somersetbaby.com.conf的文件

然后它有以下代码:

server {
    listen 80;
    server_name www.somersetbaby.com somersetbaby.com;
    return 301 https://somersetbaby.com$request_uri;
}
这似乎奏效了。我已重新启动服务器并清除缓存


感谢您的帮助。

适用于Wordpress,位于
Cloudflare->Load Balancer->NGINX->LXC容器之后。我将其放入wp配置文件,重新启动NGINX,并从Cloudflare中清除缓存。仍然有同样的问题。我也没有在AWS上使用负载平衡器,这是一个简单的Ubuntu实例安装和easyengine wordpress安装(使用FastCGI和PHP7)。我得到了502个HTTP坏网关,在您的更改中,nginx仍然在监听端口80,如果我在nginx conf文件中添加监听端口80,我会得到一个400错误。如果我把它取出来,我得到的是502错误。我已经将上面提到的代码放在wp config文件中,它仍然存在。这很难,因为它不应该发生(逻辑上)
server {
    listen 80;
    server_name www.somersetbaby.com somersetbaby.com;
    return 301 https://somersetbaby.com$request_uri;
}