Skip to main content

Self-Managed IO River Security in Akamai

IO River normally provisions and manages the Akamai configuration required to route traffic through its security services for you.

If you prefer (or need) to configure this yourself directly in Akamai Property Manager:

  • This guide walks through creating the IOR-Security Akamai Include, rule by rule.
  • The result matches the configuration that IO River would otherwise create automatically.
  • You can then attach this Include to different properties.

What does the IOR-Security Include do?​

The IOR-Security Include reroutes a copy of each request to IO River's security layer for inspection before it reaches your real origin.

The Include is created once per account/contract. Once created, it can be attached to any number of properties that need IO River's security services. Each Property just adds a reference to it and supplies its own service ID and origin values.

Setup Overview​

This guide has two parts:

  • Part A – create the IOR-Security Include itself (one-time setup).
  • Part B – attach the Include to a Property that needs IO River's security services (repeat for every Property).

Prerequisites​

Before you start, make sure you have access to Akamai Control Center with permission to create Includes on the relevant contract/group.

note

Part A can be automated with a script instead of following the manual steps — see Automating Part A with a script.

Step 1 – Create the Include​

  1. In Akamai Control Center, go to Content Delivery → Properties , and select the Includes tab.
  2. Click New Include.
    1. Select the product and click Create Include.
    2. Enter a Name: IOR-Security.
    3. Set Include Type to Common settings.
    4. Select the Group and Rule Format.
    5. Click Next and then Save.
important

The Include's Rule Format must match the rule format of every Property it's attached to. If a Property later upgrades its rule format, update this Include's rule format to match before re-activating the Property, otherwise activation will fail or behaviors may not validate correctly.

Step 2 – Add the variables​

Within the Include version you just created, go to the Include Variables section and add the following variables:

  • IORIVER_CLEARED
  • IORIVER_ASN
  • IORIVER_CITY
  • IORIVER_COUNTRY
  • IORIVER_REGION
  • IORIVER_CLIENT_IP

The initial value doesn't matter — each variable is overwritten at runtime by a setVariable behavior before it's used.

note

Akamai automatically namespaces Include-level user variables with a generated prefix unique to your account's Include (for example PMINC1419336_IORIVER_COUNTRY). Later steps reference these variables as {{user.<Include-ID>_IORIVER_...}} — always use Property Manager's Insert Variable picker to insert them rather than typing the reference by hand, since your actual prefix will differ from any example shown here.

Step 3 – Create the IORiver-Variables rule​

  1. Under the Include's default rule, click +Rules to add a new child rule.
  2. Name it IORiver-Variables and click on Insert Rule.
  3. Leave the criteria empty, so the rule always matches.
  4. Add behavior Set Variable:
    • Variable: select IORIVER_CLEARED
    • Create Value From: select Extract
    • Get Data From: select Request Header
    • Header Name: X-IOR-Cleared
    • Operation: None
  5. Add behavior Set Variable:
    • Variable: select IORIVER_CLIENT_IP
    • Create Value From: select Extract
    • Get Data From: select Request Header
    • Header Name: X-IOR-Client-IP
    • Operation: None
  6. Save the rule.

Step 4 – Create the IORiver-Security rule​

  1. Add another child rule under default, named IORiver-Security.

  2. Add a Variable criterion:

    • Variable: select IORIVER_CLEARED
    • Match Operator: is not
    • Value: {{parent.PMUSER_IORIVER_SERVICE_ID}}
      • Type this as a literal variable reference — this is a property-level variable supplied later in Part B, not something you define here
  3. Add the following behaviors:

    a. Set Variable (ASN)

    • Variable: select IORIVER_ASN
    • Create Value From: select Extract
    • Get Data From: select EdgeScape Data
    • EdgeScape Field: select AS Number
    • Operation: None

    b. Set Variable (City)

    • Variable: select IORIVER_CITY
    • Create Value From: select Extract
    • Get Data From: select EdgeScape Data
    • EdgeScape Field: select City
    • Operation: None

    c. Set Variable (Country)

    • Variable: select IORIVER_COUNTRY
    • Create Value From: select Extract
    • Get Data From: select EdgeScape Data
    • EdgeScape Field: select Country Code
    • Operation: None

    d. Set Variable (Region)

    • Variable: select IORIVER_REGION
    • Create Value From: select Extract
    • Get Data From: select EdgeScape Data
    • EdgeScape Field: select Region Code
    • Operation: None

    e. Modify Outgoing Request Header (sidecar marker)

    • Action: Add
    • Select header name: Other
    • Custom header name: X-IOR-Security-Sidecar
    • Header value: true

    f. Modify Outgoing Request Header (preserve original host)

    • Action: Add
    • Select header name: Other
    • Custom header name: X-IOR-Original-Host
    • Header value: {{builtin.AK_HOST}}
      • Type this as a literal variable reference

    g. Modify Outgoing Request Header (override Host)

    • Action: Add
    • Select header name: Other
    • Custom header name: Host
    • Header value: {{parent.PMUSER_IORIVER_SECURITY_ORIGIN}}
      • Type this as a literal variable reference — this is a property-level variable supplied later in Part B, not something you define here

    h. Modify Outgoing Request Header

    • Action: Add
    • Select header name: Other
    • Custom header name: X-IOR-Client-IP
    • Header value: {{builtin.AK_CLIENT_IP}}
      • Type this as a literal variable reference

    i. Modify Outgoing Request Header

    • Action: Add
    • Select header name: Other
    • Custom header name: X-IOR-Geodata
    • Header value: {{user.<Include-ID>_IORIVER_COUNTRY}},{{user.<Include-ID>_IORIVER_REGION}},{{user.<Include-ID>_IORIVER_CITY}},{{user.<Include-ID>_IORIVER_ASN}}
      • Use the Insert Variable picker to insert each of the four variables set in behaviors a–d — don't type this manually, since your <Include-ID> prefix will differ from this example

    j. Origin Server — route the request to the security layer:

    • Origin Type: Your own origin
    • Origin Server Hostname: {{parent.PMUSER_IORIVER_SECURITY_ORIGIN}}
      • Type this as a literal variable reference — this is a property-level variable supplied later in Part B, not something you define here
    • Forward Host Header: Origin Hostname
    • Cache Key Hostname: Origin Hostname
    • Origin SSL Certificate Verification:
      • Verification Settings: Choose Your Own
      • Origin Certificate(s) to Honor: Standard Certificate Authorities, with Akamai Permissive selected
      • Valid CN Values to Accept: Origin Hostname and Forward Host Header
    • Use True Client IP Header: Yes
      • True Client IP Header: True-Client-IP
      • Trust Client Setting: No
    • Rest of the settings should be default
  4. Save the rule.

Step 5 – Create the IORiver-Security-Cleared rule​

  1. Add another child rule under default, named IORiver-Security-Cleared.

  2. Add a Variable criterion:

    • Variable: select IORIVER_CLEARED
    • Match Operator: is
    • Value: {{parent.PMUSER_IORIVER_SERVICE_ID}}
      • Type this as a literal variable reference — this is a property-level variable supplied later in Part B, not something you define here
  3. Add the following behavior:

    Modify Outgoing Request Header

    • Action: Add
    • Select header name: Other
    • Custom header name: True-Client-IP
    • Header value: {{user.<Include-ID>_IORIVER_CLIENT_IP}}
      • Use the Insert Variable picker to select the IORIVER_CLIENT_IP variable set in Step 3 — don't type this manually, since your <Include-ID> prefix will differ from this example. Do not use {{builtin.AK_CLIENT_IP}} here — by this point the connecting IP is IO River's security layer, not the original client, so the real client IP must come from the X-IOR-Client-IP header value that the security layer echoed back.

Your rule tree under default should now contain exactly three child rules, IORiver-Variables, IORiver-Security and IORiver-Security-Cleared.

Step 6 – Validate and activate the Include​

Activate the IOR-Security Include on Staging, then later on Production. It's fine to activate it now even though no Property references it yet — Part B attaches it to one or more properties.

The Include itself is now ready to be reused by any property. The rest of this guide is Part B, which you repeat for each property that needs IO River security enabled.

Automating Part A with a script​

Steps 1–5 above (creating the Include and its rule tree) can be automated with the create_akamai_security_include.py script, instead of clicking through Property Manager by hand.

Prerequisites:

  • Akamai API credentials configured in ~/.edgerc, with Property Manager (PAPI) read/write access.
  • Python 3 with the requests and edgegrid-python packages installed (pip install requests edgegrid-python).

Usage:

python3 create_akamai_security_include.py --contract-id ctr_XXXX --group-id grp_XXXX

This creates the IOR-Security Include (type Common Settings), and writes the IORiver-Variables + IORiver-Security + IORiver-Security-Cleared rule tree described in Steps 2–5.

Options:

  • --rule-format — pin the Include to a specific rule format instead of the account's latest.
  • --dry-run — print the generated rule tree JSON without calling the Akamai API.

The script only creates the Include and saves its rules — it doesn't activate it (Step 6) or attach it to a property (Part B); do those steps manually as described below.

Part B – Attach the Include to a property​

Prerequisites​

Get these two values before you start

This step is easy to miss, but Step 1 below won't work without them. These are property-level values (not part of the Include itself), and they come from the IO River console, not Akamai:

  • IORIVER_SERVICE_ID — your IO River Service ID for this specific property. There are 2 ways to get it:
    1. From the side panel when you select a service on the Services page.
    2. From the service URL: https://manage.ioriver.io/<account-id>/services/<service-id>/... (e.g. for https://manage.ioriver.io/45cd502c-e526-42aa-aef5-962db7cde53d/services/2def1aa5-1a4b-4da2-ae9e-e5caeecf6189/..., the Service ID is 2def1aa5-1a4b-4da2-ae9e-e5caeecf6189).
  • IORIVER_SECURITY_ORIGIN — the hostname of the IO River Security Origin. Found inside the service, under the CDN Providers tab: find the Akamai row, then copy the Security Origin Host value from its Provider Specific Settings.

Step 1 – Define the property variables​

  1. Open the Property that should use this security integration.

  2. Go to Property Variables on the Property and add two User Variables (if they don't already exist):

    • IORIVER_SERVICE_ID – set the initial value to the Property's IO River service ID from the Prerequisites above.
    • IORIVER_SECURITY_ORIGIN – set the initial value to the security layer origin hostname from the Prerequisites above.

    Akamai automatically namespaces user variables with a PMUSER_ prefix, so these resolve to PMUSER_IORIVER_SERVICE_ID and PMUSER_IORIVER_SECURITY_ORIGIN — matching the {{parent.*}} references used inside the Include. They must be defined on the Property (the Include's parent), not inside the Include itself.

Step 2 – Reference the Include​

  1. In the Property's rule tree, add a child rule under the Default Rule called IORiver-Security-Rule
  2. Under this rule, add a behavior Include, and select IOR-Security
  3. Save the Property version.
important

Make sure that the IORiver-Security-Rule rule is placed as the last rule in the Property rules.

Step 3 – Activate​

  1. Activate the Property version on Staging.
  2. Test against the staging hostname: confirm requests are routed to the security layer - you can review such requests in IO River's Security Analytics page.
  3. Once verified, activate the Property on Production.