Edge Redirect

Moving Redirects to the Edge Redirector Cloudlet

Tue, Jan 31st, 2017 | Kirsten Hunter

Many of our customers use Apache or other HTTP servers at their origin, and handle redirects using the configuration on those servers. As Akamai customers, you have the ability to perform those redirects at the edge, reducing the traffic to your origin and improving your users' experience.

It's possible to put redirects in place using Property Manager but this can be unwieldy, especially for properties with a large number of redirects. There's a better way!

The Edge Redirector cloudlet makes it possible to manage your file redirects at the edge using a powerful, flexible and usable interface. The cloudlet system means that you can update those redirects as needed, without publishing a new version of your property to Akamai.

If you're not already using cloudlets, ask your account team about adding cloudlets to your account so you can take advantage of this powerful capability! If you are a direct Akamai customer, you can add Cloudlets from the marketplace as well.

Once you've added cloudlets, you can configure redirects for the Edge Redirector cloudlet in Luna, but this post will give you some guidance on how to create and manage the redirects using the API.

The code and samples for this tutorial can be found in our open source repository at in the examples/python directory.

This simple utility demonstrates the process for setting your redirect policy. It supports creating a new policy (CREATE) or updating the latest policy (LATEST). The code demonstrates the following:

Creation of a new policy when needed:

new_version_info = { "description":"Adding a new version for match rules", "matchRuleFormat":"1.0", "matchRules": [] } create_path = "/cloudlets/api/v2/policies/%s/versions" % policy create_result = httpCaller.postResult(create_path, json.dumps(new_version_info))


Creation of appropriate JSON structure (example can be found in rules.json):

{ "redirectURL": " /lap-band-update.html", "type": "erMatchRule", "name": "match-url", "matchURL": "/princess_polymath/?p=31", "statusCode": 301 }


Adding the new rule to the policy:

rule_path = "/cloudlets/api/v2/policies/%s/versions/%s/rules" % (policy, version) rule_result = httpCaller.postResult(rule_path, json.dumps(rule))


Activating the new policy version:

activation_path = "/cloudlets/api/v2/policies/%s/versions/%s/activations" % (policy, version) activation_obj = { "network":"production" } activation_result = httpCaller.postResult(activation_path, json.dumps(activation_obj))



The rules.json file contains an example JSON setup for the rules you wish to set. You will need to create a generator to take your existing configuration for your system and translate it into this format in order to use the code.

Note that this is a very simple example. If you want to add new rules to your existing policy, you'll pull the existing policy and update it before performing a PUT back to the system.