variable in different event of Irule

I’m working on an irule i’m trying to save the XFF Header data to a variable in the Irule Event HTTP_REQUEST and use the same variable in Irule Event ACCESS_POLICY_AGENT_EVENT But i’m getting an error stating variable is not available.

Next I tried to use the XFF header directly in the APM event but when i log the Header data i’m not able to view the XFF header of the original client it get’s stiffed off and i’m seeing 127.0.0.X ip in the logs so i need help in how can i use the Original Client IP in the XFF header to perform decision on APM

Hi

Have you tried storing the xxf header as an APM variable right at the start when then policy first fires…?

when HTTP_REQUEST {
if {[HTTP::header exists X-Forwarded-For]}{
set xff [HTTP::header values X-Forwarded-For]
}
}
 
when ACCESS_SESSION_STARTED {
if {[info exists xff]}{
ACCESS::session data set session.custom.xff $xff
}
}

If the value is saved as an APM variable then you should be able to manipulate it (or take action if it is empty) further on in the APM policy

HTTP headers are available in ACCESS_SESSION_STARTED event… no need to work in multiple events.

It seems that ACCESS_POLICY_AGENT_EVENT is not linked to connection but to access policy evaluation in an asynchronous context… it doesn’t have access to connection variables…

Hi iaine,

apology for the delay i was away for 2 weeks so was not able to update you guys

it worked as expected

thanks for your prompt response and support.