“由于可能的配置错误,请求超出了 10 个内部重定向的限制”,而 WordPress 在反向代理后面
Posted
技术标签:
【中文标题】“由于可能的配置错误,请求超出了 10 个内部重定向的限制”,而 WordPress 在反向代理后面【英文标题】:"Request exceeded the limit of 10 internal redirects due to probable configuration error" while having WordPress behind a reverse-proxy 【发布时间】:2021-07-02 19:15:40 【问题描述】:我已经阅读了几十个问题/答案和博客文章,但没有一个对我有用。为了给你一些背景,我想做的是:
让我在 example.com 上的 Rails 应用在 Heroku 上运行 在 DigitalOcean 上运行在 example.com/blog 上的 Wordpress我尝试了很多不同的方法,但最后我无法解决当我尝试访问博客文章时出现的这个错误(访问博客主页或管理员工作正常):
[Tue Mar 30 21:46:24.047355 2021] [ssl:info] [pid 818] [client 54.89.204.173:53088] AH01964: Connection to child 2 established (server blog.example.com:443)
[Tue Mar 30 21:46:24.047582 2021] [ssl:debug] [pid 818] ssl_engine_kernel.c(2372): [client 54.89.204.173:53088] AH02043: SSL virtual host for servername blog.example.com found
[Tue Mar 30 21:46:24.057128 2021] [ssl:debug] [pid 818] ssl_engine_kernel.c(2254): [client 54.89.204.173:53088] AH02041: Protocol: TLSv1.3, Cipher: TLS_AES_256_GCM_SHA384 (256/256 bits)
[Tue Mar 30 21:46:24.057482 2021] [ssl:debug] [pid 818] ssl_engine_kernel.c(415): [client 54.89.204.173:53088] AH02034: Initial (No.1) HTTPS request received for child 2 (server blog.example.com:443), referer: https://example.com/blog/
[Tue Mar 30 21:46:24.057636 2021] [authz_core:debug] [pid 818] mod_authz_core.c(817): [client 54.89.204.173:53088] AH01626: authorization result of Require all granted: granted, referer: https://example.com/blog/
[Tue Mar 30 21:46:24.057645 2021] [authz_core:debug] [pid 818] mod_authz_core.c(817): [client 54.89.204.173:53088] AH01626: authorization result of <RequireAny>: granted, referer: https://example.com/blog/
[Tue Mar 30 21:46:24.057879 2021] [core:error] [pid 818] [client 54.89.204.173:53088] 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: https://example.com/blog/
[Tue Mar 30 21:46:24.057885 2021] [core:debug] [pid 818] core.c(3832): [client 54.89.204.173:53088] AH00121: r->uri = /blog/index.php, referer: https://example.com/blog/
[Tue Mar 30 21:46:24.057888 2021] [core:debug] [pid 818] core.c(3838): [client 54.89.204.173:53088] AH00122: redirected from r->uri = /blog/index.php, referer: https://example.com/blog/
[Tue Mar 30 21:46:24.057891 2021] [core:debug] [pid 818] core.c(3838): [client 54.89.204.173:53088] AH00122: redirected from r->uri = /blog/index.php, referer: https://example.com/blog/
[Tue Mar 30 21:46:24.057894 2021] [core:debug] [pid 818] core.c(3838): [client 54.89.204.173:53088] AH00122: redirected from r->uri = /blog/index.php, referer: https://example.com/blog/
[Tue Mar 30 21:46:24.057896 2021] [core:debug] [pid 818] core.c(3838): [client 54.89.204.173:53088] AH00122: redirected from r->uri = /blog/index.php, referer: https://example.com/blog/
[Tue Mar 30 21:46:24.057899 2021] [core:debug] [pid 818] core.c(3838): [client 54.89.204.173:53088] AH00122: redirected from r->uri = /blog/index.php, referer: https://example.com/blog/
[Tue Mar 30 21:46:24.057902 2021] [core:debug] [pid 818] core.c(3838): [client 54.89.204.173:53088] AH00122: redirected from r->uri = /blog/index.php, referer: https://example.com/blog/
[Tue Mar 30 21:46:24.057904 2021] [core:debug] [pid 818] core.c(3838): [client 54.89.204.173:53088] AH00122: redirected from r->uri = /blog/index.php, referer: https://example.com/blog/
[Tue Mar 30 21:46:24.057907 2021] [core:debug] [pid 818] core.c(3838): [client 54.89.204.173:53088] AH00122: redirected from r->uri = /blog/index.php, referer: https://example.com/blog/
[Tue Mar 30 21:46:24.057911 2021] [core:debug] [pid 818] core.c(3838): [client 54.89.204.173:53088] AH00122: redirected from r->uri = /blog/index.php, referer: https://example.com/blog/
[Tue Mar 30 21:46:24.057917 2021] [core:debug] [pid 818] core.c(3838): [client 54.89.204.173:53088] AH00122: redirected from r->uri = /hello-world/, referer: https://example.com/blog/
[Tue Mar 30 21:46:24.058076 2021] [ssl:debug] [pid 818] ssl_engine_io.c(1102): [client 54.89.204.173:53088] AH02001: Connection closed to child 2 with standard shutdown (server blog.example.com:443)
这是我正在使用的内容及其设置
我在 rails 应用程序上使用 rack-reverse-proxy gem:
config.middleware.insert(0, Rack::ReverseProxy) do
reverse_proxy_options preserve_host: true
reverse_proxy /^\/blog(\/.*)$/, 'https://example.com$1'
end
在 WordPress 常规设置中,我在 WordPress 地址和站点地址字段中都有“https://example.com/blog”。
我的 .htaccess 是由 WordPress 创建的:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%HTTP:Authorization]
RewriteBase /blog/
RewriteRule ^index\.php$ - [L]
RewriteCond %REQUEST_FILENAME !-f
RewriteCond %REQUEST_FILENAME !-d
RewriteRule . /blog/index.php [L]
</IfModule>
/etc/apache2/sites-enabled/000-default.conf
中的虚拟主机:
UseCanonicalName On
<VirtualHost *:80>
ServerAdmin webmaster@localhost
ServerName blog.example.com
ServerAlias www.blog.example.com
DocumentRoot /var/www/html
<Directory /var/www/html/>
Options FollowSymLinks
AllowOverride All
Require all granted
</Directory>
ErrorLog $APACHE_LOG_DIR/error.log
CustomLog $APACHE_LOG_DIR/access.log combined
RewriteEngine on
RewriteCond %SERVER_NAME =www.blog.example.com [OR]
RewriteCond %SERVER_NAME =blog.example.com
RewriteRule ^ https://%SERVER_NAME%REQUEST_URI [END,NE,R=permanent]
</VirtualHost>
更多线索
可能是一个线索:当我在没有登录的情况下访问 example.com/blog/wp-admin 时,它会将我重定向到 https://example.com/blog/wp-login.php?redirect_to=https%3A%2F%2Fblog.example.com%2Fwp-admin%2F&reauth=1
。而且我不知道这个“blog.example.com”域来自哪里。
我在 DigitalOcean 的 droplet 设置中将“blog.example.com”子域添加到 WordPress droplet。
【问题讨论】:
【参考方案1】:在 Apache 配置中查看您的服务名称。你把这个 blog.example.com。我相信这应该是www.example.com
【讨论】:
以上是关于“由于可能的配置错误,请求超出了 10 个内部重定向的限制”,而 WordPress 在反向代理后面的主要内容,如果未能解决你的问题,请参考以下文章