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/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With