Forum Discussion
mahern_56900
Nimbostratus
Nov 11, 2009Add exception to response rewrite
Hi,
We are using the following irule to rewrite the headers and body of an old application:
when HTTP_REQUEST {
initialize a var
set check_response 0 ...
hoolio
Cirrostratus
Nov 12, 2009If you're able to not rewrite any input parameter, it should be a little easier. I haven't this fully, but the regex seems to work in some quick checks. If you see any issues with this, can you reply with the log output from /var/log/ltm?
Thanks,
Aaron
when HTTP_REQUEST {
Inicializamos una variable para comprobar si tenemos que reescribir las cabeceras/contenido
set check_response 0
Comprobamos si el path es el que buscamos
if {[HTTP::uri] starts_with "/nilo"} {
Ponemos la variable a 1 para actuar en las cabeceras/contenido
set check_response 1
}
}
when HTTP_RESPONSE {
Comprobamos que no escribimos una cabecera que no debemos
if {$check_response}{
Comprobamos si la cookie JSESSIONID existe
if {[HTTP::cookie exists JSESSIONID]}{
Establecemos el path de la cookie a /sdr/nilo
HTTP::cookie path JSESSIONID "/sdr/nilo"
}
Comprobamos si la peticion es text
if {[HTTP::header value Content-Type] contains "text"} {
Establecemos el texto a reemplazar y activamos el filtro stream
STREAM::expression {@/nilo/@/sdr/nilo/@}
STREAM::enable
} else {
En las respuestas que no son text, desactivamos el filtro stream
STREAM::disable
}
}
}
when STREAM_MATCHED {
log local0. "[IP::client_addr]:[TCP::local_port]: Matched: [STREAM::match]"
Only rewrite /nilo/ to /sdr/nilo/ if the matched string is not an input parameter
Check if matched string does not start with if {not ([string tolower [STREAM::match]] starts_with "
Replace /nilo/ with /sdr/nilo/ in the matched string and use that for the replacement
STREAM::replace "[string map {/nilo/ /sdr/nilo/} [STREAM::match]]"
log local0. "[IP::client_addr]:[TCP::client_port]: Matched: [STREAM::match], replaced with: [string map {/nilo/ /sdr/nilo/} [STREAM::match]]"
} else {
Prevent replacement from being performed by calling STREAM::replace with no value
STREAM::replace
log local0. "[IP::client_addr]:[TCP::client_port]: Matched: [STREAM::match], but did not perform replacement"
}
}
Recent Discussions
Related Content
DevCentral Quicklinks
* 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
Discover DevCentral Connects