How do I get the remote address of a client in servlet?

前端 未结 10 2035
刺人心
刺人心 2020-11-22 07:32

Is there any way that I could get the original IP address of the client coming to the server? I can use request.getRemoteAddr(), but I always seem to get the IP

10条回答
  •  迷失自我
    2020-11-22 08:26

    You cannot do this in a meaningful way.

    The proxy may or may not add a proxied-for header, but in many cases this will be an internal only address anyway, so it will be meaningless to you. Most proxies at the edge of an organization are configured to reveal as little as possible about the internals of the network anyway.

    What are you intending to use this information for?

提交回复
热议问题