Configuring logback.xml to log X-Forwarded-For/Client IP
Khawer Masood
shehzada at gwu.edu
Wed Sep 23 10:40:52 EDT 2015
>> Our Load Balancer is setting X-Forwarded-For, and it appears correctly in httpd logs; a small java app I wrote to print all the headers, prints the X-Forwarded-For and other X-Forwarded headers correctly, so Jetty is getting it.
>
> What matters is what getRemoteAddr() returns. If Jetty isn't changing that, you don't have it configured to use that request customizer thing.
Thanks, this was it! I was modifying a jetty.xml outside ${jetty.base} … (-: …. Once the correct jetty.xml was modified and the webapp/WEB-INF/web.xml edited with the MDC filter, we were able to capture the XFF IP using:
<Pattern>%msg|%X{req.xForwardedFor}|%n</Pattern>
Oh, and we had to now allow the Load Balancer IPs access in conf/access_control.xml — our LB parses the /idp/status page to check if the service is running. With just the jetty.xml change, the LB was getting 403s when calling /idp/status.
Thanks again Scott and Brent!
KM
More information about the users
mailing list