Forum Discussion
Rogerio_Teixeir
Nimbostratus
Apr 10, 2008Replace host based on file type
Hi,
Im trying to creat a irule that replace de hostname (FQDN) based on what fily type is request...
Like this:
Based on class images (jpg,gif,png...etc)
client...
hoolio
Cirrostratus
Apr 17, 2008Hi Rogerio,
Something like this?
when HTTP_RESPONSE {
Check if the Content-Type header value matches our criteria
if {[HTTP::header value Content-Type] contains "somestring"}{
log local0. "[IP::client_addr]:[TCP::client_port]: Matched the Content-Type check for [HTTP::header value Content-Type]"
Initialize a variable to save the cookies
set cookie_string ""
Loop through each Set-Cookie header. Save the value to a string, and remove the header.
while {[HTTP::header exists Set-Cookie]}{
Append the current Set-Cookie value to the cookie string
append cookie_string [HTTP::header value Set-Cookie]\;
log local0. "[IP::client_addr]:[TCP::client_port]: Current \$cookie_string: $cookie_string"
Delete the current Set-Cookie header
HTTP::header remove Set-Cookie
}
Include the cookies in the 302 response if there were any
if {[string length $cookie_string]}{
log local0. "[IP::client_addr]:[TCP::client_port]: Redirecting with cookies to: http://example.com Set-Cookie $cookie_string"
Send the 302 redirect response with the cookies
HTTP::respond 302 Location "http://example.com" Set-Cookie $cookie_string
} else {
log local0. "[IP::client_addr]:[TCP::client_port]: Redirecting without cookies to: http://example.com"
Send the 302 redirect response without the Set-Cookie header as there weren't any cookies
HTTP::respond 302 Location "http://example.com"
}
}
}I didn't test it, but it passed an iRuler syntax check. If you run into problems with it, check the /var/log/ltm log file for debug output. Make sure to comment out or remove the logging before using the iRule in production.
Aaron
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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
