如何解决“由于可能的配置错误,请求超出了 10 个内部重定向的限制”,同时将 WordPress 置于反向代理之后 这是我正在使用的和它们的设置更多线索
我已经阅读了许多问题/答案和博客文章,但没有一个对我有用。为了给你一些背景,我想做的是:
- 让我在 example.com 上的 Rails 应用程序在 Heroku 上运行
- 在 example.com/blog 上让 wordpress 在 DigitalOcean 上运行
我尝试了很多不同的方法,但最终我无法解决当我尝试访问博客文章时出现的这个错误(访问博客主页或管理员工作正常):
[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。
解决方法
在 Apache 配置中查看您的服务名称。你把这个 blog.example.com。我相信这应该是 www.example.com
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。