I am still very very new at iRules, so thank you in advance for any help you can give me.
I am attemping to put an iRule in place to force the usage of our content distribution network. We have an iRule that was developed for us that searches for a specific url (www.site.com) and as long as the http path ends with jpg, jpeg, png, gif, (used in a datagroup) etc it will redirect to cdn.site.com.
I can see in the logs that the rule seems to be firing however I do not know enough about the browsers available on the market to know if all browsers will follow a redirect from an image URL.
Is it possible to modify the html output? or would that be too exaustive on the device itself?
I am not sure I can post the iRule code as it was developed during the implementation of the F5 itself, so I am not sure about licensing, etc.
1) Presently, you are redirecting based on request URI yes?
Yes - if the request URI ends with an image extension, it will redirect
2) You’d rather rewrite responses to avoid the redirect yes?
Yes - unless I can find some confirmation all browsers (including mobile browsers) will follow redirect requests for images.. I have not been able to confirm nor deny this
Is it possible to modify the html output? or would that be too exaustive on the device itself?i think it is possible. i do not know whether it is too exhaustive on the device or not. anyway, the following code is just a simple example.
e.g.
[root@ve10:Active] config b virtual bar list
virtual bar {
snat automap
pool foo
destination 172.28.19.79:80
ip protocol 6
rules myrule
profiles {
myhttp {}
stream {}
tcp {}
}
}
[root@ve10:Active] config b pool foo list
pool foo {
members 200.200.200.101:80 {}
}
[root@ve10:Active] config b profile myhttp list
profile http myhttp {
defaults from http
header erase "Accept-Encoding"
}
original content
[root@ve10:Active] config curl -i http://200.200.200.101
HTTP/1.1 200 OK
Date: Tue, 27 Nov 2012 15:47:46 GMT
Server: Apache/2.2.3 (CentOS)
Last-Modified: Sat, 27 Oct 2012 03:22:35 GMT
ETag: "4183f3-59-f28f94c0"
Accept-Ranges: bytes
Content-Length: 89
Content-Type: text/html; charset=UTF-8
...snipped...
This is 101 host.
...snipped...
modified content
[root@ve10:Active] config curl -i http://172.28.19.79
HTTP/1.1 200 OK
Date: Tue, 27 Nov 2012 15:47:54 GMT
Server: Apache/2.2.3 (CentOS)
Last-Modified: Sat, 27 Oct 2012 03:22:35 GMT
ETag: "4183f3-59-f28f94c0"
Accept-Ranges: bytes
Content-Type: text/html; charset=UTF-8
Transfer-Encoding: chunked
...snipped...
This is 101 host.
...snipped...
The forum code munged the stream expression. It should be:
STREAM::expression {@".*?\.gif@@}
Also make sure that the config loads after updating the iRule as the unbalanced double quote might throw off the parser.
Steve, you remove the Accept-Encoding header on requests to the pool to prevent the server from sending compressed response content. Compressed content isn’t decompressed by TMM before applying the stream filter.