Forum Discussion
Moreli_Alama_63
Nimbostratus
May 14, 2007irule for 503 response to client
hi
i have a http VIP and am wanting to create a 503 response to the client
when the VIP is unavailable. how does one achieve this? i can see you can assign
monitors to pools but ...
hoolio
Cirrostratus
Apr 02, 2009In a simple test on 9.4.6, I was able to send a 503 with content using HTTP::respond. I've also used a 503 in 9.2.4 and 9.3.1. I'm not sure if it was a bug in an older version or a configuration issue. But if you're seeing a problem with sending a 503, can you post the iRule you're testing and the results of the tests?
when HTTP_REQUEST {
set data {Some data to send to the client. If you want to use variables in here, replace the curly braces with quotes.}
Look for a URI starting with a forward slash and then 3 digits (the first digit being 1-5)
If one is found, set it as the HTTP response code. Else, send back an HTTP 200
if {[string match {/[1-5][0-9][0-9]*} [HTTP::path]]}{
Send the response with the status code from the requested path and data
HTTP::respond [string range [HTTP::path] 1 3] content $data "a_header_name" "a_header_value"
log local0. "Sending [string range [HTTP::path] 1 3] response with $data"
} else {
Send a 200 response with data
HTTP::respond 200 content $data "a_header_name" "a_header_value"
log local0. "Sending default 200 response with $data"
}
}
Example curl request:
curl -v 10.42.2.102/503
* About to connect() to 10.42.2.102 port 80
* Trying 10.42.2.102... connected
* Connected to 10.42.2.102 (10.42.2.102) port 80
> GET /503 HTTP/1.1
> User-Agent: curl/7.15.3 (i686-redhat-linux-gnu) libcurl/7.15.3 OpenSSL/0.9.7l zlib/1.1.4
> Host: 10.42.2.102
> Accept: */*
>
< HTTP/1.0 503 Service Unavailable
< a_header_name: a_header_value
* HTTP/1.0 connection set to keep alive!
< Connection: Keep-Alive
< Content-Length: 109
Connection 0 to host 10.42.2.102 left intact
* Closing connection 0
Some data to send to the client. If you want to use variables in here, replace the curly braces with quotes.
Aaron
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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