Forum Discussion

Jon_14_147267's avatar
Jon_14_147267
Icon for Nimbostratus rankNimbostratus
Jul 23, 2016

iRule TLSv1.2 Redirect Page

I've created an iRule that builds out the redirect page we want to send people to if there browser isn't using TLSv1.2 and it works if I hit the url directly i.e. https://www.oursite.com or by typing something like https://www.oursite.com/locations/gohere.

 

However, if I do a google search and click on the link from the search results for https://www.oursite.com/locations/gohere it will redirect to my TLSv1.2 page but the images don't display. if I view the link of an image it says https://www.oursite.com/locations/gohere/logo.png.

 

Is there a way to handle this so if someone does do a google search and clicks on a link, the redirect page along with the images will display no matter where the page they are trying to get to is in the site structure?

 

Here's the iRule code: when HTTP_REQUEST {

 

if { [SSL::cipher version] ne "TLSv1.2" } {
    log local0. "Client from IP: [IP::client_addr] is using [SSL::cipher version], which is not TLS1.2 so redirected to maintenance page"


      switch [HTTP::uri] {
       "/fceLogo.png" { HTTP::respond 200 content [ifile get "fceLogo_png"] "Content-Type" "image/png" }
       "/fceHeader.jpg" { HTTP::respond 200 content [ifile get "fceHeader"] "Content-Type" "image/jpeg" }
       "/chromeLogo.png" { HTTP::respond 200 content [ifile get "chromeLogo"] "Content-Type" "image/png" }
       "/firefoxLogo.png" { HTTP::respond 200 content [ifile get "firefoxLogo"] "Content-Type" "image/png" }
       "/ieLogo.png" { HTTP::respond 200 content [ifile get "ieLogo"] "Content-Type" "image/png" }
       "/safariLogo.png" { HTTP::respond 200 content [ifile get "safariLogo"] "Content-Type" "image/png" }
       "/fceFooterLogo.png" { HTTP::respond 200 content [ifile get "fceFooterLogo"] "Content-Type" "image/png" }           
       default { HTTP::respond 200 content [ifile get FarmCreditEastTLS ] "Content-Type" "text/html" }
       }
}
else {
    log local0. "The connection was initiated using TLSv1.2 and it was successful!!"
}

}

 

Thanks.

 

  • Just a hunch, but guessing the image URLs inside the HTML document don't jive with the expected iRule locations. Your iRule is expecting the images at the root of the site

    /ielogo.png        
    

    but the HTML page is indicating that they're local to the page itself

    /locations/gohere/logo.png
    
  • Doing this will make them relative to the page:

    "./logo.png"        
    

    Or worst case you could do an ends_with or switch glob:

    switch -glob [HTTP::uri] {        
        "*/logo.png" {}
    }
    
  • Hi,

    You can also use URI::basename instead of HTTP::uri so you don't care of the path :

    if { [SSL::cipher version] ne "TLSv1.2" } {
        log local0. "Client from IP: [IP::client_addr] is using [SSL::cipher version], which is not TLS1.2 so redirected to maintenance page"
    
    
          switch [URI::basename [HTTP::path]] {
           "/fceLogo.png" { HTTP::respond 200 content [ifile get "fceLogo_png"] "Content-Type" "image/png" }
           "/fceHeader.jpg" { HTTP::respond 200 content [ifile get "fceHeader"] "Content-Type" "image/jpeg" }
           "/chromeLogo.png" { HTTP::respond 200 content [ifile get "chromeLogo"] "Content-Type" "image/png" }
           "/firefoxLogo.png" { HTTP::respond 200 content [ifile get "firefoxLogo"] "Content-Type" "image/png" }
           "/ieLogo.png" { HTTP::respond 200 content [ifile get "ieLogo"] "Content-Type" "image/png" }
           "/safariLogo.png" { HTTP::respond 200 content [ifile get "safariLogo"] "Content-Type" "image/png" }
           "/fceFooterLogo.png" { HTTP::respond 200 content [ifile get "fceFooterLogo"] "Content-Type" "image/png" }           
           default { HTTP::respond 200 content [ifile get FarmCreditEastTLS ] "Content-Type" "text/html" }
           }
    }
    else {
        log local0. "The connection was initiated using TLSv1.2 and it was successful!!"
    }