title: When HttpServletRequest getHeader return unknown?
body: <p>I am using the below code (Copied from another post - <a href="https://stackoverflow.com/questions/4678797/how-do-i-get-the-remote-address-of-a-client-in-servlet">How do I get the remote address of a client in servlet?</a>) to get the client IP address along with the proxy server (SpringBoot Appln deployed in PCF).</p>
  
  <pre><code>  public static String getClientIpAddr(HttpServletRequest request)
    {
      String ip = request.getHeader("X-Forwarded-For");
      if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip))
      {
        ip = request.getHeader("Proxy-Client-IP");
      }
      if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip))
      {
        ip = request.getHeader("WL-Proxy-Client-IP");
      }
      if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip))
      {
        ip = request.getHeader("HTTP_CLIENT_IP");
      }
      if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip))
      {
        ip = request.getHeader("HTTP_X_FORWARDED_FOR");
      }
      if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip))
      {
        ip = request.getRemoteAddr();
      }
      return ip;
    }
  </code></pre>
  
  <p>request.getHeader("X-Forwarded-For"); /request.getRemoteAddr(); (when run from local) gives the expected result. I really didn't understand the uses of other conditions.</p>
  
  <ol>
  <li>In all conditions I see "unknown".equalsIgnoreCase(IP) is used. But when I try to access request.getHeader("Proxy-Client-IP") or any junk string, I am getting null.
  When HttpServletRequest getHeader return unknown? Can this be ignored? </li>
  <li>What is the use of Proxy-Client-IP/HTTP_CLIENT_IP. I guess it is used to get client IP alone (without proxy server IP). Is it specific to a particular server? if so which server. 
  Can this be ignored in Spring boot application</li>
  <li>I guess 'WL-Proxy-Client-IP' is specific to WebLogic. Can this be ignored as well?</li>
  <li>I believe the HTTP_ prefix is specific to PHP (HTTP_X_FORWARDED_FOR and HTTP_CLIENT_IP.) Is it necessary in the SpringBoot application?</li>
  <li><p>I feel the below code is more than enough to get the client IP address along with the proxy server (provided I use spring boot with embedded tomcat and deploy the code in PCF). Could you please confirm?</p>
  
  <pre><code>private static String getClientIpAddr(HttpServletRequest httpRequest)
  {
    String clientIp = httpRequest.getHeader("X-Forwarded-For");
  
    if (clientIp == null || clientIp.length() == 0)
    {
      clientIp = httpRequest.getRemoteAddr();
    }
    return clientIp;
  }
  </code></pre></li>
  </ol>