What is a clean, Symfony way of ensuring HTTPS is being used in Symfony2 when behind an EC2 load balancer that is handling the SSL connection and sending it to you as HTTP.
If you do something like requires_channel you get a redirect loop after the initial change to HTTPS because on the webserver itself you are still doing HTTP. The url does show HTTPS though, and Amazon provide a X-FORWARDED-PROTO header to use as well.
Is there a clean way of having symfony2 handle this kind of situation?
You should check if this method is suitable for you.
In your app.php
before the $kernel->handle(...);
you should set:
Request::trustProxyData();
UPDATE:
You can also configure your application in config.yml
(see doc):
framework:
...
trust-proxy-headers: true
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