我的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映像。
答案 0 :(得分:0)
Wordpress内部使用apache Web服务器路由请求,因此我假设您将nginx放在wp-apache堆栈之上。
您应该能够通过简单地使用下面的块将到达nginx代理的每个请求发送到apache来做到这一点
server {
server_name _;
listen 80;
location / {
proxy_pass http://localhost:8000;
}
}