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

Michael_-_Harr1's avatar
Michael_-_Harr1
Icon for Nimbostratus rankNimbostratus
Feb 20, 2014

Need some assistance with IRULE

Need some assistance with IRULE. If my pool mobileqa goes down need to seend a redirect for browser traffic to maintenance page. However if the traffic is coming from a mobile device the URL is different then a browser send a http status code 404 Not sure how to code the logic in one IRULE

 

URL will be something like Browser mobilet.test.com/www/* redirect to https://edepositqa.test.com/mobile/index.html Browser mobile.test.com/splash/* redirect to maintenace site redirect https://edepositqa.test.com/mobile/index.html Mobile Device mobile.test.com/webapp/* send status code 404

 

Sample when HTTP_REQUEST { if { [active_members Mobile-QA] < 1 } { HTTP::respond 404 Location [HTTP::header Location] } }

 

when HTTP_REQUEST { if { [active_members Mobile-QA] < 1 } {

 

    HTTP::redirect "https://edepositqa.test.com/mobile/index.html"  
    return

} } I have this IRULE Not sure how to code these in one IRULE nested

 

7 Replies

  • if { [HTTP::URI] starts_with "/www/" } { HTTP::redirect https://edepositqa.test.com/mobile/index.html return } elseif { [HTTP::URI] starts_with "/splash/"} { HTTP::redirect https://edepositqa.test.com/mobile/index.html return } else { HTTP::respond 404 Location [HTTP::header Location] return }

     

    This should do the trick

     

    • Cory_50405's avatar
      Cory_50405
      Icon for Noctilucent rankNoctilucent
      Your redirect should probably use code 302. 404 means not found, and isn't necessarily appropriate in this case.
  • I need to add the condition the Virtual server pool goes down as the condition

     

    when HTTP_REQUEST { if { [active_members Mobile-QA] < 1 } {

     

    Not sure how to incorporate the rest

     

    if { [HTTP::URI] starts_with "/www/" } { HTTP::redirect https://edepositqa.test.com/mobile/index.html return } elseif { [HTTP::URI] starts_with "/splash/"} { HTTP::redirect https://edepositqa.test.com/mobile/index.html return } else { HTTP::respond 404 Location [HTTP::header Location] return }

     

  • e.g.

    when HTTP_REQUEST {
      if { [active_members Mobile-QA] < 1 } {
        if { [HTTP::URI] starts_with "/www/" } {
          HTTP::redirect "https://edepositqa.test.com/mobile/index.html"
        } elseif { [HTTP::URI] starts_with "/splash/"} { 
          HTTP::redirect "https://edepositqa.test.com/mobile/index.html"
        } else { 
          HTTP::respond 404
        }
      }
    }
    
    • Michael_-_Harr1's avatar
      Michael_-_Harr1
      Icon for Nimbostratus rankNimbostratus
      Thank you. when I tried that IRULE received error undefined procedure error. 01070151:3: Rule [/Common/test] error: line 3: [undefined procedure: HTTP::URI] [HTTP::URI]
  • e.g.

    when HTTP_REQUEST {
      if { [active_members Mobile-QA] < 1 } {
        if { [HTTP::URI] starts_with "/www/" } {
          HTTP::redirect "https://edepositqa.test.com/mobile/index.html"
        } elseif { [HTTP::URI] starts_with "/splash/"} { 
          HTTP::redirect "https://edepositqa.test.com/mobile/index.html"
        } else { 
          HTTP::respond 404
        }
      }
    }
    
    • Michael_-_Harr1's avatar
      Michael_-_Harr1
      Icon for Nimbostratus rankNimbostratus
      Thank you. when I tried that IRULE received error undefined procedure error. 01070151:3: Rule [/Common/test] error: line 3: [undefined procedure: HTTP::URI] [HTTP::URI]