Forum Discussion

prasaath_d's avatar
prasaath_d
Icon for Nimbostratus rankNimbostratus
Oct 16, 2019

Maintenance page irule was not working properly

Hi Team ,

 

currently we have configured below irule to display the display the maintenance page .

 

when LB_FAILED {

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

   LB::reselect pool Axisconnect_Redirect_SplashPage

 }

}

when we are accessing the https://axisconnect-uat1.axiscapital.com the maintenance page is working fine .

but when we are accessing https://URL/uri is not working ( the https://axisconnect-uat1.axiscapital.com/agencyportal/DisplayLogonForm ).

 

so whenever user access the site any /uri it should display the same maintenance page.

 

so kindly suggest some ideas to modify the irule or i need to add else condition.

  • Hi

     

    Try adding HTTP::uri / so that the URI is rewritten to / if that is what your maintenance web page server is expecting

     

    when LB_FAILED {

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

       LB::reselect pool Axisconnect_Redirect_SplashPage

    HTTP::uri /

     }

    }

     

  • Hi Iaine ,

     

    i have used below irule syntax but it's not displaying the Maintenance Page properly . when we accessed with FDQN it is working fine.

     

    when LB_FAILED {

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

      LB::reselect pool Axisconnect-uat2_Redirect_SplashPage

      HTTP::uri "/"

     }

    }

     

    https://axisconnect-uat2.axiscapital.com - working

     

    https://axisconnect-uat2.axiscapital.com/agencyportal/DisplayHomePage - Not working

     

    Thanks

    Prasaath D

    • gersbah's avatar
      gersbah
      Icon for Cirrostratus rankCirrostratus

      You need a condition to exclude all resources of the maintenance page itself from the rewrite action. e.g.:

       

      if { not ( [HTTP::uri] starts_with "/maintenance/" ) }{

      HTTP::uri "/"

      }

       

      Or more If your maintenance page doesn't have all css, js, images, etc. neatly in one folder.

  • Hi Gersbah ,

    We have updated all the Maintenance related files in single folder after that Maintenance page displaying.

    But when we first time accessing https://axisconnect-uat2.axiscapital.com/agencyportal/DisplayHomePage it is displaying maintenance page same when we are refreshing that page in browser it is displaying the 404 error page .

     

    Can you please help me on this

    • gersbah's avatar
      gersbah
      Icon for Cirrostratus rankCirrostratus

      I don't have a test setup where I can easily reproduce this right now, but my guess would be that it may have to do with the event you are using (LB_FAILED). After your LB::reselect this may not trigger anymore, because now you are landing on a working pool again.

      You already have a check for active pool members < 1, so you can use the HTTP_REQUEST event instead. It's a bit less efficient, because it triggers all the time, not just in case of an ongoing maintenance. But I've never noticed any performance impact.

      I always do some variation of the following:

      when HTTP_REQUEST {
      	# Check if pool is unavailable
      	if { [ active_members prod_pool ] < 1 } {
      		# Don't do rewriting for resources of the maintenance page
      		if { not ( [HTTP::uri] starts_with "/maintenance/" ) }{
      			# Rewrite everything else to maintenance page
      			HTTP::uri "/maintenance/"
      		}
       
      		# Rewrite Host Header, set different Pool
      		HTTP::header replace Host "maintenance.server"
      		pool maintenance_pool
      	}
      }

      But as I said, I don't know if the event is actually what's causing your issue or if it's related to something else in your iRule or your maintenance page or your network environment.

      Try adding some logging (log local0. "your text here") to your iRule in different places, to see what happens when you refresh the page. Does the event still trigger? Do your conditions still match? What's the value of [HTTP::uri] during the various steps of the process? This may be a bit of data to parse, but you should be able to figure out what happens.

  • Hi Gersbah ,

     

    Please find the updated

    irule

     

    when HTTP_REQUEST {

     if { [ active_members UAT_BOS_axisconnect-uat2_https_pool] < 1 } {

     if { not ( [HTTP::uri] starts_with "/" ) }{

    HTTP::uri "/"

    }

     HTTP::header replace Host "10.18.123.19"

     pool Axisconnect-uat2_Redirect_SplashPage

    }

    }

    • gersbah's avatar
      gersbah
      Icon for Cirrostratus rankCirrostratus

      'if { not ( [HTTP::uri] starts_with "/" ) }' will never be true, because every URL starts with "/"

       

      It's important that the maintenance page resources are in a separate folder (which does not exist in the actual productive application), because then you can simply select everything which is not in that folder and rewrite it to the maintenance page. Otherwise you will have to exclude the maintenance page files from the rewrite one by one.