解决wordpress 302循环重定向

我在用nginx转发内网wordpress的时候,css等样式加载不出来,点登陆,一堆302重定向报错:(ip已经隐去)

X.X.X.X - - [26/Sep/2019:14:28:23 +0800] "GET /wp-login.php HTTP/1.1" 302 5 "https://blog.fencatn.net/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.132 Safari/537.36 OPR/63.0.3368.94" "Y.Y.Y.Y"
X.X.X.X - - [26/Sep/2019:14:28:23 +0800] "GET /wp-login.php HTTP/1.1" 302 5 "https://blog.fencatn.net/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.132 Safari/537.36 OPR/63.0.3368.94" "Y.Y.Y.Y"
X.X.X.X - - [26/Sep/2019:14:28:23 +0800] "GET /wp-login.php HTTP/1.1" 302 5 "https://blog.fencatn.net/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.132 Safari/537.36 OPR/63.0.3368.94" "Y.Y.Y.Y"
X.X.X.X - - [26/Sep/2019:14:28:23 +0800] "GET /wp-login.php HTTP/1.1" 302 5 "https://blog.fencatn.net/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.132 Safari/537.36 OPR/63.0.3368.94" "Y.Y.Y.Y"
X.X.X.X - - [26/Sep/2019:14:28:23 +0800] "GET /wp-login.php HTTP/1.1" 302 5 "https://blog.fencatn.net/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.132 Safari/537.36 OPR/63.0.3368.94" "Y.Y.Y.Y"
X.X.X.X - - [26/Sep/2019:14:28:23 +0800] "GET /wp-login.php HTTP/1.1" 302 5 "https://blog.fencatn.net/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.132 Safari/537.36 OPR/63.0.3368.94" "Y.Y.Y.Y"
X.X.X.X - - [26/Sep/2019:14:28:23 +0800] "GET /wp-login.php HTTP/1.1" 302 5 "https://blog.fencatn.net/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.132 Safari/537.36 OPR/63.0.3368.94" "Y.Y.Y.Y"
X.X.X.X - - [26/Sep/2019:14:28:23 +0800] "GET /wp-login.php HTTP/1.1" 302 5 "https://blog.fencatn.net/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.132 Safari/537.36 OPR/63.0.3368.94" "Y.Y.Y.Y"
X.X.X.X - - [26/Sep/2019:14:28:23 +0800] "GET /wp-login.php HTTP/1.1" 302 5 "https://blog.fencatn.net/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.132 Safari/537.36 OPR/63.0.3368.94" "Y.Y.Y.Y"
X.X.X.X - - [26/Sep/2019:14:28:23 +0800] "GET /wp-login.php HTTP/1.1" 302 5 "https://blog.fencatn.net/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.132 Safari/537.36 OPR/63.0.3368.94" "Y.Y.Y.Y"

这个报错困扰我很久,网上各种查,今天终于找到个靠谱的,按他的方法解决了,我粘贴下原文,并感谢原作者:

https://www.hida.in/2019/09/03/wordpress-wp-admin-302循环重定向/

阿里云的虚拟机过期了,更换为ECS。wordpress用的是docker镜像,在nginx代理后面。配置好后,首页部分静态资源因为不是https没有加载,显示不正常,我怀疑是网站配置问题,就先忽略了。控制台页面无法打开,循环重定向,查询很多方法无效。后来在dockerhub上的wordpress页面发现nginx需要添加一个选项,按照说明添加后就可以正常访问了。下面就是添加的内容。

proxy_set_header X-Forwarded-Proto https;

方法就是去nginx转发器上添加

proxy_set_header X-Forwarded-Proto https;

此条目发表在Nginx, wordpress分类目录,贴了, 标签。将固定链接加入收藏夹。

发表评论

您的电子邮箱地址不会被公开。 必填项已用*标注