Forum Discussion

adiezma_1656's avatar
adiezma_1656
Icon for Nimbostratus rankNimbostratus
Nov 09, 2011

iRule redirect http to https except! ...

Hi everyone!

 

 

 

I need a iRule can always redirect a URL from HTTP to HTTPS, except if the url ends in sync.php

 

 

 

Example in my internet browser:

 

 

 

http://blablabla.bla.com -- REDIRECT to https://blablabla.bla.com

 

 

 

http://blablabla.bla.com/sync.php -- NO REDIRECT

 

 

 

https://blablabla.bla.com/sync.php -- REDIRECT to http://blablabla.bla.com/sync.php

 

 

 

Pardon for my english, it's very bad

 

 

 

Thanks a lot!!

 

2 Replies

  • e.g.

    [root@ve1023:Active] config  b virtual bar list
    virtual bar {
       snat automap
       pool foo
       destination 172.28.65.152:http
       ip protocol tcp
       rules myrule
       profiles {
          http {}
          tcp {}
       }
    }
    [root@ve1023:Active] config  b rule myrule list
    rule myrule {
       when HTTP_REQUEST {
            if {not ([string tolower [HTTP::path]] ends_with "sync.php")}{
                    HTTP::redirect "https://[HTTP::host][HTTP::uri]"
            }
    }
    }
    
    [root@ve1023:Active] config  b virtual bar2 list
    virtual bar2 {
       snat automap
       pool foo
       destination 172.28.65.152:https
       ip protocol tcp
       rules myrule2
       profiles {
          clientssl {
             clientside
          }
          http {}
          tcp {}
       }
    }
    [root@ve1023:Active] config  b rule myrule2 list
    rule myrule2 {
       when HTTP_REQUEST {
            if {[string tolower [HTTP::path]] ends_with "sync.php"}{
                    HTTP::redirect "http://[HTTP::host][HTTP::uri]"
            }
    }
    }
    
    [root@ve1023:Active] config  curl -I http://blablabla.bla.com/
    HTTP/1.0 302 Found
    Location: https://blablabla.bla.com/
    Server: BigIP
    Connection: Keep-Alive
    Content-Length: 0
    
    [root@ve1023:Active] config  curl -I http://blablabla.bla.com/test
    HTTP/1.0 302 Found
    Location: https://blablabla.bla.com/test
    Server: BigIP
    Connection: Keep-Alive
    Content-Length: 0
    
    [root@ve1023:Active] config  curl -I http://blablabla.bla.com/sync.php
    HTTP/1.1 404 Not Found
    Date: Thu, 10 Nov 2011 01:10:46 GMT
    Server: Apache/2.2.3 (CentOS)
    Connection: close
    Content-Type: text/html; charset=iso-8859-1
    
    [root@ve1023:Active] config  curl -Ik https://blablabla.bla.com/sync.php
    HTTP/1.0 302 Found
    Location: http://blablabla.bla.com/sync.php
    Server: BigIP
    Connection: Keep-Alive
    Content-Length: 0
    
    
  • Hello again.

     

     

    The two iRules it's working very good. Nitass, thank you so much!!

     

     

    Solved !!