如果我尝试强制网站的某些区域使用 https,我会得到
错误 310 (net::ERR_TOO_MANY_REDIRECTS):重定向过多.
如果我自己只使用 页面呈现良好,只有当我强制它使用 https 时.
这是我的 security.yml,但如果我也使用注释,我也会得到同样的错误.
安全性:编码器:FOS\UserBundle\Model\UserInterface:sha512role_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 将尝试重定向导致循环:)
更多信息在这里.. blog.servergrove/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 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.. blog.servergrove/2011/04/04/symfony2-quick-tip-generateurl-with-https-on-nginx/
更多推荐
“require
发布评论