Forum Discussion

mburnham_59608's avatar
mburnham_59608
Icon for Nimbostratus rankNimbostratus
Aug 02, 2011

Use a variable in REWRITE_RESPONSE_DONE that was set in ACCESS_POLICY_COMPLETED



Hi all,
I would like to use a variable set in ACCESS_POLICY_COMPLETED (as below) in the REWRITE_RESPONSE_DONE event.
when ACCESS_POLICY_COMPLETED {
   set targetbaseurl "https://moo.foo.com"
   mangle the targetbaseurl into hex encoding for rewrite engine
   binary scan $targetbaseurl H* encodedbaseurl
   set mangled_url [concat [ACCESS::session data get {session.server.network.protocol}]://[ACCESS::session data get {session.server.network.name}]/f5-w-$encodedbaseurl\$\$[ACCESS::session data get {session.server.landinguri}]  ]
   log local0. "mangled URL attempt 109: $mangled_url"
   -------------------------------------------------------
}
Is this possible?
Thanks much,
Mark
  • If you set a variable it should be available to other iRules on the same VIP for the life of the TCP connection.

    Easy to test...

    when ACCESS_POLICY_COMPLETED {

    set testvar "scope-check"

    }

    when REWRITE_RESPONSE_DONE {

    if {[info exists testvar]} {

    log "testvar=$testvar"

    }

    }

    Check /var/log/ltm for the log entry.

    If that doesnt work you could store information using session or tables which is global to the box. See the table command.

  • I didn't realize the "mangled URL" was static. I thought it had to be created each time, so now I just set it as a global variable and use it whenever necessary.