Connectors quickstart
Create a connector to a second origin, send one path of your application to it with a rule, and check the response through your workload.
This guide instructs you through sending your first path to a second origin with a connector.
- Create a connector of type
httpthat reaches a second origin over HTTPS and sends that origin’s ownHostheader. - Add a rule that points one path of your application at the connector with the Set Connector behavior.
- Request that path through your workload and get the answer of the second origin.
Four parts make the chain, listed in the order this guide uses them:
- The connector holds the address of the second origin, the
Hostheader it sends, and the protocol it uses to connect. - The rule on your application matches one path in the request phase. Its Set Connector behavior names the connector.
- The workload that already serves your application receives the request. Its deployment needs no change.
- The request for that path meets the rule, and the connector sends it to the second origin. Every other path still reaches the origin of your first connector.
A connector receives no traffic until a rule names it. This guide uses httpbin.org as the second origin, a public service that answers every request under /anything with a JSON copy of the request it received. The response you verify at the end therefore shows what the connector sent. To use your own origin, replace httpbin.org with its hostname, and /anything with its path, such as /api/.
The connector this guide leaves you with is where the Products of Connectors start. Load Balancer spreads requests across up to 15 addresses of one connector. Origin Shield protects the origin with an Origin IP ACL and HMAC signing. Live Ingest takes a live stream in through a connector of type live_ingest.
The prerequisites and the three stages show the steps of one interface at a time. Select yours:
Prerequisites
- An application served by a workload, with a rule that sends every request to a first connector. To create all three, refer to Applications quickstart.
- The workload domain of that workload, of the form
<id>.map.azionedge.net. This guide writes it as<workload-domain>. curl, to request the path through your workload.
- Access to Azion Console.
Create a connector to your second origin
A connector of type http holds the address of an origin and the settings Azion uses to reach it. You create it on its own, outside any application. This connector has one address, httpbin.org, and connects to it over HTTPS only.
The Host header tells the origin which site a request is for. By default, a connector sends the host the client requested, which is your workload domain. This connector sends httpbin.org instead, so the origin receives its own name. For more information, refer to Host header.
The connector keeps the path of each request as the client sent it. To add a directory of the origin in front of every path, refer to Path prefix. To serve the objects of a bucket instead of an HTTP origin, refer to Use a bucket as an application origin.
To create the connector with the Azion CLI, put it in a JSON file first. Save this body as connector.json:
addresses lists the origin servers, and connection_options.host is the Host header the connector sends. force_https makes every connection to the origin use HTTPS.
Create the connector from the file. The command needs --type even though the file names the type:
The output carries the ID of the new connector:
Read the connector back in JSON. Replace <connector-id> with the ID from the previous command:
This excerpt of the output shows the connection options, with a value for every option the file left out:
path_prefix is empty, so the path reaches the origin unchanged. Record the id: the rule passes it as <connector-id>. The connector exists in your account.
Send a path to the connector
A rule in Rules Engine for Applications pairs criteria with behaviors. This rule runs in the request phase of your application. Its criterion, ${uri} starting with /anything, matches every request under that path. Its behavior, Set Connector, sends each matching request to the new connector. For more information, refer to Set Connector.
The rule from the Applications quickstart matches every path, /anything included. When several matching rules carry Set Connector, only the last one runs. Keep this rule after the catch-all rule, so it decides the connector for /anything. In the API, a new rule goes after the rules the application already has: the second rule of an application is stored with order set to 1.
To create the rule with the Azion CLI, keep the rule in a file: on a command line, the shell would expand ${uri}. Save this body as rule.json, and replace <connector-id> with the ID of the new connector:
Create the rule in the request phase of your application. Replace <application-id> with the ID of your application:
The output carries the ID of the new rule:
The rule is active on your application, and it sends every request under /anything to the connector.
Verify the response
The check is the same whichever interface created the connector and the rule. In the command, replace <workload-domain> with the workload domain of your workload.
A new connector and a new rule take several minutes to reach Azion’s distributed infrastructure, and data centers apply them at different times. Until then, a request for /anything can still reach the origin of your first connector. Repeat the request until the second origin answers. For more information, refer to Propagation.
Send a request for the path the rule matches:
httpbin.org answers with a JSON copy of the request it received. This excerpt keeps the Host header and the URL:
Host is httpbin.org, the value the connector sends, not your workload domain. url shows that the path reached the origin unchanged. A request for any other path, such as /, still reaches the origin of your first connector. Your application sends one path to a second origin through its own connector.