How do I restore original visitor IP with Tomcat7?

To have Tomcat7 automatically restore the original visitor IP to your access logs and application you will need to add %{CF-Connecting-IP}i into your log schema.

As an example, you could add the below block to your server.xml file.

<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
prefix="localhost_access_log." suffix=".txt"
pattern="%{CF-Connecting-IP}i - %h %u %t - &quot;%r&quot; - %s - %b - %{CF-RAY}i" />

Which would result in your logs looking like this.

Visitor IP - Cloudflare IP - [04/Dec/2014:23:18:15 -0500] - "GET / HTTP/1.1" - 200 - 1895 - 193d704b85200296-SJC
Still not finding what you need?

The Cloudflare team is here to help. 95% of questions can be answered using the search tool, but if you can’t find what you need, submit a support request.

Powered by Zendesk