Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Symfony2 HTTPS requirement behind EC2 load balancer

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?

like image 314
Dave Avatar asked Jul 31 '12 09:07

Dave


1 Answers

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
like image 100
Vitalii Zurian Avatar answered Oct 15 '22 08:10

Vitalii Zurian