gpt4 book ai didi

symfony - "require_channel: https"导致错误 310,重定向过多

转载 作者:行者123 更新时间:2023-12-04 17:07:58 26 4
gpt4 key购买 nike

如果我尝试强制网站的某些区域使用 https,我会得到
Error 310 (net::ERR_TOO_MANY_REDIRECTS): There were too many redirects.
如果我自己只使用 https://页面呈现良好,只有当我强制它使用 https 时。

这是我的 security.yml,但如果我也使用注释,我会得到同样的错误。

security:
encoders:
FOS\UserBundle\Model\UserInterface: sha512

role_hierarchy:
ROLE_ADMIN: ROLE_USER
ROLE_MERCHANT: ROLE_USER
ROLE_SUPER_ADMIN: [ROLE_USER, ROLE_ADMIN, ROLE_ALLOWED_TO_SWITCH, ROLE_MERCHANT]

providers:
fos_userbundle:
id: fos_user.user_provider.username_email

firewalls:
dev:
pattern: ^/(_(profiler|wdt)|css|images|js)/
security: false
main:
pattern: ^/
form_login:
provider: fos_userbundle
csrf_provider: form.csrf_provider
default_target_path: /dashboard
logout: true
anonymous: true

access_control:
- { path: ^/login$, role: IS_AUTHENTICATED_ANONYMOUSLY}
- { path: ^/login_check$, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/register, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/resetting, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/admin/, role: ROLE_ADMIN, requires_channel: https }
- { path: ^/dashboard, role: ROLE_USER, requires_channel: https}
- { path: ^/invoice/new, role: ROLE_MERCHANT, requires_channel: https}
- { path: ^/invoice, role: ROLE_USER, requires_channel: https}

我也在 nginx 而不是 Apache 上运行。

最佳答案

尝试添加

fastcgi_param HTTPS on;

对于您的 nginx vhost,这将帮助 Symfony 识别请求是 SSL 请求,symfony 正在检查 HTTPS 全局变量以检查请求是否为 SSL 并相应地重定向,如果该变量未在 Web 服务器内部设置SSL 请求 symfony 将尝试重定向导致循环:)

更多信息在这里.. http://blog.servergrove.com/2011/04/04/symfony2-quick-tip-generateurl-with-https-on-nginx/

关于symfony - "require_channel: https"导致错误 310,重定向过多,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17250438/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com