Set the Host header and path prefix for an origin
Choose the Host header a connector sends and the path it prepends, so the origin serves the right site and directory.
You can set the Host header a connector sends to its origin, and a path it prepends to every request, from Azion Console, the Azion CLI, or the API. Both settings apply to a connector of type http. The examples use httpbin.org as the origin, because it answers with the request it received, so each setting shows in its response. Replace it with the host name of your origin.
Prerequisites
Console
- A connector of type
http, and a workload whose application points a rule at the connector with theSet Connectorbehavior. To create both, refer to Connectors quickstart. - The workload domain, or a domain of your own, that the workload answers on.
- Access to Azion Console.
Send the origin’s own host name
By default, host is ${host}, which sends the host the client requested. Keep the default for an origin that serves several virtual hosts and reads each request under its public name. Set a literal value when the origin answers only under its own name. The connector then sends that name for every request.
Console
To set the host name in Azion Console:
Access Azion Console > Connectors, then select your connector.
In Host, enter httpbin.org.
Azion Console shows Connector has been updated. The Console refuses a value that is not a host name, an IP address, or a variable, with Host must be a valid hostname, IP address, or variable.
To send the client’s host again, set the value back to ${host}.
Prepend a path
The path goes in front of the path the client requested, so the origin serves content from one of its directories. With /anything, a request for /get reaches the origin as /anything/get. With /secure, a request for https://<your-domain>/index.html reaches the origin as /secure/index.html. The prefix never appears in the client’s URL. The value starts with /, and the default is no prefix.
For a bucket of Object Storage, a connector of type storage carries its own prefix instead. For more information, refer to Connector settings.
Console
To set the path in Azion Console:
Access Azion Console > Connectors, then select your connector.
In Path, enter /anything.
Azion Console shows Connector has been updated. A path without the leading slash is refused with Path must start with a forward slash (/).
Verify what the origin receives
A connector change needs no new deployment. It reaches traffic over several minutes, and each data center applies it at its own moment. For more information, refer to How Connectors works.
To see the request the origin received, send a request through your workload. Replace <workload-domain> with the workload domain or your own domain:
httpbin.org answers with the request it received, as JSON. Two fields show the connector’s settings: headers.Host is the Host header, and url carries the path the origin received. With host at ${host} and the path prefix /anything, the response reads:
url carries /anything/get, so the connector prepends the path prefix. headers.Host carries the workload domain, the host the client requested. With host at httpbin.org, headers.Host reads httpbin.org instead. Send the request several times: an answer with the previous values comes from a data center that has not applied the change yet.