Forum Discussion

eirikn's avatar
eirikn
Icon for Nimbostratus rankNimbostratus
Jul 26, 2016

Can anyone help me with single apology page using data groups?

Hi,

I have a VS that serves several sites. Some times, one of these sites malfunction and I want to be able to manually put it in apology in a easy way.

Im thinking a datagroup with a string and a value will be easy enough, like this:

site1.com | no
site2.com | no
site3.com | yes
site4.com | no
site5.com | no

Site 3 will be put in apology (just a 301 redirect to a static URL. Every site has a different URL.)

My logic is:

If HTTP::host equals class match dg_apology_single and class match apology_dg_single value equals "yes"

then: 301 to http://apology.com/site3

else: do nothing.

Im having some problems creating the logic. Any help would be appreciated!

10 Replies

  • Make your data group look like this, maybe? Then you could write a quick API call to add or subtract hosts from the apology page and not have to worry about listing sites you don't want to take any action on/for.

     

    "www.example.com := www.apology.page/example"

     

    when HTTP_REQUEST {

     

    set host [class match -value [string tolower [HTTP::host]] equals dg_apology_single]

     

    if { $host ne "" } {

     

    HTTP::redirect "https://$host"

     

    unset $host

     

    }

     

    }

     

    • eirikn's avatar
      eirikn
      Icon for Nimbostratus rankNimbostratus

      Hmm, Im not sure if I follow.

       

      Writing a API to manage the hosts sounds like a bit to much work. Not knowing exactly how to do so.

       

      Having all my sites in the datagroup, predefined with a simple Yes/no value will be easy for others to manage.

       

      If site3 is experiencing problems, one just has to change a no to yes.

       

      I think the hard part is to have a single site redirect to a unique URL, if a "yes" is present.

       

    • ekaleido's avatar
      ekaleido
      Icon for Cirrus rankCirrus

      I don't like the way this plays out in a large environment, but if this is how you want to do it... Also if you want to append something relevant to site3 aspart of the URI in the redirect, it'll take a bit more work.

       

      www.site3.com := yes

       

      when HTTP_REQUEST {

       

      set host [class match -value [string tolower [HTTP::host]] equals dg_apology_single]

       

      if { $host eq "yes" } {

       

      HTTP::redirect "https://apology.page"

       

      unset $host

       

      }

       

      }

       

    • eirikn's avatar
      eirikn
      Icon for Nimbostratus rankNimbostratus

      This looks good, but would require alot of tweaking to be able to have 40 different apology URLS.

      Every site has a unique apology URL.

      Im no expert with using datagroups, but is it possible to have a third colon with the unique aplogoy URL?

      So if the DG looks like this:

          site1.com | no  | www.apology.com/23423
          site2.com | no  | www.apology.com/43623
          site3.com | yes | www.apology.com/54233
          site4.com | no  | www.apology.com/68423
          site5.com | yes | www.apology.com/64732
      

      The irule would redirect site3.com to www.apology.com/54233

      and redirect site5.com to www.apology.com/64732 ?

      I am open for suggestions, or other ways to solve the problem.

  • Make your data group look like this, maybe? Then you could write a quick API call to add or subtract hosts from the apology page and not have to worry about listing sites you don't want to take any action on/for.

     

    "www.example.com := www.apology.page/example"

     

    when HTTP_REQUEST {

     

    set host [class match -value [string tolower [HTTP::host]] equals dg_apology_single]

     

    if { $host ne "" } {

     

    HTTP::redirect "https://$host"

     

    unset $host

     

    }

     

    }

     

    • eirikn's avatar
      eirikn
      Icon for Nimbostratus rankNimbostratus

      Hmm, Im not sure if I follow.

       

      Writing a API to manage the hosts sounds like a bit to much work. Not knowing exactly how to do so.

       

      Having all my sites in the datagroup, predefined with a simple Yes/no value will be easy for others to manage.

       

      If site3 is experiencing problems, one just has to change a no to yes.

       

      I think the hard part is to have a single site redirect to a unique URL, if a "yes" is present.

       

    • ekaleido_26616's avatar
      ekaleido_26616
      Icon for Cirrocumulus rankCirrocumulus

      I don't like the way this plays out in a large environment, but if this is how you want to do it... Also if you want to append something relevant to site3 aspart of the URI in the redirect, it'll take a bit more work.

       

      www.site3.com := yes

       

      when HTTP_REQUEST {

       

      set host [class match -value [string tolower [HTTP::host]] equals dg_apology_single]

       

      if { $host eq "yes" } {

       

      HTTP::redirect "https://apology.page"

       

      unset $host

       

      }

       

      }

       

    • eirikn's avatar
      eirikn
      Icon for Nimbostratus rankNimbostratus

      This looks good, but would require alot of tweaking to be able to have 40 different apology URLS.

      Every site has a unique apology URL.

      Im no expert with using datagroups, but is it possible to have a third colon with the unique aplogoy URL?

      So if the DG looks like this:

          site1.com | no  | www.apology.com/23423
          site2.com | no  | www.apology.com/43623
          site3.com | yes | www.apology.com/54233
          site4.com | no  | www.apology.com/68423
          site5.com | yes | www.apology.com/64732
      

      The irule would redirect site3.com to www.apology.com/54233

      and redirect site5.com to www.apology.com/64732 ?

      I am open for suggestions, or other ways to solve the problem.