Forum Discussion
karthik_sriniva
Nimbostratus
Oct 28, 2005Stream Profile: Replace String
Hi Guys,
I had configured a virtual server for our secure site. The content is legacy code and it has hardcoded urls for http. Currently I am using stream profile to replace all the http:// to https://
The code also contains javascript which has hardcoded http%3A%2F%2F, which should be replaced with https%3A%2F%2F. Is there a way to make stream profile perform this replacement as well.
Thanks for your help as always
Srini
23 Replies
- Colin_Walker_12Historic F5 AccountAre you having trouble adding multiple replace strings, or getting the second replace string to work?
You should be able to add multiple search and replace strings in a single stream profile, as of v9.2.
-Colin - karthik_sriniva
Nimbostratus
HI Colin,
Thanks for the information. I do not know how to add the second string. Is there an example I can look at.
Thanks. - Colin_Walker_12Historic F5 AccountHere's a doc about managing profiles in 9.2. :
Click here
I'll see if I can dig up anything more specific, or maybe write up some brief instructions, and get back to you with what I find later today.
-Colin - karthik_sriniva
Nimbostratus
Thanks Colin. This is what I had configured now
profile stream httpR_stream {
defaults from stream
source "http://"
target "https://"
}
so how do I add another search and replace for "prodSrv" to "prod2Srv"
Thanks,
Srini - karthik_sriniva
Nimbostratus
HI Guys,
Is it possible to use regular expression for search string in stream profile.
Also if someone could post an example on how to add a second search and replace string, would be of much help - bl0ndie_127134Historic F5 AccountYes but only on 9.2 and later. There are several enhancements worth noting here.
. We added unlimited search and replace target pairs that can be expresses as sed replacement expressions.
. We also added a new event called STREAM_REPLACED where you can query for the matching string and also override the replacement if you desire to do so. - karthik_sriniva
Nimbostratus
Thanks for the information. We are using 9.2. Can you post an example to search and replace two different strings. - bl0ndie_127134Historic F5 AccountExpression syntax :
The expression syntax should be fairly familiar to most UNIX users, as it’s a 'SED' like replacement pairs of source and targets shown below. expression := /// // //. If the *last* target expression is empty, then a match event will be fired but there will be no replacement performed. The only caveat is that an empty target *must* be specified in the *last* expression. When the filter matches one of the expressions say for example ‘source1’, the matching content will be replaced by ‘target1’.
Configuration :
The new stream behavior can be enabled by applying the new expression to the ‘target’ stream profile and leaving the ‘source’ profile *empty*. If both ‘source’ and ‘target’ values are set, the stream filter will default to the original behavior of looking for string literals.
STREAM_MATCHED - Fired when a when a stream expression matches. This event can be used to skip or change the replacement target.
STREAM::disable - Disables any further processing on the stream filter for this connection. This can be called from HTTP events.
STREAM::enable - Enables the stream filter. This can be called from HTTP events.
STREAM::expression - Replace the stream expression specified in the profile with this value. The syntax is identical to the profile syntax. NOTE that this change affects just this connection and is sticky for the duration of the connection. Use this rule wisely!
STREAM::match - Returns the matching characters.
STREAM::replace [] - Can be used to change the target replacement string specified in the profile. This call is not sticky and will be applied only once during the current match. If the ‘target’ expression is missing, the replacement will be skipped. - karthik_sriniva
Nimbostratus
Appreciate your quick response. Following your post, this is what I have and it's not working
expression := /http://testbigip/https://testbigip /http.3A.2F.2Ftestbigip/https.3A.2F.2Ftestbigip /testbigip/
Could you take a minute and point out what's wrong
Thanx
Srini - karthik_sriniva
Nimbostratus
Sorry, my previous posting is confusing.
I want to replace all content which is like
http://testbigip to https://testbigip and
http%3A%2F%2Ftestbigip to https%3A%%2F%2Ftestbigip
i tried this expression and it;s not working
expression := /http(*)test/https&testbigip/ /dummy/
Any help would be appreciated
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
