APM already active session error when changing landing URI
for a customer we setup APM with several landing URI to take different routes through the access policy. but of course the users sometimes make the mistake to enter https://apm.domain.com instead of using the correct landing URI, https://apm.domain.com/uri1. they can't correct this within the same session because then they get the "Access policy evaluation is already in progress for your current session." error screen. only workaround is closing the browser, which is annoying.
i tried to solve this on that error screen, but that doesn't appear possible (in 11.2.1 and 11.4.0). so i created this iRule to solve it, perhaps it comes in handy for others.
this iRule works in 11.4:
when HTTP_REQUEST {
set sid [ACCESS::session sid]
switch -glob [HTTP::uri] {
"/uri1*" -
"/uri2*" {
if {$sid != ""} {
log local0. "request for /uri* and active session, remove session and redirect"
ACCESS::session remove
HTTP::redirect [HTTP::uri]
TCP::close
}
}
default {
log local0. "default"
do nothing
}
}
}
this iRule works in 11.2.1, i needed to add the after 5000 and HTTP::collect as APM doesnt quickly enough kill the session:
when HTTP_REQUEST {
set sid [ACCESS::session sid]
switch -glob [HTTP::uri] {
"/uri1*" -
"/uri2*" {
if {$sid != ""} {
log local0. "request for /uri* and active session, remove session and redirect"
ACCESS::session remove
HTTP::collect
after 5000 {
HTTP::redirect [HTTP::uri]
TCP::close
}
}
}
default {
log local0. "default"
do nothing
}
}
}