Forum Discussion
Fiko_29923
Jun 17, 2011Nimbostratus
insert javascript to html pages using irules
Hi, I want to ask is it possible to insert javascript to existing web pages?
e.g. I have web pages which already running and use it as pool member for load balancing. Using iRules, I want to check for incoming HTTP request thus when request comes will fire irules and insert javascript into the web page.
Anyone can help me with this problem?
- hoolioCirrostratusHi Fiko,
when HTTP_REQUEST { Disable stream filter by default STREAM::disable Don't allow response data to be chunked if { [HTTP::version] eq "1.1" } { Force downgrade to HTTP 1.0, but still allow keep-alive connections. Since HTTP 1.1 is keep-alive by default, and 1.0 isn't, we need make sure the headers reflect the keep-alive status. if { [HTTP::header is_keepalive] } { HTTP::header replace "Connection" "Keep-Alive" } } } when HTTP_RESPONSE { if {[HTTP::header Content-Type] starts_with "text/"} { Remove the spaces before and after head in < head > STREAM::expression {@< head >@@} STREAM::enable } } when STREAM_MATCHED { Once we've hit one match, disable the stream filter for the rest of the response STREAM::disable } Aaron
- hoolioCirrostratusSee the attached text file for an uncorrupted version.
- Fiko_29923Nimbostratusmany thanks Aaron, I'll test it out
- Fiko_29923NimbostratusHi, I have some concern regarding connection which enter the BIG-IP and trigger the irule
- Peter_72728NimbostratusFrom what I understand, that shouldn't be a problem. These devices are designed to handle many concurrent requests. The variable will be set correctly since it's scope is based on the connection.
- hoolioCirrostratusAs Peter said if you use a local variable you won't have to worry about trampling of variable values between connections. However, you're using $::url which is a global variable. This will get overwritten each time it is set for each connection. You should change $::url to $url to avoid this issue.
- Peter_72728NimbostratusGood catch, Aaron. I missed that!
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