我在 Centos 7 VPS 上运行一个包含 Wordpress、MYSQL 和 PHP 的 docker 容器。
我可以正常访问博客的前端。我也可以登录管理面板并安装插件,但当我尝试保存页面、保存帖子或对它们进行任何类型的更新时,我收到以下错误:
但是,如果我手动用我的域名替换 0.0.0.0:8000,例如 domain.com/wp-json/wp/v2/,那么就不会出现错误。
这是我的 Nginx 设置:
server {
server_name domain.com www.domain.com;
location / {
proxy_pass http://0.0.0.0:8000;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Proto $scheme;
}
if ( $http_host ~* "www\.(.*)") {
return 301 https://$1$request_uri;
}
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/domain.com/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/domain.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
}
server {
if ($host = www.domain.com) {
return 301 https://$host$request_uri;
} # managed by Certbot
if ($host = domain.com) {
return 301 https://$host$request_uri;
} # managed by Certbot
server_name domain.com www.domain.com;
listen 80;
return 404; # managed by Certbot
}
我需要某种方式让 Wordpress 始终使用我的域名。
答案1
修改wp-config.php并添加WP_HOME和WP_SITEURL。 https://wordpress.org/support/article/changing-the-site-url/
或者直接在数据库中更改它(在 wp_options 内)