Forum Discussion

dsanders1979_24's avatar
dsanders1979_24
Icon for Nimbostratus rankNimbostratus
Jul 03, 2007

Issue redirecting from HTTP to HTTPS and then balance to different pools based on suffix

I have a scenario where I have the same base URL, however multiple websites with different names, i.e. www.abc.com/production1/enhancedlogin.asp , and www.abc.com/test1/enhancedlogin.asp.

 

 

I currently have two virtual servers set up for this, one for Port 80 traffic, and the other for Port 443 traffic.

 

 

I would like all requests that come in for the host domain http://www.abc.com to be redirected to https://www.abc.com, and also redirected to whichever pool cooresponds with the suffix (https://www.abc.com/production1 >>> pool_1, while https://www.abc.com/test1 >>> pool_2)

 

 

I'm new to creation of IRules and was hoping to know, if this is possible, and if there are any suggestions / sample irules anyone is aware of that could help with this cause.

 

 

Thanks in advance!

1 Reply

  • Chris_Seymour_1's avatar
    Chris_Seymour_1
    Historic F5 Account
    This should be no problem. First you will want to redirect all traffic with the below simple iRule that is available on the codeshare.

     

     

    when HTTP_REQUEST {

     

    HTTP::redirect "https://[HTTP::host][HTTP::uri]" }

     

     

    Next you will need the commands to direct the client based on their URI to the correct pool

     

     

    when HTTP_REQUEST {

     

    if { [HTTP::uri] starts_with "production1" } {

     

    pool pool1

     

    }

     

    elseif { [HTTP::uri] starts_with"test1" } {

     

    pool pool2

     

    }

     

    }

     

     

    Good luck!

     

     

    obi chris kenobi