Forum Discussion
kawiman_43144
Jul 25, 2012Nimbostratus
Respond to Get request on it's own?
I am evaluating load balancers and one "nice to have" would be to have the load balancer itself respond to an http get request with a specified string to any client that sends the get. Is this possibl...
Hamish
Aug 01, 2012Cirrocumulus
Sure. Use an iRule. Just implement the HTTP_REQUEST method, check the URI sent, if it's the specified string, respond to it from the iRule, if not just continue to forward the request as normal.
e.g. (Sorry, quick cut & paste from another iRUle, but the gist is there. It looks up the URI in a data group and responds with the content (value) if it exists).
when HTTP_REQUEST {
Retrieve the login form from a base64 encoded external class file
Pull just the filename from the path... So we need to get rid of the leading '/'.
set lf_file [substr [HTTP::path] 1]
if { $lf_debugFlag >=2 } {
HSL::send $lfs001hsl "${lfs001HSLPrefix}:: Checking for $lf_file in DG $lf_contentClass"
}
v9 set lf_ResponseData [findclass $lf_file $::loginForm_test " "]
set lf_ResponseData [class search -value $lf_contentClass equals "$lf_file"]
if { $lf_ResponseData ne "" } {
There's 2 fields...
set lf_MimeType [getfield $lf_ResponseData " " 1]
set lf_Content [b64decode [getfield $lf_ResponseData " " 2]]
if { $lf_debugFlag >=2 } {
HSL::send $lfs001hsl "${lfs001HSLPrefix}:: Serving $lf_MimeType for $lf_file"
}
Perform the substitutions...
if { $lf_MimeType equals "text/html" } {
regsub -all {} $lf_Content "[IP::client_addr]" lf_Content
}
HTTP::respond 200 content $lf_Content "Content-Type" "$lf_MimeType"
}
H
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