For more information regarding the security incident at F5, the actions we are taking to address it, and our ongoing efforts to protect our customers, click here.

Forum Discussion

Kareem's avatar
Kareem
Icon for Nimbostratus rankNimbostratus
Mar 06, 2014

Is it possible to attach an irule to an HTTPS virtual server ?

Hi,

I am trying to combine two irules together and having no luck. Can someone help ? The details are as follows: One rule is for http to https redirect while the second irule is for fallback page to be displayed if the original web page goes down. 1) http to https redirect when HTTP_REQUEST { string tolower [HTTP::host] if {[HTTP::host] contains "maximoqa.cenovus.com" }{ HTTP::redirect https://[HTTP::host]/maximo/ } else { HTTP::redirect https://[HTTP::host].cenovus.com/maximo/ } }

2) Use the LTM as a webserver as a lite version of a maintenance page. Like a fallback page when HTTP_REQUEST {

sets the timer to return client to host URL set stime 10

Use the Host header value for the responses if it's set. If not, use the VIP address. if {[string length [HTTP::host]]}{ set host [HTTP::host] } else { set host [IP::local_addr] }

Check if the URI is /maintenance switch [HTTP::uri] { "/maintenance" {

      Send an HTTP 200 response with a Javascript meta-refresh pointing to the host using a refresh time
     HTTP::respond 200 content \

"Maintenance page \

Sorry! This site is down for maintenance.

" "Content-Type" "text/html" return } } If the pool_testLB is down, redirect to the maintenance page if { [active_members pool_testLB] < 1 } { HTTP::redirect "http://$host/maintenance" return } }

18 Replies

  • Kareem's avatar
    Kareem
    Icon for Nimbostratus rankNimbostratus

    yes I do have an HTTP Profile attached to the port 443 VIP and I want to Use the LTM as a webserver as a lite version of a maintenance page. In this case, it returns a maintenance page with text to return when the pool members are not available. Also refreshes the client's browser, every x seconds, returning back to the site, in case the site returns to normal after an outage or maintenance.

     

    Are you thinking about using the Fallback host option under the HTTP profile ? Will that present the maintenace page or it will just redirect users to another server that has the page ?

     

  • Kareem's avatar
    Kareem
    Icon for Nimbostratus rankNimbostratus

    Yes, Fallback host will not meet my requirement. I need the F5 to present the actual message saying the application is down and under maintenance.

     

  • You are using a switch in your iRule, but you are only matching against one argument. Check out this post. Nitass included a good example in this thread that you should be able to use:

     

    https://devcentral.f5.com/questions/maintenance-page-irule

     

  • Kareem's avatar
    Kareem
    Icon for Nimbostratus rankNimbostratus

    Hi,

     

    Is it possible to create a very simple irule that will present a maintenace page and attach it to the port 443 VIP while the othe irule for HTTP-to-HTTPS redirect is still attached to the port 80 VIP ?

     

  • Yes. Leave your HTTP to HTTPS redirect iRule on your port 80 virtual server. Then this can be your iRule for your 443 virtual server:

    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
      }
    }
    
  • Kareem's avatar
    Kareem
    Icon for Nimbostratus rankNimbostratus

    Thanks. I will use this one and test and will give you a feedback asap.

     

  • Kareem's avatar
    Kareem
    Icon for Nimbostratus rankNimbostratus

    Hi,

     

    Do I need to chang LB::server pool to LB::maximo_qa_pool to reflect the actual server pool name ?

     

    Please respond as soon as possible.