title: Get user machine's IP address when a website is configured with Apache Varnish in front of Tomcat
body: <p>Currently, I am running a website which is running on Tomcat which has Apache in front and varnish for caching. Tomcat is running on port <code>8080</code> and port <code>81</code> is used as varnish back end. I need to implement a feature for which I need to know the IP address of the client's machine visiting the website. I've tried to access the IP address by the header <code>X-FORWARDED-FOR</code>.</p>
  
  <p>When the website is accessed from port 81 (i.e. <a href="http://mywebsite.com:81/" rel="nofollow">http://mywebsite.com:81/</a>) I can get the IP address of the client's machine but unfortunately when accessing through default port 80 (i.e. <a href="http://mywebsite.com/" rel="nofollow">http://mywebsite.com/</a>) it's returning the localhost IP address (127.0.0.1). Can anyone suggest what can be the worked around to get the user's real IP address from port 80 as well?</p>