Forum Discussion

Joe_46466's avatar
Joe_46466
Icon for Nimbostratus rankNimbostratus
May 21, 2009

URL Rewriting of Hostname

We are upgrading a web farm, named "FarmA" and have built its replacement on new hardware. I have created a new pool named "FarmB". What I would like to do is this:

 

 

As applications are migrated from FarmA to FarmB they will have their IIS directory set to be a redirection on FarmA to FarmB, so that when the users type "http://FarmA/AppA/Index.htm" they will be redirected to "http://FarmB/AppA/Index.htm"

 

 

I would like to have an iRule in-place on FarmB to rewrite the URL so that the client sees the final address in their browser as "http://FarmA/AppA/Index.htm". This way no reference names have to change, bookmarks will still work, and the users will not know they are on the new farm.

 

 

Is this possible to achieve via an iRule? If so, can you provide an example?

 

 

Any help would be greatly appreciated!

4 Replies

  • You have a couple of options with URL rewriting. In your case, if you want to maintain the original hostname, then all you'll have to do is modify the Host HTTP header in the HTTP_REQUEST event on it's way to the backend pool of servers. Something like this should do it:

    when HTTP_REQUEST {  
       if { [HTTP::header "Host"] eq "FarmA" } {  
         HTTP::header replace "Host" "FarmB"  
       } 
     }

    If you configure this iRule on your FarmA virtual, it will make the uri "http://FarmA/*" look to the backend servers like it is "http://FarmB/*".

    Hope this helps.

    -Joe
  • Joe, thank you for such a quick response on this! I should clarify, FarmA isn't on an F5 Load Balancer and I don't have any way to control it. I need to apply the iRule to the FarmB settings.

     

     

    I have already placed this blanket iRule on FarmB, but it isn't working:

     

     

    when HTTP_REQUEST {

     

     

    HTTP::header replace "Host" "FarmA"

     

     

    }
  • Then it's not going to work because you need to flip the client back to FarmA so it shows up on the browser. This would lead to a flip-flop between FarmA and FarmB.

    However, what you could is 2 stage a transition (This conceptual design):

    Create a VIP and assign it pool FarmA.

    Apply the following iRule

      
     when HTTP_REQUEST {    
       if { [HTTP::header "Host"] eq "FarmA" } {  snat automap }  
     }  
     

    Repoint your DNS over to the new VIP and test to make the traffic is making it across. Now you have successfully transition over to the F5.

    The next step is when you migrate which is simply updating the iRULE and change the virtual default pool to FarmB

      
     when HTTP_REQUEST {    
       if { [HTTP::header "Host"] eq "FarmA" } {    
         HTTP::header replace "Host" "FarmB"   
       }  
     }  
     

    At least in concept it should work

    CB
  • OK, then it looks as though I cannot do what I wanted. Basically, I was looking for a way to upgrade servers and migrate webs one-by-one onto the new hardware while retaining the same hostname.

     

     

    Thanks for your quick responses.