我在Docker容器中有一个WordPress服务器。WordPress在里面运行Nginx服务器。当我经历初始安装阶段时,CSS(和其他文件)工作得很好。但是当我加载主站点时,这些资源重定向到HTTP://example.com/blogs/.而不是HTTPS。
以下是来自inspect的URL:
https://example.com/blogs/
http://example.com/blogs/wp-includes/js/wp-emoji-release.min.js?ver=5.1.1
字符串
以下是我从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;
}
型
我已经用以下信息更新了wp-wp.php文件
define('WP_HOME','https://example.com/blogs/');
define('WP_SITEURL','https://example.com/blogs/');
$_SERVER['REQUEST_URI'] = '/blogs' . $_SERVER['REQUEST_URI'];
型
请让我知道如果你需要更多的信息。
- 更新#1 -
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
}
型
2条答案
按热度按时间xdnvmnnf1#
如果
siteurl
和home
也设置为https,请检查wp_options表。omqzjyyz2#
假设您的域有一个服务器块,请确保您的服务器块中有这些行,以将所有非https请求重定向到https:
字符串