Forum Discussion
Gerardo_Garcia_
Nimbostratus
Jul 09, 2008Excluding some urls for the STREAM conversion
I have the following iRule that converts http to https for external users only as defined on the internal_net
However, when the page contains calls to google.com, amazon.com, ebay.com it tries to put SSL on it.
Is there any way to include an exception list like the one that we have for the internal_net?
when HTTP_RESPONSE {
if { not ([matchclass [IP::client_addr] equals $::internal_net])}{
Enable debug logging to /var/log/ltm? 1=yes, 0=no
set debug 1
If the response content type is text, configure the default stream profile to replace http:// with https://
if {[string tolower [HTTP::header value Content-Type]] contains "text"}{
STREAM::expression @http://@https://@
STREAM::enable
}
Check if the response is a redirect (3xx)
if {[HTTP::is_redirect]}{
if {$debug}{log local0. "Original Location: [HTTP::header value Location], Updated Location: [string map {http: https:} [HTTP::header value Location]]"}
Use 'string map' to replace http: with https:
HTTP::header replace Location [string map {http: https:} [HTTP::header value Location]]
}
}
}
- hoolio
Cirrostratus
Hi Gerardo, - Gerardo_Garcia_
Nimbostratus
I guess it will be better to have the inclusion stream instead of exclusion. - Gerardo_Garcia_
Nimbostratus
This is the one that I use - Gerardo_Garcia_
Nimbostratus
This is what I got in the log file - hoolio
Cirrostratus
I would have thought you could use a stream expression with a single token. Here is a more tested example with the unnecessary backreference in the regex removed:when HTTP_RESPONSE { Disable the stream filter by default STREAM::disable Check if response type is text if {[HTTP::header value Content-Type] contains "text"}{ Match any http:// instance and replace it with nothing STREAM::expression {@http://.*?example\.com@@} Enable the stream filter for this response only STREAM::enable } } when STREAM_MATCHED { log local0. "[IP::client_addr]:[TCP::local_port]: matched: [STREAM::match], replaced with: [string map {http:// https://} [STREAM::match]]" STREAM::replace "[string map {http:// https://} [STREAM::match]]" }
- Gerardo_Garcia_
Nimbostratus
That worked great, thanks - Gerardo_Garcia_
Nimbostratus
I'm sorry it did not work. - Nicolas_Menant
Employee
Here are some link to learn more about regular expressions - Gerardo_Garcia_
Nimbostratus
This is the iRule that I have, I just changed the name of the url to the one for the company. - hoolio
Cirrostratus
The stream portion of the rule should be working fine to only rewrite the http:// references to https:// for *.example.com. The issue is likely to be there isn't any checking on 30x redirects. If you change this line:
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