thanks hoolio, your suggestions are pretty valuable, now the rule is almost working as expected, the only problem is that the decrypted variable is always returning empty, there is no error message or something like that, it just return empty when I decrypt, decode e b64decode.
when RULE_INIT {
set ::prefix "enc_"
set ::sessao "JSESSIONID"
}
when HTTP_REQUEST {
if { ([HTTP::uri] starts_with "/$::prefix") and ([HTTP::cookie exists $::sessao]) }{
set decrypted [AES::decrypt [HTTP::cookie value $::sessao] [b64decode [URI::decode [string range [HTTP::uri] [expr {[string length $::prefix] + 1} ] end]]]]
log local0. "uri [HTTP::uri] decrypted: $decrypted"
HTTP::uri $decrypted
set uri $decrypted
} else { set uri [HTTP::uri] }
if { [string tolower $uri] contains "abc" } {
pool pool_abc
} elseif { [string tolower $uri] contains "def" } {
pool pool_def
}
}
when HTTP_RESPONSE {
if { [HTTP::header value Content-Type] starts_with "text" } {
set encrypted "/$::prefix[URI::encode [b64encode [AES::encrypt [HTTP::cookie value $::sessao] $uri]]]"
log local0. "uri: $uri encrypted: $encrypted"
HTTP::header replace Location "$encrypted"
}
}