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 objects take part, and each one links to the next:
- The connector holds your error page at a path. It already exists. For more information, refer to Connectors.
- The custom page set binds status code
404to that path on the connector. - The deployment of the workload names the set, next to the application it already names.
- The request reaches a path that the application’s connector answers with
404, and the set replaces that answer.
A set changes nothing until a deployment names it. When the application’s connector answers 404, the visitor receives the content of your page in place, with no redirect, and with the status code the page sets. This guide covers Azion Console and the API, and you assign the set in Azion Console. The Azion CLI cannot change a deployment that already exists, and the published API v4 reference has no endpoint for one.
Prerequisites
Console
- A workload whose deployment names an application. To create one, refer to Workloads quickstart.
- A path that your application’s connector answers with
404, such as a page that does not exist. - A connector that serves 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. Each page binds one status code to a path on a connector, and it can answer with a status code of its own. The set in this stage keeps the page in cache for 0 seconds 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 Create Custom Page Code.
In Page Code, select 404.
In Type, keep Page Connector.
In Connector, select the connector that serves your error page.
In Page Path (URI), enter the path at which the connector serves your page, 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
The deployment of a workload names the application, the firewall, and the custom page set that serve its traffic. A workload holds one deployment, so you assign the set by editing that deployment. The application it already names 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 deployment of the workload names your 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 your application’s connector 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. For more information, refer to Propagation.
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 your connector serves at the page’s path. When that document is an HTML page, the response reads:
The response carries no Location header, so the client is not redirected. Your workload answers a missing path with your own page.