简体   繁体   English

Wordpress Static 去 HTTP 而不是 Z0E8433F9A404F1F3BA601C14B026D321

[英]Wordpress Static going to HTTP instead of HTTPS

I have a WordPress server inside a docker container.我在 docker 容器内有一个 WordPress 服务器。 WordPress is running with a nginx server inside. WordPress 在内部运行 nginx 服务器。 When I go through the initial installation phase, css (and other files) worked perfectly.当我通过初始安装阶段 go 时,css(和其他文件)运行良好。 But the when I load the main site, those resources redirected to HTTP://example.com/blogs/... instead of HTTPS.但是当我加载主站点时,这些资源重定向到 HTTP://example.com/blogs/... 而不是 HTTPS。

Here are the URLs from the inspect:以下是来自检查的 URL:

https://example.com/blogs/
http://example.com/blogs/wp-includes/js/wp-emoji-release.min.js?ver=5.1.1

Here are my Nginx configuration from example.com:这是来自 example.com 的我的 Nginx 配置:

location /blogs/ {
                proxy_pass HTTP://localhost:8080/;
                proxy_set_header Host $host;
                proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_read_timeout 1800s;
        }

I have updated the wp-config.php file with the following information我已使用以下信息更新了 wp-config.php 文件

define('WP_HOME','https://example.com/blogs/');
define('WP_SITEURL','https://example.com/blogs/');
$_SERVER['REQUEST_URI'] = '/blogs' . $_SERVER['REQUEST_URI'];

Please let me know if u need any more information.如果您需要更多信息,请告诉我。

--- update #1 --- --- 更新 #1 ---

Nginx Server block Nginx 服务器块

server {
        root /var/www/html;
        index index.php index.html index.htm;

        server_name example.com; # managed by Certbot
       
        location /blogs/ {
                proxy_pass HTTP://localhost:8080/;
                proxy_set_header Host $host;
                proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_read_timeout 1800s;
        }

    listen [::]:443 ssl ipv6only=on; # managed by Certbot
    listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # :managed by Certbot
    if ($scheme != https) {
          return 301 https://$host$request_uri;
    }
}
server {
    if ($host = example.com) {
        return 301 https://$host$request_uri;
    } # managed by Certbot


        listen 80 ;
        listen [::]:80 ;
    server_name example.com;
    return 404; # managed by Certbot
}

Check in the wp_options table if siteurl and home are also set with https.如果还使用 https 设置了siteurlhome ,请检查 wp_options 表。

assuming you have a server block for your domain, make sure you have these lines in your server block to redirect all non-https request to https:假设您的域有一个服务器块,请确保您的服务器块中有这些行,以将所有非 https 请求重定向到 https:

    server {
        listen 80;
        listen 443 ssl http2;
        server_name example.com www.example.com;
the rest of your code
        if ($scheme != https) {
            return 301 https://example.com$request_uri;
the rest of your code
    }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM