Forum Discussion

DM_5174's avatar
DM_5174
Icon for Nimbostratus rankNimbostratus
Jun 20, 2007

Need urgent Redirect help!!!!

Hi all -

 

 

I have a problem here with redirecting the URL.

 

 

1. when users come in with http, the rule below needs to do a https redirect. This is working so far, however, when I try to add the following URL it is not redirecting to another pool.

 

 

This is working:

 

http://www.mysite.com -> https://www.mysite.com

 

 

This is not working:

 

http://www.mysite.com/site1 -> should get redirected to Pool "www_apache"...

 

 

I would like to add the "site1" redirection also to the same irule for the

 

https redirection below, but can not figure out how to do so. Please help!

 

 

Thanks!

 

 

 

 

when HTTP_REQUEST {

 

 

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

 

 

}

 

 

 

 

  • Colin_Walker_12's avatar
    Colin_Walker_12
    Historic F5 Account
    If all you're trying to do is modify the above rule so that all mysite.com/site1 requests go directly to the www_apache pool, you'd want something like this:

    
    when HTTP_REQUEST {
      if { ([HTTP::host] ends_with "mysite.com") and ( [HTTP::uri] starts_with "/site1") } {
        pool www_apache
      } else {
        HTTP::redirect https://[HTTP::host][HTTP::uri]
      }
    }

    HTH,

    Colin
  • Hi Colin,

     

     

    Thanks for the quick reply...

     

     

    What if I want to come in at http, get redirected to https first, and after that, i enter "site1" to the URL it should redirect me to

     

    the www_apache pool still in the ssl session.

     

     

    thanks!

     

    Anthony
  • Oh for got also, I i want the following

     

     

    /site2

     

    /site3

     

    /site4

     

     

    to also use the "www_apache" pool how would I add this? Site1 through Site4 are on separate servers (apache servers), however the

     

    original connection "http://www.mysite.com" is through the IIS servers.

     

     

    Thanks,

     

    Anhtuan

     

     

     

     

  • Colin_Walker_12's avatar
    Colin_Walker_12
    Historic F5 Account
    Well now you're talking about two separate iRules, on two separate Virtual Servers.

    On the port 80 virtual server you'd have the simple rule that you posted above:

    
    when HTTP_REQUEST {
      HTTP::redirect https://[HTTP::host][HTTP::uri]
    }

    Then you'd have another virtual server set up with the same IP address listening on port 443. That virtual server would then have an iRule assigned to it that would check to see if the URI started with site[1-4] and send them to the appropriate pool if that was the case.

    Something like:

    
    when HTTP_REQUEST {
      switch -glob [string tolower [HTTP::uri]] {
        "/site1*" -
        "/site2*" -
        "/site3*" -
        "/site4*" {
          pool www_apache
        }
      }
    }

    Keep in mind that the Virtual Server listening on 443 will have to have a client SSL profile configured as well so that it can decrypt the traffic at the BIG-IP, otherwise it won't be able to read the URI to route appropriately.

    HTH,

    Colin

  • Hi Collin -

     

     

    The problem here is: I have two virtual servers called

     

    "pool1_80" and "pool2_443"

     

     

    Virtual server "Pool1_80" has a iRule for the httpS redirect if coming in over port 80. After encrypting with the client SSL, it sends it to server 10.1.50.11 and 10.1.50.12 in the pool respectfully.

     

    However, if a user manually adds "/site1" after getting redirected to httpS, I get an http 1.1 error. If they successfully logged in this

     

    session and click on a link "/site1" they should get redirected to another "www_apache" pool containing server 10.1.50.12 and 10.1.50.13 while maintining the SSL connection originally created by the first redirect rule created by the "pool1_80" virtual server...So

     

    the "www_apache" server should see that the connection

     

    and sessions came from the first pool and serve the

     

    "/site1" page.

     

     

    Thanks for the help thus far, but even if I tried to add the second iRule to the "www_apache" pool listening on port 80 and creating another "www_apache_ssl" with the same servers listening on port 443 as per your suggestion, it still does not work.

     

     

    Please help.

     

     

    Thank you!