Forum Discussion

Yasunori_Shimur's avatar
Yasunori_Shimur
Icon for Nimbostratus rankNimbostratus
Jul 16, 2020

To display Maintenance Page using iRule

I wanna creating a Maitenance Page by using iRule on BIG-IP when Virtual Server's pools are all down,

I created a following iRule.

When entering https://example.com/, displayed the Maintenance Page as expected.

However entering the URL with a path(https://example.com/aaaaa https://example.com/123456 etc...) , displayed "This site can't be reached. "

What I want to achieve is to display the Maintenance Page if entering a URL with a path.

How do i to do?

 

====================================================================================================================================

when HTTP_REQUEST

{

 if { [active_members [LB::server pool ]] < 1 }

    {

    switch [HTTP::uri]

    {

      "/" { HTTP::respond 200 content [ifile get "MAINTENANCE_index"] "Content-Type" "text/html" }

      "/application.css" { HTTP::respond 200 content [ifile get "MAINTENANCE_application"] "Content-Type" "text/css" }

      "/contents.css" { HTTP::respond 200 content [ifile get "MAINTENANCE_contents"] "Content-Type" "text/css" }

      "/default.css" { HTTP::respond 200 content [ifile get "MAINTENANCE_default"] "Content-Type" "text/css" }

      "/defaultHub.css" { HTTP::respond 200 content [ifile get "MAINTENANCE_defaultHub"] "Content-Type" "text/css" }

      "/footer_logo.png" { HTTP::respond 200 content [ifile get "MAINTENANCE_footer_logo"] "Content-Type" "image/png" }

      "/footer_privacy.png" { HTTP::respond 200 content [ifile get "MAINTENANCE_footer_privacy"] "Content-Type" "image/png" }

      "/global_navi.css" { HTTP::respond 200 content [ifile get "MAINTENANCE_global_navi"] "Content-Type" "text/css" }

      "/logo-hd.png" { HTTP::respond 200 content [ifile get "MAINTENANCE_logo-hd"] "Content-Type" "image/png" }

      "/module.css" { HTTP::respond 200 content [ifile get "MAINTENANCE_module"] "Content-Type" "text/css" }

      "/normal.css" { HTTP::respond 200 content [ifile get "MAINTENANCE_normal"] "Content-Type" "text/css" }

      "/return_top_link.png" { HTTP::respond 200 content [ifile get "MAINTENANCE_return_top_link"] "Content-Type" "image/png" }

    }

  }

}

====================================================================================================================================

3 Replies

  • Hi Yasunori,

    Can you try this?

    when HTTP_REQUEST {
    	if { [active_members [LB::server pool ]] < 1 } {
    		switch [HTTP::uri]
    		{
    		  "/application.css" { HTTP::respond 200 content [ifile get "MAINTENANCE_application"] "Content-Type" "text/css" }
    		  "/contents.css" { HTTP::respond 200 content [ifile get "MAINTENANCE_contents"] "Content-Type" "text/css" }
    		  "/default.css" { HTTP::respond 200 content [ifile get "MAINTENANCE_default"] "Content-Type" "text/css" }
    		  "/defaultHub.css" { HTTP::respond 200 content [ifile get "MAINTENANCE_defaultHub"] "Content-Type" "text/css" }
    		  "/footer_logo.png" { HTTP::respond 200 content [ifile get "MAINTENANCE_footer_logo"] "Content-Type" "image/png" }
    		  "/footer_privacy.png" { HTTP::respond 200 content [ifile get "MAINTENANCE_footer_privacy"] "Content-Type" "image/png" }
    		  "/global_navi.css" { HTTP::respond 200 content [ifile get "MAINTENANCE_global_navi"] "Content-Type" "text/css" }
    		  "/logo-hd.png" { HTTP::respond 200 content [ifile get "MAINTENANCE_logo-hd"] "Content-Type" "image/png" }
    		  "/module.css" { HTTP::respond 200 content [ifile get "MAINTENANCE_module"] "Content-Type" "text/css" }
    		  "/normal.css" { HTTP::respond 200 content [ifile get "MAINTENANCE_normal"] "Content-Type" "text/css" }
    		  "/return_top_link.png" { HTTP::respond 200 content [ifile get "MAINTENANCE_return_top_link"] "Content-Type" "image/png" }
    		  default { HTTP::respond 200 content [ifile get "MAINTENANCE_index"] "Content-Type" "text/html" }
    		}
    	}
    }
  • I did this iRule.

    The Maintenance Page with a path URL was also displayed as expected.

    Thanks.​