Forum Discussion

Craig_17766's avatar
Craig_17766
Icon for Nimbostratus rankNimbostratus
Aug 29, 2013

URL rewriting on our DR F5 for functionality testing

Hi all,

 

I’d be grateful for some advice or some insight with something I am trying to do – I presume I’ll need to use irules.

 

We have a backup site with copies of our apps that IIS expect connections on say www.mysite.co.uk (http and https virtual servers).

 

We also own www.backupsite.co.uk.

 

Our aim to be able to functionally test our backup site using xxx.backupsite.co.uk but in the event we’d need to flip over to our backup site we’d also need the applications available on the regular xxx.mysite.co.uk that IIS is expecting.

 

Can this be done?

 

Any help, hints, tips, greatly appreciated.

 

Thanks.

 

4 Replies

  • I did something similar to what Jason coded in the iRule.

     

    Let's say I have a site called auctions.mydomain.com (not real obviously). The DR system (only for testing as the production system remains available during the test), has an IP in the DNS that resolves auctions-dr.mydomain.com. I point the "-dr" name to the DR site. In an iRule attached to the DR site virtual server, I do as Jason suggested and update the host header so my virtual hosting works. This works quite well except for a few sites that have not learned the virtues of relative links yet.

     

    To handle that, I actually use a stream profile to catch any occurrence of the regular host name (auctions.mydomain.com in this case) and change it to auctions-dr.mydomain.com. I do that generally with some code to see if the host name is one of the real ones, then take the first node before the "-dr" so functionally, I remove the -dr. The stream and associated search and replace code handles cases where a link might have the original one. Note that I also found I had some limitations in using a stream when checking HTTP headers. For that, I also had to check in the Location header (as Jason suggested) to handle that too.

     

    This works quite well and allows our test people to access the DR system from their desktops with no other changes than the extra iRule inserted into the DR virtual servers and the additional DNS entries.

     

    I should say I also have a string class so I can check the hostnames. The reason is I have some domains that might be auctions.com but for the DR system, I need to send it to auctions-dr.mydomain.com. I have some code that looks for that case and adjusts the host header accordingly. If all your sites are at the same level in the domain, you might not need to worry about that.

     

    I hope that helps. If you are interested in anything specific, let me know. I did not add any code as the examples already included show the idea.

     

    Regards,

     

    Tom Schaefer Better Software Solutions, Inc.

     

  • Maybe not what you're intending, but it sounds like DNS would do this for you.

     

    1. Specific DNS entries for the backup URL to point to the backup servers/DC

       

    2. A GSLB like GTM to publish and load balance the production URL between the two DCs, and to fail over the sites.

       

  • Maybe not what you're intending, but it sounds like DNS would do this for you.

     

    1. Specific DNS entries for the backup URL to point to the backup servers/DC

       

    2. A GSLB like GTM to publish and load balance the production URL between the two DCs, and to fail over the sites.

       

  • easiest route is using host entries on your test systems. Do you have GTM? If so, you could use an iRule to give your backupsite as an answer for certain source IPs then you don't need to manipulate names at all. If neither of those are an option, you can rewrite them. Something like this should get you started:

    when HTTP_REQUEST {
      if { [HTTP::host] eq "www.backupsite.co.uk" } {
        set is_rewrite 1
        HTTP::header replace host "www.mysite.co.uk"
      }
    }
    when HTTP_RESPONSE {
      if { [info exists is_rewrite] } {
        HTTP::header replace Location [string map "www.mysite.co.uk www.backupsite.co.uk" [HTTP::header Location]]
      }
    }