I have an open source application, similar to Sharepoint, that build URL’s on the fly. I have an SSL cert on the F5 to make it https://, but the server is clear, http://. For some reason, one of the links the application builds inserts the http:// URL inside the https:// URL. Here is an example:
I’d try to fix the app first. If that’s not an option, you can rewrite the response headers and/or content with an iRule. To rewrite the header (typically the Location header in a redirect) you can use the following rule:
when HTTP_RESPONSE {
Check if response is a redirect
if {[HTTP::is_redirect]}{
Replace http//mysite.com with nothing if it's present in the Location header value
HTTP::header replace Location [string map {http//mysite.com ""} [HTTP::header value Location]]
}
}
If you need to perform the replacement in the response content, you can add the stock stream profile and then use an iRule to configure the search/replace strings:
when HTTP_RESPONSE {
Check if response is a redirect
if {[HTTP::is_redirect]}{
Replace http//mysite.com with nothing if it's present in the Location header value
HTTP::header replace Location [string map [list http//mysite.com ""] [HTTP::header value Location]]
}
Check if response content type is text
if {[HTTP::header value "Content-Type"] starts_with "text"}{
Set the stream expression
STREAM::expression "@http//mysite.com@@"
Enable the stream filter
STREAM::enable
} else {
Response wasn't text, so disable the stream filter
STREAM::disable
}
}
If it’s a typo that http//mysite.com is missing the :, you can use http://mysite.comhttp://mysite.com as the search string and replace it with http://mysite.com. You’d then want to use the following string map and STREAM::expression replacement strings:
I tried your suggestions, but they did not work. I think because it is not really a HTTP header that I need to change. If I look at the whole stream, I see that it is the actual GET request that I need to change:
I tried your suggestions, but they did not work. I think because it is not really a HTTP header that I need to change. If I look at the whole stream, I see that it is the actual GET request that I need to change:
Can you use a browser plugin like Fiddler for IE or HttpFox for FF to see what the server is actually sending back in response headers and/or the body?
You can rewrite the URI, but it might be cleaner to figure out why the response rewriting isn’t working. The find/replace strings might be wrong. Or the server might be compressing the response content. LTM doesn’t decompress the response content when applying the stream filter so it wouldn’t be rewritten.
If you do want to rewrite the URI, you can use the same string map command with HTTP::uri:
when HTTP_REQUEST {
Check if URI starts with //mysite.com
if {[HTTP::path] starts_with "//mysite.com"
Replace //mysite.com with / in the path
HTTP::path [string map {//mysite.com /} [HTTP::path]]
}
}