Custom Pages quickstart
Create a custom page set that replaces your origin's 404 with a page of your own, assign it in the Workload's deployment, and see it served.
This guide instructs you through replacing the 404 your origin returns with your first page from Custom Pages.
- Create a custom page set with one page for status code
404. - Assign the set in the deployment of your Workload.
- Request a path your origin does not have and get your own page in its place.
Four elements take part, and each one leads to the next:
- Your error page is at a path on the Connector. The Connector already exists. For more information, refer to Connectors.
- The custom page set holds a page that replaces status code
404with the content at that path on the Connector. - The deployment of the Workload sets the custom page set, next to the Application it already sets.
- The request reaches a path that the Connector your Application uses answers with
404, and the custom page set replaces that response.
A Workload uses a custom page set only once that Workload’s deployment sets that custom page set. Then, when the Connector your Application uses answers 404, the client receives the content of your page in place of that response. The response carries no redirect, and its status code is the one the page sets.
This guide covers Azion Console and the API, and you assign the set in Azion Console. The Azion CLI has no command that updates a deployment, and the published API v4 reference has no endpoint for one.
Prerequisites
Console
- A Workload with a deployment that sets an Application. To create one, refer to Workloads quickstart.
- A path that the Connector your Application uses answers with
404, such as a page that does not exist on your origin. - A Connector with your error page at a path. To create one, refer to Connectors.
- Access to Azion Console. To sign in, refer to How to access Azion Console.
Create the custom page set
A custom page set is a named list of pages, and it needs at least one page. Each page replaces one status code with the content at a path on a Connector, and it can answer with a status code of its own. The page in this stage stays in cache for 0 seconds, its time to live (TTL), and answers with 404.
Console
To create the set in Azion Console:
Access Azion Console > Custom Pages.
Select Create Custom Page. The Create Custom Page page opens.
In Name, enter a name for the set, such as my-custom-pages.
Select + Custom Page Code.
In Page Code, select 404.
In Type, keep Page Connector.
In Connector, select the Connector with your error page.
In Page Path (URI), enter the path of your page on the Connector, such as /html.
In Response TTL, enter 0.
In Response Custom Status Code, enter 404.
The set exists with one page for code 404. It serves nothing until you assign it to your Workload. A set with no page code is refused with the message “You must have at least one custom page code”.
Assign the set to your Workload
A Workload’s deployment sets the Application that answers its requests, and it can also set a Firewall and a custom page set. A Workload holds at most one deployment, so you assign the custom page set by editing that deployment. The Application that the deployment already sets stays in place.
Console
To assign the set in Azion Console:
Access Azion Console > Workloads.
Select your Workload. The Edit Workload page opens.
In Deployment Settings, select your set in Custom Page. Keep Application as it is.
Azion Console shows the message “Your workload has been updated”. The Workload’s deployment sets your custom page set.
Request a page your origin answers with 404
The check is the same whichever interface assigned the set. In the command, replace <your-workload-domain> with the workload domain of your Workload, of the form <id>.map.azionedge.net. Replace <missing-path> with the path that the Connector your Application uses answers with 404.
An assigned set does not serve at once. The change to the deployment spreads across Azion’s distributed infrastructure, and that takes several minutes, with no guaranteed duration. While it spreads, a request can receive either your origin’s 404 or your page. Repeat the request until your page answers, as Propagation explains.
Send a request to the missing path and print the response headers with the body:
The response keeps status 404, from the page’s custom_status_code. Its body is the document at the page’s path on your Connector. When that document is an HTML page, the response starts like this example, with your document as the body:
The response carries no Location header, so the client is not redirected. Your Workload answers a missing path with your own page.