ACE URL Redirects

Sometimes a web applications virtual directory can change. You may have many rservers behind your load-balancer that would require a configuration change to send the redirect. In this case, it’s easier to configure the redirect right on the ACE instead of the rservers web-server (IIS, Apache, etc.) instead.

So lets say your website is http://site.domain.com/oldsite and the application team built a new app and wants everyone to be redirected to http://site.domain.com/newsite

First you need to define the redirect:

rserver redirect REDIRECT1
  webhost-redirection http://%h/newsite 301
    inservice

The %h above inserts the host header from the request, which in our case would have been site.domain.com. You can also use %p which inserts the full URL path string from the request. This most likely wont be the one you use.

  • %h—Inserts the hostname from the request Host header
  • %p—Inserts the URL path string from the request

The 301 means the resource has been moved permanently. If it’s just a temporary change, you can use 302. Sometimes admins just use 302 because it’s the default.

  • 301—The requested resource has been moved permanently. For future references to this resource, the client should use one of the returned URLs.
  • 302—(Default) The requested resource has been found but has been moved temporarily to another location. For future references to this resource, the client should continue to use the request URI because the resource may be moved to other locations occasionally.

Now your redirection rule is configured. You need to assign it to a serverfarm. Instead of a host serverfarm, you want to define a redirect serverfarm.

serverfarm redirect FARM-REDIRECT
  rserver REDIRECT1
    inservice

So you’ve got a serverfarm and a rserver redirection configuration. Now it’s time to define the classmap that will match the virtual directory the user requests.

In our example the user is going to /oldsite; in many cases you already have this configured–since we are doing a redirection to begin with.

class-map type http loadbalance match-any CLASS-MAP-APPS
  5 match http url /oldsite.*
  6 match http url /hello.*
  7 match http url /osiris.*

So we want to write a new classmap that will match only the virtual directory we want users to be redirected from. This way we don’t mess up any of the current virtual-directory matches we have defined.

class-map type http loadbalance match-any CLASS-MAP-REDIRECT
  5 match http url /oldsite.*

Now we’re pretty much ready to go. Add the new class-map to your policy-map:

policy-map type loadbalance first-match MY-POLICY
  class CLASS-MAP-APPS
    serverfarm FARM-APPS
  class CLASS-MAP-REDIRECT
    serverfarm FARM-REDIRECT

Now everything is configured for the new redirection. BUT the old class map virtual directory match is still there. We need to remove it to make our changes go into place. This makes our changes immediate.

class-map type http loadbalance match-any CLASS-MAP-APPS
  no 5 match http url /oldsite.*

Now test your site! I like to use Chrome with it’s developer tools to capture each request. You should see the initial request, then the newsite coming back with a 301.

Advertisements
ACE URL Redirects

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s