title: java httpRequest getRemoteAddr allways return 127.0.0.1
body: <p>Hello everybody and thanks for your help,</p>
  
  <p>I am developing a web application using JSF and for security reasons i need to capture the user's IP when he does the log in.</p>
  
  <p>I am using the following code:</p>
  
  <pre><code>HttpServletRequest request=(HttpServletRequest) context.getExternalContext().getRequest();
  remoteAddress=request.getRemoteAddr();
  </code></pre>
  
  <p>The thing is that when I check my app logs to check the ip address it always returns 127.0.0.1.</p>
  
  <p>[INFO]      07/01/2014 11:04:22 --> User xxx connected from 127.0.0.1</p>
  
  <p>[INFO]      07/01/2014 11:27:43 --> User xxx connected from 127.0.0.1</p>
  
  <p>For more detail:</p>
  
  <ul>
  <li>I am using tomcat 7</li>
  <li>My server works inside a debian virtual machine</li>
  <li>I am connecting to the server from a different pc from the one containing the VM.</li>
  </ul>
  
  <p>I have searched in internet and read about using:</p>
  
  <pre><code>request.getHeader("X-FORWARDED-FOR");
  </code></pre>
  
  <p>But It did not solved my problem.</p>
  
  <p>I am quite lost at the moment, any ideas why is this happening?</p>