Redirect Non-SSL Requests on SSL Virtual Server Rule

Problem this snippet solves:

This iRule sends an HTTP redirect to clients who make an HTTP request to an HTTPS virtual server. In order for this iRule to work, non-SSL connections must be allowed on the client SSL profile.

Code :

when HTTP_REQUEST { 

   # Check if the client used an SSL cipher 
   if {not ([catch {SSL::cipher version} result]) && [string tolower $result] ne "none"}{ 

      # Client did use a cipher 
      log local0. "\$result: $result. Allowing encrypted request." 

   } else { 

      # Client did not use a cipher 
      log local0. "\$result: $result. Redirecting unencrypted request." 
      HTTP::redirect "https://usesslplease.example.com/" 
   } 
}
Published Mar 18, 2015
Version 1.0
No CommentsBe the first to comment