Thanks Jaymer. Sorry for extremly delayed response. I only work on this part time.
So if anyone is interested.. this is what worked for me... in server.xml (IP addresses have been changed)
<Host name="localhost" appBase="webapps" unpackWARs="true" autoDeploy="true" >
<Valve className="org.apache.catalina.valves.RemoteIpValve"internalProxies="123.456.789.876|456.789.012.345" remoteIpHeader="x-forwarded-for" proxiesHeader="x-forwarded-by" trustedProxies="proxy1|proxy2" />
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
prefix="awareim_access_log" suffix=".txt"
pattern="%{x-forwarded-for}i %l %u %t "%r" %s %b" />
</Host>
So basically... the RemoteIPValve tells the server that if the Remote IP is one of the IP's you've listed, then it will look for and use the Forwarded IP address.
----- What we're looking at : -----------------
<Host name="localhost" appBase="webapps" unpackWARs="true" autoDeploy="true" > <<-- No idea what any of this means except 'localhost' needs to be your actual server in my case it is localhost
<Valve className="org.apache.catalina.valves.RemoteIpValve"internalProxies="123.456.789.876|456.789.012.345" remoteIpHeader="x-forwarded-for" proxiesHeader="x-forwarded-by" trustedProxies="proxy1|proxy2" /> <<-- this is the important bit. The addresses are the IP addresses of the Reverse Proxy's firewall's (the IP's that will be accessing your server. If you're using a Reverse Proxy Service (like I am, as opposed to using say NGINX or Caddy), they will give you a list of addresses that you need to let through your own firewall: them's the one's). And then then you gotta put that last bit in 'trustedProxies' and basically just "proxy1|proxy2|proxy3... etc etc.
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
prefix="awareim_access_log" suffix=".txt" <<-- This is your log. Look at it to see if it's all working or not
pattern="%{x-forwarded-for}i %l %u %t "%r" %s %b" /> <<-- Again... No Idea what any of this means
</Host>
IP's are separated by: |
The annoying bit was, I can't work out how to specify an IP range, so you have to list every IP. In my case there are 12 IP addresses !!... Which also means I had to specify "proxy1|proxy2|....proxy12"
So I came up with this from a combination of Jaymer's reply, and looking up the actual Tomcat manual online, and if I recall there's a post on stackoverflow about it as well.