[英]Reverse proxy from Nginx to Dockerized Wordpress is causing an infinite redirect loop
My Wordpress website should appear at http://192.168.122.50/blog/
我的Wordpress网站应该出现在http://192.168.122.50/blog/
I started out by creating this server block 我开始创建这个服务器块
server {
server_name 192.168.122.50;
listen 80;
location /blog/ {
proxy_pass http://localhost:8000; # My Wordpress site
}
}
Next, I added the two following lines to my Wordpress config (wp-config.php): 接下来,我将以下两行添加到我的Wordpress配置(wp-config.php):
define( 'WP_HOME', 'http://192.168.122.50/blog/' );
define( 'WP_SITEURL', 'http://192.168.122.50/blog/' );
I keep getting infinite redirect loops to this URL: http://192.168.122.50/blog/wp-admin/install.php
我一直在为这个URL获得无限的重定向循环: http://192.168.122.50/blog/wp-admin/install.php
: http://192.168.122.50/blog/wp-admin/install.php
Here is the HTTP response I receive, according to httpie: 根据httpie,这是我收到的HTTP响应:
HTTP/1.1 302 Found
Cache-Control: no-cache, must-revalidate, max-age=0
Connection: keep-alive
Content-Length: 0
Content-Type: text/html; charset=UTF-8
Date: Sun, 07 Apr 2019 15:13:50 GMT
Expires: Wed, 11 Jan 1984 05:00:00 GMT
Location: http://192.168.122.50/blog/wp-admin/install.php
Server: nginx/1.12.2
X-Powered-By: PHP/7.2.17
X-Redirect-By: WordPress
I have attempted to fix this issue by adding the following lines after the proxy_pass, but to no avail. 我试图通过在proxy_pass之后添加以下行来解决此问题,但无济于事。
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
Also, I am using the wordpress:latest
Docker image. 另外,我使用wordpress:latest
Docker镜像。
Wordpress uses apache web server internally to route request so i am assuming you are puting nginx on top of wp-apache stack. Wordpress在内部使用apache web服务器来路由请求,所以我假设你把nginx放在wp-apache堆栈之上。
you should able to do this by sending every request coming to nginx proxy passing to apache by simply using below block 你应该能够通过简单地使用下面的块发送到nginx代理的每个请求传递给apache来做到这一点
server {
server_name _;
listen 80;
location / {
proxy_pass http://localhost:8000;
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.