title: Running tomcat behind multiple httpd proxy, how to log the IP of which proxy server the request goes through
body: <p>My system is running as architecture below</p>
  
  <p>clients -> physical LB -> httpd reverse proxy (multiple servers) -> tomcat (multiple servers)</p>
  
  <p>my question is how I could log the IP of the proxy server that the request goes through into the tomcat access log?</p>
  
  <p>here is my tomcat server.xml config</p>
  
  <pre><code>  &lt;Valve    className="org.apache.catalina.valves.RemoteIpValve"
              remoteIpHeader="x-forwarded-for"
              proxiesHeader="x-forwarded-by"
              protocolHeader="x-forwarded-proto"
    /&gt;
    &lt;Valve    className="org.apache.catalina.valves.AccessLogValve"
              requestAttributesEnabled="true"
              directory="${LOG_DIR}/tomcat"
              prefix="access."
              suffix=".log"
              pattern="%h %{org.apache.tomcat.remoteAddr}r %{X-Forwarded-For}i %A %{Host}i %u %t &amp;quot;%r&amp;quot; %s %b &amp;quot;%{Referer}i&amp;quot; &amp;quot;%{User-Agent}i&amp;quot; %I %D &amp;quot;%S&amp;quot; &amp;quot;%{COOKIE}i&amp;quot;"
              resolveHosts="false"
              fileDateFormat="yyyy-MM-dd"
              rotatable="true"
    /&gt;
  </code></pre>