Configure Sandbox Client with the CLI

Update origin mappings for your Sandbox Client.

Before you begin

This step assumes you have already created a sandbox.

When creating a sandbox based on a property, the CLI automatically scans the Property Manager configuration, detects all the origin hostnames defined in the file, and asks you to confirm if you want sandbox requests to go directly to these origins.
my_laptop:~ username$ akamai sandbox create --property www.example.com:5 --name sandbox_for_example.com --requesthostnames localhost,www.example.com
building origin list 
Detected the following origins: origin-www.example.com  
? Would you like the Sandbox Client to proxy these to the destination defined in the Akamai config? **Yes**
registering sandbox in local datastore
sandbox_id: 4b3a0c0e-dfe9-4df8-b175-1ed23e293c52 sandbox_for_example.com is now active  
Successfully created sandbox_id 4b3a0c0e-dfe9-4df8-b175-1ed23e293c52. Generated sandbox client configuration at /Users/username/.akamai-cli/cache/sandbox-cli/sandboxes/sandbox_for_example.com/config.json please edit this file  
my_laptop:~ username$

If you want to route sandbox traffic to different development origins, follow these steps.

How to

  1. Enter n to override the settings.
  2. Enter open config.json to open the sandbox client configuration. You can locate the file in the cache folder for the Akamai CLI. In the example above it is /Users/username/.akamai-cli/cache/sandbox-cli/sandboxes/sandbox_for_example.com/config.json
    There are three customizable sections in the Sandbox Client configuration file.
    • sandboxServerInfo : Identify the port and IP address the Sandbox Client should run on.
      {
        "sandboxServerInfo": {
          "secure": false,
          "port": 9550,
          "host": "127.0.0.1"
        },
      
    • advanced.requestDetail : Set this value to true if you want to capture request and response headers and the sandbox connection logs. Find the log files in the same folder as your Sandbox Client config file.
      "advanced": {
          "requestDetail": false
        },
      
    • originMappings: Modify this section to override the origins defined in your property configuration to your development origin.
       "originMappings": [
          {
            "from": "origin-www.akamaidevops.com",
            "to": "pass-through"
          }
      
  3. Modify the target hostname in the "originMappings" section to point to your development origin.
    "originMappings": [
        {
          "from": "origin-www.akamaidevops.com",
          "to": {
            "secure": false,
            "port": 80,
            "host": "<target hostname>"
    
    • Add a host header line if you want to instruct the sandbox client to override the host header value that the sandbox forwards to the development origin.
      
            "to": {
              "secure": false,
              "port": 80,
              "host": "www.example.com.akadns.net",
              "hostHeader": "dev.example.com"
            }
      
    • Configure one origin to go directly and route another origin to a dev origin as shown.
      
            "to": {
              "secure": false,
              "port": 80,
              "host": "www.example.com.akadns.net",
              "hostHeader": "dev.example.com"
            }
            "from": "origin-static.akamaidevops.com",
            "to": "pass-through"
          }
      
    Note: If you have origin values that are generated at run time using Property Manager variables, you can configure your sandbox to support wildcards.
    • Allow all origin values to pass through.
      
            "originMappings":[  
          {  
              "from":"*.*",
              "to":"pass-through"
          }
    • Allow a specific subdomain wildcard origin value to pass through.
      
            "originMappings":[  
          {  
              "from":"*.example.com",
              "to":"pass-through"
          }
    • Allow a specific subdomain wildcard to go to another origin.
      "originMappings":[  
          {  
              "from":"*.example.com",
              "to":[  
                  "host":"127.0.0.1",
                  "port":9001,
                  "secure":false,
                  "hostHeader":"origin-dev.example.com"
              ]
          }