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.
Prerequisites
Console
- 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.
Console
To create the connector in Azion Console:
Access Azion Console > Connectors.
The Create Connector page opens.
In General, enter my-connector as the Name.
In Connector Type, select HTTP.
Under Address Management, enter httpbin.org in Address, without a protocol or a port.
In Host, enter httpbin.org.
In Transport Protocol Policy, select Force HTTPS.
The connector exists in your account, and the rule you add to your application selects it.
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.
Console
To create the rule in Azion Console:
Access Azion Console > Applications, and select the application from the Applications quickstart.
In General, enter send-path-to-connector as the Name.
In Phase, select Request Phase. A rule’s phase cannot change after you create the rule.
Under Criteria, select the variable ${uri} and the operator starts_with, and enter /anything as the argument.
Under Behaviors, select Set Connector.
In Connector, select my-connector, the connector you created for the second origin.
The rule appears in the Rules Engine tab, under the Request heading.
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.