Forum Discussion

muzammil_88686's avatar
muzammil_88686
Icon for Nimbostratus rankNimbostratus
Jan 05, 2013

Maintenance Page iRule

Dear Team,

 

We have one virtual server which consists of two pool members on it.

 

We would like to deploy the maintenance page on F5 if both the pool members are down.

 

We have an HTML page(which consists of the extension "maintenance.html") with us.

 

Could you pls let me know the iRule if we want to deploy the above "maintence.html" page on F5?

 

 

10 Replies

  • Dear Team,

     

     

    Also note that whenever the user want to access the www.test.com and all the subsequent requests i.e "/*" need to be redirected to maintenance page.

     

     

    Thank you!

     

  • what version are you running? have you tried sample irule in LTM Maintenance Page below? isn't it usable?

     

     

    LTM Maintenance Page

     

    https://devcentral.f5.com/wiki/irules.ltmmaintenancepage.ashx
  • Thank you for your response!

     

     

    Below is the version which we are running on LTM.

     

     

    BIG-IP 10.2.1 Build 511.0 Hotfix HF3.

     

     

    To be honest I m not familiar with the iRule what you have mentioned.

     

     

    Could you pls suggest me one sample which I can follow?

     

     

    Requirement:

     

    Virtual Server IP: 192.168.1.1

     

    Pool Name: test_pool

     

    Pool Members: 10.1.1.1 and 10.1.1.2

     

    HTTP page name do be deployed on LTM: "maintenance.html"

     

    Condition: If both the pool members are down then user need to get the page "maintenance.html"

     

     

    Pls let me know if you have any queries.

     

     

    Thank you!

     

     

  • Thank you Steve for your response!

     

     

    When I tried to follow the URL I have some doubts...could you pls suggest me on that.

     

     

    1. Create the HTML for the maintenance page. It must be on one line, and all double-quotes must be escaped with backslashes.

     

    Query1: For example, I have the below HTML code from "maint.index.html"(I mean ".HTML" format")

     

     

    Maintenance pageSorry! This site is down for maintenance.

     

     

    Do I need to save it as "maint.index.html.class"(I mean in ".class" format) and upload it in "/var/class/"

     

     

    Thank you!
  • If you plan on going to v11 anytime soon, iFiles makes this much easier.

     

     

    https://devcentral.f5.com/tech-tips/articles/v111-ndashexternal-file-access-from-irules-via-ifiles
  • Thank you Chris for your response and suggestion.

     

     

    Unfortunately we do not have plan to go for v11 in the near future.

     

     

     

     

     

  • since your maintenance page is simple (no image inside), you may try something like this.

    [root@ve10:Active] config  b virtual bar80 list
    virtual bar80 {
       snat automap
       pool foo
       destination 172.28.19.252:80
       ip protocol 6
       rules myrule
       profiles {
          http {}
          tcp {}
       }
    }
    [root@ve10:Active] config  b rule myrule list
    rule myrule {
       when RULE_INIT {
      set static::maint_page "Sorry! This site is down for maintenance."
    }
    when HTTP_REQUEST {
      set maint_prefix "/maintenance.html"
    
      if { [HTTP::uri] equals "$maint_prefix" } {
        HTTP::respond 200 content $static::maint_page "Content-Type" "text/html" "Connection" "Close"
        return
      }
    
      if { [active_members [LB::server pool]] < 1 } {
        HTTP::redirect $maint_prefix
      }
    }
    }
    
     pool is down
    
    [root@ve10:Active] config  b pool foo|grep -i pool\ member
    +-> POOL MEMBER foo/200.200.200.101:80   inactive,down
    
     bigip responds maintenance page instead
    
    [root@ve10:Active] config  curl -iL http://172.28.19.252
    HTTP/1.0 302 Found
    Location: /maintenance.html
    Server: BigIP
    Connection: Keep-Alive
    Content-Length: 0
    
    HTTP/1.0 200 OK
    Content-Type: text/html
    Server: BigIP
    Connection: close
    Content-Length: 80
    
    Sorry! This site is down for maintenance.
    
    
  • Thank you Nitass for your response!

     

     

    From the iRule which you have suggested:

     

    set maint_prefix "/maintenance.html"

     

     

    Users will not access any "/maintenance.html" page. If the user is trying to access "www.test.com" i.e "/*"(I mean www.test.com/abc, www.test.com/def, www.test.com/*...etc) it should show the below html page

     

     

    "Sorry! This site is down for maintenance."

     

     

    Could you pls suggest if the above iRule suggested by you is still valid?