Forum Discussion

Albert__Tase_70's avatar
Albert__Tase_70
Icon for Nimbostratus rankNimbostratus
Apr 19, 2007

need help with persistance and redirects

ok I have two vips which are 170.224.107.69_80 and 170.224.107.69_https

 

in the pool for 80 I have 10.245.243.19 on 80

 

and 10.254.243.27 on 80

 

under the vip for 443 I have the default cert applied and

 

in the pool 10.254.243.19 on 80 and 10.254.243.27 on 80

 

 

the traffic comes in hts the 80 vip the server dose a redirect to Redirect to http://170.224.107.69/BookStore/SecureCheckOut.do

 

so I tried applying the folowing irule to redirect it to https and I a musing cookie for persisteance.

 

 

when HTTP_REQUEST {

 

if { [HTTP::uri] contains "http://170.224.107.69/BookStore/SecureCheckOut.do"}{

 

HTTP::redirect "https://170.224.107.69/BookStore/SecureCheckOut.do"}

 

else {

 

use pool bookstore_10.254.243.41_80

 

}} which I applied to the port 80 vip it odse not work

 

 

the whole idea is to take the incomming port 80 connection persist it to one of the two servers and when they hit check out redierct them to https on the same server they cam e in on

 

 

thansk for any help also have a ticket open for this with support C347360

3 Replies

  • First the URI match in the first line won't work because you are trying to match the URI to the entire URL. Something as follows should work:

    
    when HTTP_REQUEST {
       if { [HTTP::uri] contains "/BookStore/SecureCheckOut.do" } {
          HTTP::redirect "https://170.224.107.69[HTTP::uri]"
       } else {
          pool bookstore_10.254.243.41_80
       }
    }

    As you can see on the redirect line I have set the URI variable, which would also contain any trailing query strings, if you don't want those then change the [HTTP::uri] to /BookStore/SecureCheckOut.do.

    I would also suggest you store specific commands like [HTTP::uri] into a variable:

    set my_uri [HTTP::uri], then you can do the following:

    
    when HTTP_REQUEST {
       set my_uri [HTTP::uri]
       if { $my_uri contains "/BookStore/SecureCheckOut.do" } {
          HTTP::redirect "https://170.224.107.69$my_uri"
       } else {
          pool bookstore_10.254.243.41_80
       }
    }

    It just looks a bit cleaner, plus you can reuse that variable anytime you want.

    HTH

    -Wes
  • For an overview on URI parsing, check out my recent tech tip on that subject:

     

     

    http://devcentral.f5.com/Default.aspx?tabid=63&articleType=ArticleView&articleId=18

     

    Click here

     

     

     

    -Joe
  • That is a great article Joe, the problem I have is the search functions on the new devcentral site do not always work. Aside from that, the content coming through is awesome. Good work all.

     

     

    -Wes