document.write('
Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. when HTTP_REQUEST {
  2.  
  3. #
  4. # Service requests for files (URIs) from the maintenance page.
  5. # Note that we always service these pages, even if the http_pool is up.
  6. # The maintenance prefix should be unique in the application and
  7. # not conflict with an existing directory on the web servers.
  8. set maint_prefix "/maintenancepage"
  9.  
  10. if { [HTTP::uri] starts_with "$maint_prefix" } {
  11.  
  12. # Strip off the $maint_prefix from the URI as you can't easily do variable expansion
  13. # within a switch statement.
  14. # Note that requests for the exact maintenance prefix URI will be set to a null string,
  15. # so handle null in the first switch case.
  16. set uri [string map [list $maint_prefix ""] [HTTP::uri]]
  17.  
  18. # Return the requested page based on the requested URI
  19. switch -- $uri {
  20. "" {
  21. log local0. "Request for $maint_prefix. Redirecting to $maint_prefix/"
  22. HTTP::redirect "$maint_prefix/index.html"
  23. }
  24. "/" -
  25. "/index.html" {
  26. log local0. "Request for index. Responding with content: [lindex $::maint_index_html_class 0]"
  27. HTTP::respond 200 content [class element -value 0 maint_index_html_class] "Content-Type" "text/html"
  28. }
  29. "/logo.png" {
  30. log local0. "Request for logo.png. Responding with binary content"
  31. HTTP::respond 200 content [b64decode [class element -value 0 maint_index_logo_png_class]] "Content-Type" "image/png"
  32. }
  33. default {
  34. log local0. "Unrecognized request to URI: [HTTP::uri]"
  35. HTTP::respond 404 content "Unrecognized request to [HTTP::uri]" "Content-Type" "text/html"
  36. }
  37. }
  38. return
  39. }
  40. #
  41. # If the all members in the default pool are down, redirect to the maintenance page
  42. #
  43. if { [active_members [LB::server pool]] < 1 } {
  44. HTTP::redirect "$maint_prefix/index.html"
  45. }
  46. }
');