EC2背后负载平衡器Symfony2的HTTPS要求 [英] Symfony2 HTTPS requirement behind EC2 load balancer
问题描述
什么是保证HTTPS干净,Symfony的方式正在Symfony2中使用时,身后一个EC2负载平衡器正在处理SSL连接,并将其发送给你的HTTP。
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.
如果你做这样的事情requires_channel你得到初步改变为HTTPS后重定向循环,因为在Web服务器本身,你还在做HTTP。该URL显示HTTPS虽然和亚马逊提供的X转发-PROTO头使用为好。
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.
有有Symfony2的处理这种情况的一个干净的方式?
Is there a clean way of having symfony2 handle this kind of situation?
推荐答案
您应该检查是否这方法是适合你的。
You should check if this method is suitable for you.
在你的 app.php
在 $内核级>手柄(...);
你应该设置:
Request::trustProxyData();
更新:
您还可以配置你的应用程序中的 config.yml
(见<一href="http://symfony.com/doc/current/reference/configuration/framework.html#trust-proxy-headers">doc):
You can also configure your application in config.yml
(see doc):
framework:
...
trust-proxy-headers: true
这篇关于EC2背后负载平衡器Symfony2的HTTPS要求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!