TYPO3后台访问出现ERR_TOO_MANY_REDIRECTS重定向循环问题求助
问题:访问TYPO3后台出现ERR_TOO_MANY_REDIRECTS循环重定向
环境配置
- 架构:
Cloudflare (HTTPS) -> AWS ALB (HTTPS) -> AWS EC2 (HTTP) (nginx, php-fpm, typo3) - SSL模式:Cloudflare Full (strict),双层SSL终止(Cloudflare、AWS ALB各一次),TYPO3应用仅接收HTTP请求
当前配置
Nginx配置(取自TYPO3官方文档)
... location / { try_files $uri $uri/ /index.php$is_args$args; } location = /typo3 { rewrite ^ /typo3/; } location /typo3/ { absolute_redirect off; try_files $uri /typo3/index.php$is_args$args; } location ~ [^/]\.php(/|$) { fastcgi_split_path_info ^(.+?\.php)(/.*)$; if (!-f $document_root$fastcgi_script_name) { return 404; } fastcgi_buffer_size 32k; fastcgi_buffers 8 16k; fastcgi_connect_timeout 240s; fastcgi_read_timeout 240s; fastcgi_send_timeout 240s; fastcgi_pass php-fpm:9000; fastcgi_index index.php; include fastcgi.conf; }
TYPO3后台index.php(标准配置)
<?php call_user_func(static function () { $classLoader = require dirname(dirname(__DIR__)).'/vendor/autoload.php'; \TYPO3\CMS\Core\Core\SystemEnvironmentBuilder::run(1, \TYPO3\CMS\Core\Core\SystemEnvironmentBuilder::REQUESTTYPE_BE); \TYPO3\CMS\Core\Core\Bootstrap::init($classLoader)->get(\TYPO3\CMS\Backend\Http\Application::class)->run(); });
问题现象
访问https://<MY_DOMAIN>.com/typo3/时触发ERR_TOO_MANY_REDIRECTS错误;另一台直接在服务器端终止SSL的TYPO3站点无此问题,已开启nginx调试日志但无相关报错,推测是TYPO3因接收HTTP请求而强制重定向到HTTPS,形成循环。
解决方案
1. 给Nginx添加FastCGI协议参数
在Nginx的location ~ [^/]\.php(/|$)代码块中,新增以下参数,让TYPO3识别原始请求为HTTPS:
fastcgi_param HTTPS on; fastcgi_param HTTP_X_FORWARDED_PROTO https; fastcgi_param HTTP_X_FORWARDED_SSL on;
添加后,TYPO3会认为用户发起的是HTTPS请求,不会再触发强制HTTPS重定向。
2. 确认AWS ALB的转发头配置
确保AWS ALB已配置转发X-Forwarded-Proto、X-Forwarded-For等请求头,这样Nginx才能获取到前端的真实协议信息。
3. 检查TYPO3站点基础配置
进入TYPO3后台的站点配置,确认:
- 站点
Base URL设置为https://<MY_DOMAIN>.com/ Force SSL选项配置正确(如果开启,需确保TYPO3能识别HTTPS环境)
4. 清理浏览器缓存
循环重定向后浏览器会缓存错误的重定向规则,修改配置后建议清空浏览器缓存或使用隐私模式测试。
内容的提问来源于stack exchange,提问作者Subzero123
相关产品推荐
相关产品推荐

