“require_channel:https"导致错误 310,重定向过多 [英] "require_channel: https" causes Error 310, Too Many Redirects

查看:38
本文介绍了“require_channel:https"导致错误 310,重定向过多的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我尝试强制网站的某些区域使用 https,我会得到

错误 310 (net::ERR_TOO_MANY_REDIRECTS):重定向过多.

如果我自己只使用 https://页面呈现良好,只有当我强制它使用 https 时.

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

安全性:编码器:FOS\UserBundle\Model\UserInterface:sh​​a512role_hierarchy:ROLE_ADMIN:ROLE_USERROLE_MERCHANT:ROLE_USERROLE_SUPER_ADMIN: [ROLE_USER, ROLE_ADMIN, ROLE_ALLOWED_TO_SWITCH, ROLE_MERCHANT]供应商:fos_userbundle:id:fos_user.user_provider.username_email防火墙:开发:模式:^/(_(分析器|wdt)|css|图像|js)/安全:假主要的:模式:^/表单登录:提供者:fos_userbundlecsrf_provider: form.csrf_providerdefault_target_path:/dashboard登出:真的匿名:真实访问控制:- { 路径:^/login$,角色:IS_AUTHENTICATED_ANONYMOUSLY}- { 路径:^/login_check$,角色:IS_AUTHENTICATED_ANONYMOUSLY }- { 路径:^/注册,角色:IS_AUTHENTICATED_ANONYMOUSLY }- { 路径:^/resetting,角色:IS_AUTHENTICATED_ANONYMOUSLY }- { 路径:^/admin/,角色:ROLE_ADMIN,requires_channel:https }- { 路径:^/dashboard,角色:ROLE_USER,requires_channel:https}- { 路径:^/invoice/new,角色:ROLE_MERCHANT,requires_channel:https}- { 路径:^/发票,角色:ROLE_USER,requires_channel:https}

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

解决方案

尝试添加

fastcgi_param HTTPS 开启;

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

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

If I try and force certain areas of my site to use https I get

Error 310 (net::ERR_TOO_MANY_REDIRECTS): There were too many redirects.

If I just use https:// myself the page renders fine, it's only when I force it to use https.

This is my security.yml, but I get the same error if I use annotations too.

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}

I'm running on nginx rather than Apache too.

解决方案

Try adding

fastcgi_param HTTPS on;

To your nginx vhost, that will help Symfony recognize that the request is a SSL request, symfony is checking against the HTTPS global variable to check if the request is SSL or not and redirect acordingly, if that variable is not set inside by the webserver on a SSL request symfony will try to redirect causing the loop :)

More info over here.. http://blog.servergrove.com/2011/04/04/symfony2-quick-tip-generateurl-with-https-on-nginx/

这篇关于“require_channel:https"导致错误 310,重定向过多的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆