Forum Discussion

Stephen_Spence_'s avatar
Stephen_Spence_
Icon for Nimbostratus rankNimbostratus
May 30, 2013

URL Migration problem

I currently have two websites that I publish....

 

website.acme.com

 

website2.acme.com

 

For each published website I have irules in place which reference a datagroup list which contain certain url redirects.

 

For example:

 

If a user enters http://website.acme.com/test/123.htm in their browser, F5 takes that request, references the datagroup and forwards it to http://website.acme.com/test2/test2.htm

 

-or- If a user enters http://website2.acme.com/test/123.htm in their browser, F5 takes that request, references the datagroup and forwards it to http://website2.acme.com/test2/test2.htm

 

 

This all works because they reference two different pool and nodes, they reference different irules and data classes, etc...

 

One of my developers would now like to have certain requests (not all) coming in for http://website.acme.com to be directed to website2's backend pool member and keep "website.acme.com" in the url. (for selected paths)

 

Here is my current irule:

 

when HTTP_REQUEST {

 

set reqPath [string tolower [HTTP::path]]

 

if { [class match $reqPath eq website.acme.com_class] } {

 

set redirect_url [class lookup $reqPath website.acme.com_class]

 

HTTP::respond 302 Location $redirect_url Connection "Close"

 

}

 

}

 

 

I need to figure out a way that if a request comes in for http://website.acme.com/test/abc, redirect it to the website2.acme.com pool with the /abc path, but don't change original url path.

 

So it looks like: http://website.acme.com/test/abc/default.htm

 

 

Any assistance would be greatly appreciated.

 

 

5 Replies

  • Arie's avatar
    Arie
    Icon for Altostratus rankAltostratus
    I'm a bit confused by the terms "redirect" and "forward" you use; it seems that when you say "forward" you mean "redirect" (i.e. 3xx response).

     

     

    However, I think what you're looking for is the following:

     

     

    1) For certain requests you want to issue a Redirect (i.e. 3xx) so the client will make another request to the new URL. For this you would still use HTTP::respond (or HTTP::redirect, which is an alias for HTTP::respond 302).

     

    2) For other certain requests you want to pick another pool, which would simply mean that you tell the LTM to use a pool that's different from the one you configured as the default pool. See https://devcentral.f5.com/wiki/iRules.pool.ashx for details on how to use the "pool" command.
  • I apologize I meant to say redirect and not forward.

     

     

    They want to take an incoming request and redirect particular URLs to a different pool member.

     

    While I could do it through an irule, as I think there are going to be 70-80 of these redirected pool entries........

     

    The would like to leave the old URL on the old pool intact in case someone has them bookmarked.
  • Arie's avatar
    Arie
    Icon for Altostratus rankAltostratus
    It sounds like you're not looking for a redirect, though. My definition for a redirect is to send a directive to the client to make a new request (e.g. 301, 302, 307). If you're not telling the client to make a new request you're directing ('routing'), not redirecting. Perhaps this difference is a bit artificial, but it does help to keep the requirements clear.

     

     

    Either way, I think "HTTP::uri" is what you're looking for. It changes the URL is passed from the LTM to the node. Details: https://devcentral.f5.com/wiki/irules.http__uri.ashx

     

  • One of my developers would now like to have certain requests (not all) coming in for http://website.acme.com to be directed to website2's backend pool member and keep "website.acme.com" in the url. (for selected paths)you can use "pool" command or httpclass to send specific request to websites's pool.

     

     

    sol9800: Using an iRule to load balance HTTP requests to multiple pools

     

    http://support.f5.com/kb/en-us/solutions/public/9000/800/sol9800.html

     

     

    in case if you also want to change http host header, you can use "HTTP::header replace" command.

     

     

    HTTP::header wiki

     

    https://devcentral.f5.com/wiki/iRules.http__header.ashx