“require

编程入门 行业动态 更新时间:2024-10-21 09:53:17
本文介绍了“require_channel:https"导致错误 310,重定向过多的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

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

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

如果我自己只使用 页面呈现良好,只有当我强制它使用 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 将尝试重定向导致循环:)

更多信息在这里.. 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

本文发布于:2023-10-31 16:19:27,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1546617.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:require

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!