我正在 Heroku 上运行 symfony2 应用程序,我需要获取可信代理(IP) 我的应用程序将按照此处所述运行:http://symfony.com/blog/new-in-symfony-2-3-use-sub-networks-to-configure-trusted-proxies
Dyno manifold 中提到了 Dyno 可以获得的 IP。也就是说:
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.
该框架实际上有一些选项,例如:
framework:
trust_proxy_headers: true
但这很快就会被弃用......
谢谢! :)
最佳答案
您可能只需在前端 Controller 中添加一个信任传入 IP 的调用(因为到达服务器的唯一方法是通过 Heroku 路由层):
Request::setTrustedProxies(array($_SERVER['REMOTE_ADDR']));
关于symfony - Heroku 可信代理,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16180486/