开发者

How to get the Node's server IP behind a load balancer in Java

I have a webpage behind a load balancer, and I want to display the user (for 开发者_高级运维troubleshooting purposes) the IP of the actual node that the user is connected to (will be the same for a while due to sticky session)

I'm sure it's a very trivial question, but I want to be sure, what Java API should be used for that? will all APIs return me the request host? or will it be server dependent?


InetAddress.getLocalHost().getHostName() will give you the name of the server you are on. InetAddress.getLocalHost().getHostAddress() will give the IP Address of the server you are on.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜