[英]PHP - Amazon Elastic Beanstalk - Get private IP address
I am hosting a web app in Amazon Elastic Beanstalk (EB). 我在Amazon Elastic Beanstalk(EB)中托管一个Web应用程序。 The web app is written in php.
该网络应用程序是用php编写的。 EB also uses Elastic Load Balancer (ELB).
EB还使用弹性负载平衡器(ELB)。 The web app implements a websocket with the client.
该Web应用程序与客户端实现一个websocket。 Here is what I have done so far:
到目前为止,这是我所做的:
If the EB deployment goes for horizontal scaling (increase the number of instances), will the private ips of the scaled instances remain same ( please explain )? 如果EB部署用于水平扩展(增加实例数),则扩展后实例的私有IP是否保持不变( 请说明 )? If not, and I believe so, how do I get the private ip address of the current instance that is serving the client?
如果没有,并且我相信,我如何获取正在为客户端提供服务的当前实例的私有IP地址?
So far its working perfectly without any problem, but there's only one instance running. 到目前为止,它可以完美运行,没有任何问题,但是只有一个实例正在运行。 I tried listing the clients and I can get the private ips with the list but I don't know how to identify the instance that is currently serving the file.
我尝试列出客户端,并且可以使用列表获取私有ip,但是我不知道如何识别当前为文件提供服务的实例。
Please help me. 请帮我。
This will do the trick: 这将达到目的:
<?php $ip = shell_exec('hostname -i'); ?>
important: this works only for the linux environment. 重要:这仅适用于linux环境。 For windows,
hostname -i
is not valid. 对于Windows,
hostname -i
无效。 You can refer to https://superuser.com/questions/382265/ for further ideas. 您可以参考https://superuser.com/questions/382265/了解更多信息。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.