Forum Discussion

MSK_222682's avatar
MSK_222682
Icon for Nimbostratus rankNimbostratus
May 06, 2016

How to forward the requests to another URL using iRule

Hi, I have a scenario wherein I have to forward all the incoming requests to a virtual server (https://abc.com) to another URL something like https://test.com/o/maintenance.html which hosts the maintenance page, so that users could see the maintenance page.

However, this should be transparent to the end user viz, they should not see https://test.com/o/maintenance.html in their browsers when accessing the virtual server in question.

Can anyone help me with the irule in this regard. P.S. I have tried the iFile but the maintnance page is only working for IE but not with Chrome & Mozilla.

Thanks in advance, MSK

  • hello,

    The best way is to apply the irule for maintenance on the VS directly. for example :

     

    when HTTP_REQUEST {
      if { [active_members $default_pool] < 1 } { 
        HTTP::respond 200 content [ifile get "/Common/maintenance.html"] noserver "Content-Type" "text/html" "Cache-Control" "no-cache, must-revalidate" 
      }
    } 
    when LB_FAILED { 
          HTTP::respond 200 content [ifile get "/Common/maintenance.html"] noserver "Content-Type" "text/html" "Cache-Control" "no-cache, must-revalidate" 
        }
    

     

    Otherwise, you can use the virtual command (e.g. virtual /Common/my_VS_Name)

  • Arie's avatar
    Arie
    Icon for Altostratus rankAltostratus

    If it's a maintenance page you would want to use HTTP response code 503 (Service Unavailable) rather than a 200 (OK), per the RFC standards for HTTP.

    Using a 200 (OK) is risky. For instance, there's a chance that search engines will index the maintenance page. If any department is using external monitoring (e.g. Pingdom) those reports would incorrectly show that the site/pages were available.

    You can simply change the response code from 200 to 503:

     

    HTTP::respond 503 content [ifile get "/Common/maintenance.html"] noserver "Content-Type" "text/html" "Cache-Control" "no-cache, must-revalidate"