Heroku受信任的代理 [英] Heroku trusted proxies

查看:155
本文介绍了Heroku受信任的代理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 Heroku 上运行 symfony2 应用程序,我需要获取可信代理(IP(s))
后面我的应用程序将按照此处所述运行: http://symfony.com/blog/new-in-symfony-2-3-use-sub-networks-to-configure-trusted-proxies

有一个关于Dyno可以在 Dyno流形中说:


运行多个dynos时,应用程序分布在多个节点$ d $ b by the dyno manager。访问您的应用程序始终通过
路由器。



因此,dynos没有静态IP地址。尽管您不能直接连接到测功机,但可以从测功机发出传出的
请求。然而,你可以指望dyno的IP地址
随着它在不同地方重新启动而改变。


该框架实际上具有一些选项,如:

$ $ p $ code $ framework
trust_proxy_headers:
pre>

但是,这个问题很快就会被废弃......



谢谢! :)

解决方案

您可能只需在前端控制器中添加一个相信传入IP的呼叫(因为只有这样才能获得到你的服务器是通过Heroku路由层):

  Request :: setTrustedProxies(array($ _ SERVER ['REMOTE_ADDR']) ); 


I'm running a symfony2 application on Heroku, and I need to get the trusted proxies ( IP(s) ) behind which my app is going to be running as described in here : http://symfony.com/blog/new-in-symfony-2-3-use-sub-networks-to-configure-trusted-proxies

There is a mention about the IP(s) a Dyno can get in the Dyno manifold that say :

When running multiple dynos, apps are distributed across several nodes by the dyno manager. Access to your app always goes through the routers.

As a result, dynos don’t have static IP addresses. While you can never connect to a dyno directly, it is possible to originate outgoing requests from a dyno. However, you can count on the dyno’s IP address changing as it gets restarted in different places.

The framework actually has some option like :

framework:
    trust_proxy_headers: true

But this is going to be deprecated soon...

Thanks ! :)

解决方案

You can probably just add a call in your front controller that trusts the incoming IP (since the only way to get to your server is via the Heroku routing layer):

Request::setTrustedProxies(array($_SERVER['REMOTE_ADDR']));

这篇关于Heroku受信任的代理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆