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 possible?
- HamishCirrocumulusSure. 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.
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" }
- hooleylistCirrostratusAs Hamish said this is definitely possible. Here's a slightly simpler example that sends some HTML in an HTTP 200 response for requests to /respond.html:
when HTTP_REQUEST { if {[HTTP::path] eq "/respond.html" { HTTP::respond 200 content { Apology Page We are sorry, but the site you are looking for is temporarily out of service If you feel you have reached this page in error, please try again. } } }
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