从Nginx到Dockerized Wordpress的反向代理导致无限重定向循环

问题描述 投票:0回答:1

我的Wordpress网站应该出现在http://192.168.122.50/blog/

我开始创建这个服务器块

server {
  server_name 192.168.122.50;
  listen 80;

  location /blog/ {
    proxy_pass http://localhost:8000; # My Wordpress site
  }
}

接下来,我将以下两行添加到我的Wordpress配置(wp-config.php):

define( 'WP_HOME', 'http://192.168.122.50/blog/' );                                                                                  
define( 'WP_SITEURL', 'http://192.168.122.50/blog/' );   

我一直在为这个URL获得无限的重定向循环:http://192.168.122.50/blog/wp-admin/install.php

根据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

我试图通过在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;

此外,我正在使用wordpress:latest Docker镜像。

wordpress docker nginx reverse-proxy
1个回答
0
投票

Wordpress在内部使用apache web服务器来路由请求,所以我假设你把nginx放在wp-apache堆栈之上。

你应该能够通过简单地使用下面的块发送到nginx代理的每个请求传递给apache来做到这一点

server {
  server_name _;
  listen 80;
    location / {
       proxy_pass http://localhost:8000;
    }
}
最新问题
© www.soinside.com 2019 - 2024. All rights reserved.