Forum Discussion
GavinW_29074
Feb 07, 2012Nimbostratus
HTTP_RESPONSE not firing
Hi there,
I'm using the ProxyPass v10 iRule to perform some path rewriting on some of our VIP's...
However we seem to be getting some sporadic issues whereby the HTTP_RESPONSE ev...
GavinW_29074
Feb 15, 2012Nimbostratus
Aaron
Yes, I've got another rule that's handling all the error variables... Code is:
when RULE_INIT {
set static::RespondDebug 1
Static iFile content
set static::unavailable_page [ifile get unavailable_page_html]
set static::offline_page [ifile get offline_page_html]
set static::secure_failure_page [ifile get secure_connection_failure_html]
set static::act_logo [ifile get act_logo_png]
}
when CLIENT_ACCEPTED priority 1 {
if {$static::RespondDebug > 0} { log local0. "Processing CLIENT_ACCEPTED at priority 1" }
Set-up base variables.
set pool_error 0
set maintenance_mode 0
set ssl_error 0
set failure_result ""
set response_error 0
if {$static::RespondDebug > 0} { log local0. "Variables set:- \$pool_error = $pool_error, \$maintenance_mode = $maintenance_mode, \$ssl_error = $ssl_error, \$failure_result = '$failure_result', \$response_error = $response_error" }
}
when HTTP_REQUEST priority 20 {
Variable set-up.
set vname "[findstr [string range [virtual name] [string last / [virtual name]] end] "/" 1 "_"]"
set host "[HTTP::host]"
set uri "[HTTP::uri]"
set errors_prefix "VS=$vname, Host=$host, URI=$uri"
if {$static::RespondDebug > 0} { log local0. "$errors_prefix: Processing HTTP_REQUEST at Priority 20..." }
if {$static::RespondDebug > 0} { log local0. "$errors_prefix: \$maintenance_mode = $maintenance_mode, \$ssl_error = $ssl_error, \$failure_result = '$failure_result'" }
Catch ACT Logo and return.
if { [HTTP::uri] ends_with "logo-act.png" } {
if {$static::RespondDebug > 0} { log local0. "$errors_prefix: Returning ACT Logo..." }
HTTP::respond 200 content $static::act_logo "Content-Type" "image/png" "Connection" "Close" "Cache-Control" "no-cache"
TCP::close
event disable
return
}
Catch Scheme Logo(s) and return.
if { [HTTP::uri] ends_with "_logo.jpg" } {
if {$static::RespondDebug > 0} { log local0. "$errors_prefix: Returning Scheme Specific Logo's..." }
Set-up iFile name.
set ifile_name "scheme_error_logo_"
set scheme_ref [class lookup $vname Scheme_Error_VIP_Names]
append ifile_name $scheme_ref
append ifile_name "_"
Get Logo name from URI
set logo_name [string trim [getfield [HTTP::uri] "/" 3] "_logo.jpg"]
append ifile_name $logo_name
if {$static::RespondDebug > 0} { log local0. "$errors_prefix: Logo name is: '$ifile_name'" }
Get iFile content
catch {ifile get $ifile_name} response_content
if {$static::RespondDebug > 0} { log local0. "$errors_prefix: Response content is: '$response_content'" }
if { $response_content == "" } {
log local0.info "$errors_prefix: Logo not found..."
HTTP::respond 200 "Connection" "Close" "Cache-Control" "no-cache"
} else {
if {$static::RespondDebug > 0} { log local0. "$errors_prefix: Returning logo..." }
HTTP::respond 200 content $response_content "Content-Type" "image/jpg" "Connection" "Close" "Cache-Control" "no-cache"
}
TCP::close
event disable
return
}
Handle maintenance mode.
if {$maintenance_mode} {
if {$static::RespondDebug > 0} { log local0. "$errors_prefix: Returning Maintenance page html..." }
switch -glob [HTTP::method] {
POST {
if {$static::RespondDebug > 0} { log local0. "$errors_prefix: POST Method - Returning Code 503" }
HTTP::respond 503
event disable
return
}
GET {
Scheme specific error page handling.
if {$static::RespondDebug > 0} { log local0. "$errors_prefix: GET Method - Checking for Custom error page" }
if { [class match $vname eq Scheme_Error_VIP_Names] } {
if {$static::RespondDebug > 0} { log local0. "$errors_prefix: $vname found in Scheme_Error_VIP_Names" }
set scheme_ref [class lookup $vname Scheme_Error_VIP_Names]
if {$static::RespondDebug > 0} { log local0. "$errors_prefix: Scheme reference is: '$scheme_ref'" }
set response_html [ifile get scheme_error_html_$scheme_ref]
HTTP::respond 200 content $response_html "Content-Type" "text/html" "Cache-Control" "no-cache"
} else {
if {$static::RespondDebug > 0} { log local0. "$errors_prefix: $vname not found in Scheme_Error_VIP_Names" }
HTTP::respond 200 content $static::offline_page "Content-Type" "text/html" "Cache-Control" "no-cache"
}
event disable
return
}
}
TCP::close
}
Handle SSL error
if {$ssl_error} {
if {$static::RespondDebug > 0} { log local0. "Returning SSL Error page html..." }
HTTP::respond 403 content [subst $static::secure_failure_page] "Content-Type" "text/html" "Connection" "Close"
TCP::close
event disable
return
}
}
when HTTP_REQUEST priority 750 {
if {$static::RespondDebug > 0} { log local0. "Processing HTTP_REQUEST at Priority 750..." }
if {$static::RespondDebug > 0} { log local0. "\$pool_error = $pool_error" }
Handle error page.
if {$pool_error} {
switch -glob [HTTP::method] {
POST {
if {$static::RespondDebug > 0} { log local0. "POST Method - Returning Code 503" }
HTTP::respond 503
event disable
return
}
GET {
Scheme specific error page handling.
if {$static::RespondDebug > 0} { log local0. "$errors_prefix: GET Method - Checking for Custom error page" }
if { [class match $vname eq Scheme_Error_VIP_Names] } {
if {$static::RespondDebug > 0} { log local0. "$errors_prefix: $vname found in Scheme_Error_VIP_Names" }
set scheme_ref [class lookup $vname Scheme_Error_VIP_Names]
if {$static::RespondDebug > 0} { log local0. "$errors_prefix: Scheme reference is: '$scheme_ref'" }
set response_html [ifile get scheme_error_html_$scheme_ref]
HTTP::respond 200 content $response_html "Content-Type" "text/html" "Cache-Control" "no-cache"
} else {
if {$static::RespondDebug > 0} { log local0. "$errors_prefix: $vname not found in Scheme_Error_VIP_Names" }
HTTP::respond 200 content $static::unavailable_page "Content-Type" "text/html" "Cache-Control" "no-cache"
}
event disable
return
}
}
TCP::close
}
if {$static::RespondDebug > 0} { log local0. "Passed error checking... Continuing..." }
return
}
when HTTP_RESPONSE priority 250 {
if {$static::RespondDebug > 0} { log local0. "Processing HTTP_RESPONSE... at Priority 250" }
if {$static::RespondDebug > 0} { log local0. "\$response_error = $response_error" }
if {$response_error} {
switch -glob [string toupper $HTTP_METHOD] {
"POST" {
if {$static::RespondDebug > 0} { log local0. "POST Method - Returning Code 503" }
HTTP::respond 503
event disable
return
}
"GET" {
Scheme specific error page handling.
if {$static::RespondDebug > 0} { log local0. "$errors_prefix: GET Method - Checking for Custom error page" }
if { [class match $vname eq Scheme_Error_VIP_Names] } {
if {$static::RespondDebug > 0} { log local0. "$errors_prefix: $vname found in Scheme_Error_VIP_Names" }
set scheme_ref [class lookup $vname Scheme_Error_VIP_Names]
if {$static::RespondDebug > 0} { log local0. "$errors_prefix: Scheme reference is: '$scheme_ref'" }
set response_html [ifile get scheme_error_html_$scheme_ref]
HTTP::respond 200 content $response_html "Content-Type" "text/html" "Cache-Control" "no-cache"
} else {
if {$static::RespondDebug > 0} { log local0. "$errors_prefix: $vname not found in Scheme_Error_VIP_Names" }
HTTP::respond 200 content $static::unavailable_page "Content-Type" "text/html" "Cache-Control" "no-cache"
}
event disable
return
}
}
}
}
But all the logs show that $pool_error and $response_error are at 0.
Cheers
Gav
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