If a web page with following Source URL is browsed , then a part of URI (highlighted in bold) should be converted to “en” (which is English language ) and output should be Masked URL as shown below .
I am unable to update my original post. Here is an updated version.
If you simply want to mask URL’s then apply a STREAM profile with the following iRule.
when HTTP_REQUEST {
log local0. "..in HTTP_REQUEST"
no replacement for requests
STREAM::disable
disable compression server side
HTTP::header remove "Accept-Encoding"
}
when HTTP_RESPONSE {
log local0. "...in HTTP_RESPONSE"
only replace text content
if {!([HTTP::header value Content-Type] contains "text")}{ return}
set search ""
foreach pair [class get myclass] {
set search "$search@[lindex $pair 0]@[lindex $pair 1]@"
}
log local0. "String replace=$search"
STREAM::expression $search
STREAM::enable
}
Then create a string data class myclass as follows…
Name Value
/secureapp/connect/report_en/REP /en
/peter /pan
Thanks for the response !! Though i am ok working with irules , however the above example is little tough for me to understand . Could you please explain me the logic behind the same . Also request to consider the below URLs in your example
The STREAM commands allow search and replace of data passing to and from the webserver. In this case I have enabled it only on the response coming back from the webserver… (STREAM::enable/disable). The stream expression is a sequence of search and replace pairs in the format @search@replace@. The foreach loop builds a stream expression from name and value pairs in the class myclass. We also turn off compression as most websites send data compressed although the user is never aware of this but we cannot process compressed data. Removing the Accept-Encoding header means the website will not compress the reply.
Thanks for the detailed explanation !! Yes , the previous one is correct . I want any webpage with http://www.myweb.com/secureapp/connect/report\_en/REP/XYZ to be displayed as http://www.myweb.com/en/XYZ in the users’ browser . Also please note that whenever the URI is triggered in any other part of the web page (any other link present inside the webpage containing this URI ) , then also it should replace /secureapp/connect/report_en/REP/ with /en . I believe that iRule configuration you mentioned above would do that as well.
Also , do i need to simply apply this iRule to the Virtual Server OR apart from applying this iRule to VS , i have to create a separate Stream profile as well and then apply to the VS . I have not worked on Stream profile before and would like to know what needs to be filled in Source and Target part ?
The stream profile by default works in both directions. Only through iRules can you control when it is applied. I you have seen in the first example I do this.
You apply the iRule to the resources section of your virtual server and you must add a stream profile to have access to the STREAM iRule commands. You can use the system default stream profile and you do not need to fill out any fields in the profile itself. The STREAM::expression command in the iRule does that for you. You add the profile in the advanced view of your virtual server properties. Note the iRule will not apply unless there is a stream profile attached.
In the data class I specified name and value. Name is your Search and and value is what it will be replaced with.
Thanks a lot !! I will add “system default stream profile” to VS and will add the said irule for the VS . Is there any way to test out via F5 CLI if it is working ?
If any of the above posts have provided a solution to your issue, please indicate so by clicking the tick to the left of them. This gives feedback and recognition to the volunteers who responded to your issue.
I just setup a webpage with the strings on it and called that webpage through a virtual with the iRule attached. There is no way to trigger logging event when STREAM actually replaces something.
One more request , i would like to get the above iRule triggered only when end user browses www.myweb.com . The reason is that there are multiple websites hosted on backend physical servers (residing behind F5) ; however those websites are represented by F5 Virtual IP address.
when HTTP_REQUEST {
log local0. "..in HTTP_REQUEST"
set host [string tolower [HTTP::host]]
if {$host ne "www.myweb.com"} { return }
no replacement for requests
STREAM::disable
disable compression server side
HTTP::header remove "Accept-Encoding"
}
when HTTP_RESPONSE {
log local0. "...in HTTP_RESPONSE"
if {$host ne "www.myweb.com"} { return }
only replace text content
if {!([HTTP::header value Content-Type] contains "text")}{ return}
set search ""
foreach pair [class get myclass] {
set search "$search@[lindex $pair 0]@[lindex $pair 1]@"
}
log local0. "String replace=$search"
STREAM::expression $search
STREAM::enable
}
The above is not working . I configured the above iRule and assigned it to VS along with enabling stream. I have built a dummy URL on the backened webserver and when i browse this URL , the URL in the address bar remains unchanged ]
The URL recommended by you contains the solutions which are difficult to understand and which doesnt mention the shortening of URIs . Is there any other way of doing it ?
The above is not working . I configured the above iRule and assigned it to VS along with enabling stream. I have built a dummy URL on the backened webserver and when i browse this URL , the URL in the address bar remains unchanged
i understand Kevin’s irule does replace string (e.g. uri) in response from server. it does not affect if you browse the uri directly.