Forum Discussion
Darrell_Kesti_5
Aug 27, 2008Historic F5 Account
Stream iRule
Hello. I am working on an iRule to solve a specific problem with a Sharepoint java script. Basically, I am doing SSL Client side termination on the Big-IP LTM 9.4.5 box. However, a few scripts located in the /_wpresources directory from the SharePoint servers are hard coding an http://intranet address when I need all of it to be an https://intranet address. Here is a way I think I can solve it by using a stream profile and replacing http:// with https://. The kicker is I only want to do this when I see a response from the /_wpresources directory.
Here is what I have....will this work?
when HTTP_RESPONSE {
Check if the URI contains the /_wpresources or equivalent. If it does replace http:// with https:// within the data stream.
if {[HTTP::header value uri] contains "_wpresources"}{
STREAM::expression "@http://@https://@"
STREAM::enable
}
Disable the stream filter by default. We are doing this as the steam profile is enabled within the http profile. It will be re-enabled if needed later.
STREAM::disable
}
Thanks.
- hoolio
Cirrostratus
Hello,when HTTP_REQUEST { Don't rewrite the response by default set rewrite_response 0 Check if we want to rewrite the response based on the requested URI if {[string tolower [HTTP::path]] contains "/_wpresources"}{ set rewrite_response 1 } } when HTTP_RESPONSE { Disable the stream filter by default STREAM::disable Check if we're rewriting the response if {$rewrite_response==1}{ Match any http:// instance and replace it with https:// STREAM::expression {@http://@https://@} Enable the stream filter for this response only STREAM::enable } }
- Darrell_Kesti_5Historic F5 AccountThanks Aaron,
- hoolio
Cirrostratus
If you're only rewriting based on the content-type header value, you can look for the string "text" instead of enumerating every content-type you don't want to rewrite to https. This means you don't have to include image types and every other binary filetype. The msword, excel and powerpoint content-types should typically be "application/msword", etc (Click here). They should not contain the word text.when HTTP_RESPONSE { Disable the stream filter by default STREAM::disable Check if we're rewriting the response switch -glob [string tolower [HTTP::header value Content-Type]] { "*msword*" - "*vnd.excel*" - "*ms-powerpoint*" { Response isn't one we want to rewrite. Do nothing. log local0. "[IP::client_addr]:[TCP::client_port]: Not modifying response for response type [HTTP::header value Content-Type]" } default { For all other responses, match any http:// instance and replace it with https:// in the response payload STREAM::expression {@http://@https://@} Enable the stream filter for this response only STREAM::enable log local0. "[IP::client_addr]:[TCP::client_port]: Modifying response for response type [HTTP::header value Content-Type]" } } }
when HTTP_RESPONSE { Disable the stream filter by default STREAM::disable Check if we're rewriting the response if {[HTTP::header value Content-Type] contains "text"}{ Match any http:// instance and replace it with https:// STREAM::expression {@http://@https://@} Enable the stream filter for this response only STREAM::enable log local0. "[IP::client_addr]:[TCP::client_port]: Modifying response for response type [HTTP::header value Content-Type]" } } }
- Darrell_Kesti_5Historic F5 AccountThanks for the information. I am getting very close. The word documents and other files are now properly being handled and the content is being written to https://. However, there is one concern. I just found out that the sharepoint portal also uses some external links to other sites that are called from the client machine, so we are replacing the http:// links in these sites to be https://, and it is breaking some of the reporting metrics because of this. Here is a variant of the rule I created. I only want to change the http content to https if it is part of the intranet.mydomain.com site, which is what the VIP is front ending, and not for any other links that may stream by in the page content.
- hoolio
Cirrostratus
That looks fine. You don't need to include anything for the paths if you want to just replace all instances of http://intranet.mydomain.com with https://intranet.mydomain.com. irrespective of the path. - Darrell_Kesti_5Historic F5 AccountThanks Aaron. This new rule did the trick...looks like we are good. Thanks for the help.
- hoolio
Cirrostratus
Good to hear.
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