Forum Discussion
Adrian_Turcu_10
Nimbostratus
Oct 30, 2007Help With HTTP_RESPONSE
Hello Gurus
Could someone help me with a quick rule to replace a header in the response back to the client, please?
My problem is like follows: we have a poxi app (not proxy) and t...
hoolio
Cirrostratus
Oct 31, 2007That's good to hear. Here is a version without the logging and intermediate variables:
when HTTP_REQUEST {
Save host (without the port if it's specified)
set shost [getfield [HTTP::host] ":" 1]
}
when HTTP_RESPONSE {
Check if response is a redirect (HTTP status of 3xx)
if { [HTTP::status] starts_with "3" } {
Check if the port the request was made on was 443
if {[clientside {TCP::local_port}] == 443}{
Request was made to an SSL port, so replace 127.0.0.1 with the Host header value from the request
and replace http:// with https:// in the Location header value
HTTP::header replace Location [string map "http:// https:// 127.0.0.1 $shost" [HTTP::header value Location]]
} else {
Request was made to an HTTP port, so just replace 127.0.0.1 with the Host header value from the request
HTTP::header replace Location [string map "127.0.0.1 $shost" [HTTP::header value Location]]
}
}
}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