Get IP address of client in JSP

前端 未结 4 696
慢半拍i
慢半拍i 2021-02-09 11:36

I need to get the IP address of the client in the JSP page. I have tried the following ways:

request.getRemoteAddr()
request.getHeader(\"X_FORWARDED_FOR\")
reque         


        
4条回答
  •  渐次进展
    2021-02-09 12:08

    do you use reverse proxy like apache proxy? http://httpd.apache.org/docs/2.2/mod/mod_proxy.html

    When acting in a reverse-proxy mode (using the ProxyPass directive, for example), mod_proxy_http adds several request headers in order to pass information to the origin server. These headers are:

    X-Forwarded-For
    The IP address of the client.
    X-Forwarded-Host
    The original host requested by the client in the Host HTTP request header.
    X-Forwarded-Server
    The hostname of the proxy server.
    

提交回复
热议问题