Forum Discussion
Irule
HI, i am new to irules . i am trying below irule
when LOAD_BALANCER_COOKIE_NAME = "SOURCE_IP";
public static String getRemoteIPAddress(HttpServletRequest request) { Cookie cookie = getCookie(request, LOAD_BALANCER_COOKIE_NAME); if (cookie == null) { return request.getRemoteAddr(); }
if (cookie.getValue() == null || StringUtils.isEmpty(cookie.getValue())) { return request.getRemoteAddr(); } return cookie.getValue(); }
i am seeing below errror
01070151:3: Rule [/Common/test] error: /Common/test:1: error: [wrong args][when LOAD_BALANCER_COOKIE_NAME = "SOURCE_IP";] /Common/test:3: error: [undefined procedure: public][public static String getRemoteIPAddress(HttpServletRequest request) { Cookie cookie = getCookie(request, LOAD_BALANCER_COOKIE_NAME); if (cookie == null) { return request.getRemoteAddr(); }
if (cookie.getValue() == null || StringUtils.isEmpty(cookie.getValue())) { return request.getRemoteAddr(); } return cookie.getValue(); }]
Can some one help me correcting the irule.
4 Replies
Hi Vvskaladhar,
an iRule has to be written in TCL (Tool Command Language), but the code you're using is written in Java.
To help you further you may want to explain us, which task you have to perform with this rule?
Cheers, Kai
Hi Vvskaladhar,
take a look to the guide below. It covers the configuration steps to enable this functionality either on your HTTP profile (recommended) or by using iRules (less performant).
sol4816: Using the X-Forwarded-For HTTP header to preserve the original client IP address for traffic translated by a SNAT
https://support.f5.com/kb/en-us/solutions/public/4000/800/sol4816.html
Cheers, Kai
- vvskaladhar_488
Nimbostratus
thanks lot for help and sorry for the late reply.
it solved my problem .
- You're welcome... :-)
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com