我有一个 wordpress 托管在 Apache2 上,前面有 Nginx。
<WORLD> ===> <NGINX PROXY> --> APACHE/DOCKER/STATIC WEBSITE etc...
我的 wordpress 代理的 nginx conf 是:
server {
server_name dev-www.example.com;
location / {
proxy_pass http://127.0.0.1:13400;
}
}
我的 Apache 配置:
Listen 13400
<VirtualHost 127.0.0.1:13400>
CustomLog /var/log/httpd/sites/dev-www/access_log combined
ErrorLog /var/log/httpd/sites/dev-www/error_log
DirectoryIndex index.php
DocumentRoot /var/www/sites/example.com/dev-www
RewriteEngine On
<Directory /var/www/sites/example.com/dev-www/>
Options Indexes FollowSymLinks
AllowOverride all
</Directory>
</VirtualHost>
和 wordpress .htaccess
:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php [L]
</IfModule>
# END WordPress
问题是当我继续 dev-www.example.com/foobar.php
我被重定向到 127.0.0.1/foobar.php
.我知道它来自 nginx
配置127.0.0.1
弹出如何修复它?
我尝试将代理传递给 dev-www.example.com:13400
但我得到了一个无限循环:
[Tue May 10 23:44:45.001680 2016] [core:error] [pid 1096] [client 127.0.0.1:54887] AH00124: Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace., referer: http://dev-www.example.com/
注意:http://dev-www.example.com
没有问题或 http://dev-www.example.com/index.php
谢谢。
注意 2:如果我将 nginx 配置更改为 localhost:13400,那么我将被重定向到 localhost/login-3。它看起来像 .htaccess 重定向到 ServName,它是 127.0.0.1
最佳答案
它是 wordpress 重定向到 HTTP_HOST
,添加
$_SERVER['HTTP_HOST'] = $_SERVER['HTTP_X_FORWARDED_HOST'];
在 wp-config.php
中修复它。
关于php - 当访问在代理中使用 apache 和 nginx 托管的 wordpress 时重定向到 127.0.0.1,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37149842/