How to define a new origin for your application

Define an origin to determine the source of the content of your application. It can be an application, a web server, or a storage.

When you create an edge application, a default origin is created and activated automatically. This guide will show you how to create and activate a new origin with different configurations without removing or editing the default origin.


  1. Access Azion Console.
  2. On the upper-left corner of the page, open the Products menu, represented by three horizontal lines, and then select Edge Application.
  3. Click the edge application for which you want to configure a new origin.
  4. Select the Origins tab.
  5. Click the Add Origin button.
  6. Give your new origin a name. For example: httpbin.org
  7. Under Origin Type, keep the option Single Origin selected.
  1. Under Host Header, add customhost.com.
  2. Leave Origin Path blank.
  3. Under Origin Protocol Policy, select Enforce HTTPS.
  4. Under Address, add httpbin.org.
  5. Click the Save button.

You’ve created a new origin, but it isn’t active in your application yet. You need to define what will trigger a request to the new origin.

  1. Navigate to the Rules Engine tab.
  2. Click the Add Rule button and select Request Phase.
  3. Under the Criteria section, select the variable ${uri}.
  1. As a comparison operator, select is equal.
  2. As an argument, add /httpbin.
  3. In the Behaviors section, select Set Origin from the behavior list.
  4. Select the new origin you created.
  5. Click the Save button.
  6. Wait a few minutes for the changes to propagate and access xxxxxxxxxx.map.azionedge.net/httpbin.

  1. Run the following POST request in your terminal, replacing [TOKEN VALUE] with your personal token and the <edge_application_id> variable with your edge application ID:
Terminal window
curl --location 'https://api.azionapi.net/edge_applications/<edge_application_id>/origins' \
--header 'Accept: application/json; version=3' \
--header 'Content-Type: application/json' \
--header 'Authorization: Token [TOKEN VALUE]' \
--data '{
"name": "httpbin.org SO HTTPS Host:customhost.com",
"origin_type": "single_origin",
"addresses": [
{
"address": "httpbin.org"
}
],
"origin_protocol_policy": "https",
"host_header": "customhost.com"
}'
KeyDescription
nameSets the string in value as a name of the origin.
origin_typeSets the new origin type to single_origin. For more information on load balancing, check Work with multiple origins.
addressesTakes a list of objects for each address of the origin. Since this is an entry of the single origin type, you may only send one object with the address value in the array.
origin_protocol_policyWhen https, enforces an HTTPS connection with the origin, not affecting the protocol from user requests.
host_headerSets the string in value as the value of the Host header sent to the origin.
  1. You’ll receive a response similar to this:
{
"results": {
"origin_id": <origin_id>,
"origin_key": <origin_key>,
"name": "httpbin.org SO HTTPS Host:customhost.com",
"origin_type": "single_origin",
"addresses": [
{
"address": "httpbin.org",
"weight": null,
"server_role": "primary",
"is_active": true
}
],
"origin_protocol_policy": "https",
"is_origin_redirection_enabled": false,
"host_header": "customhost.com",
"method": "",
"origin_path": "",
"connection_timeout": 60,
"timeout_between_bytes": 120,
"hmac_authentication": false,
"hmac_region_name": "",
"hmac_access_key": "",
"hmac_secret_key": ""
}
}
  1. Run the following POST request in your terminal, replacing [TOKEN VALUE] with your personal token, the <edge_application_id> variable with your edge application ID, and the <origin_id> variable with the origin ID from when you created a new origin via API:
Terminal window
curl --location 'https://api.azionapi.net/edge_applications/<edge_application_id>/rules_engine/request/rules' \
--header 'Accept: application/json; version=3' \
--header 'Content-Type: application/json' \
--header 'Authorization: Token [TOKEN VALUE]' \
--data '{
"name": "Set httpbin /httpbin",
"behaviors": [
{
"name": "set_origin",
"target": "<origin_id>"
}
],
"criteria": [
[
{
"variable": "${uri}",
"operator": "is_equal",
"conditional": "if",
"input_value": "/httpbin"
}
]
]
}'
  1. You’ll receive a response confirming that the rule was created.
  2. Wait a few minutes for the changes to propagate and access xxxxxxxxxx.map.azionedge.net/httpbin. Also, try accessing any other unconfigured URI: you should receive a 404 error.

Contributors