Last active
December 20, 2015 02:09
-
-
Save emag/6054353 to your computer and use it in GitHub Desktop.
This is a Byteman rule to get real IP from request via proxy(such as load balancer, reverce proxy).
Simply replacing HttpServletRequest#getRemoteAddr return value with HTTP Header: x-forwarded-for value. I tested it on WildFly 8.0.0.Alpha3, JBoss AS 7.1, Tomcat 7.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
RULE x-forwarded-for | |
INTERFACE javax.servlet.http.HttpServletRequest | |
METHOD getRemoteAddr | |
AT EXIT | |
IF $0.getHeader("x-forwarded-for") != null | |
DO | |
RETURN $0.getHeader("x-forwarded-for") | |
ENDRULE |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment