title: Tomcat: 'X-Forwarded-For' doesn't work with load balancer
body: <p>We are currently working on a redundant server setup (2 servers + 1 load balancer) using Tomcat 7 update 76. To fulfill the logging requirements of our company, we are trying to get the IP of the remote server, that actually sends the request, not the IP of the load balancer. Unfortunately we were not able to get it to work with the following documentation: </p>
  
  <ul>
  <li><a href="https://tomcat.apache.org/tomcat-7.0-doc/api/org/apache/catalina/valves/RemoteIpValve.html" rel="nofollow noreferrer">https://tomcat.apache.org/tomcat-7.0-doc/api/org/apache/catalina/valves/RemoteIpValve.html</a></li>
  <li><a href="https://tomcat.apache.org/tomcat-7.0-doc/api/org/apache/catalina/valves/AccessLogValve.html" rel="nofollow noreferrer">https://tomcat.apache.org/tomcat-7.0-doc/api/org/apache/catalina/valves/AccessLogValve.html</a></li>
  <li><a href="https://tomcat.apache.org/tomcat-7.0-doc/config/valve.html#Remote_IP_Valve" rel="nofollow noreferrer">https://tomcat.apache.org/tomcat-7.0-doc/config/valve.html#Remote_IP_Valve</a></li>
  </ul>
  
  <p>We used the following configuration for access logging and remote valve:</p>
  
  <pre><code>&lt;Valve className="org.apache.catalina.valves.RemoteIpValve" internalProxies="xxx\.xxx\.xxx\.7|xxx\.xxx\.xxx\.8|xxx\.xxx\.xxx\.9"  remoteIpHeader="X-Forwarded-For" /&gt;
  &lt;Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
  prefix="access_log." suffix=".log"
  pattern="%{org.apache.catalina.AccessLog.RemoteAddr}r %l %u %t &amp;quot;%r&amp;quot; %s %b" 
  requestAttributesEnabled="true" /&gt;
  </code></pre>
  
  <p>The request header 'X-Forwarded-For' was set and load balancer was analyzed via wireshark. However we still only get the IP of the load balancer and not the IP of the remote client. The IP adresses of the config have already been checked and they are correct.</p>