Customize an error page
Replace the error responses of a workload with your own pages, one per status code, each with its own cache time and response status code.
You can replace the error responses of a workload with pages of your own, for several status codes at once, from Azion Console, the Azion CLI, or the API. To create your first set with one page and see it replace a 404, refer to Custom Pages quickstart.
With Custom Pages, the pages live in a custom page set. Each page answers one status code that the application’s connector returns, and the set serves pages only after the workload’s deployment names it.
An application that runs on API v3 sets its error pages in Error Responses instead. For more information, refer to Error Responses.
Select an interface. The prerequisites and the steps of each task follow your choice.
Prerequisites
- A workload and an application for it to serve. To create both, refer to Workloads quickstart.
- A connector that serves your error page documents, each at its own path. For more information, refer to Connectors.
- Access to Azion Console. For more information, refer to How to access Azion Console.
- A workload whose deployment names the application.
Create a set with a page for each code
Each page in the set takes its own status code, connector path, cache time, and response status code. A page can also answer with a code other than the one the connector returned, such as a 404 in place of a 403. Azion serves the page in place, with no redirect. After you change a page’s document, Azion keeps serving the cached copy until its cache time runs out. For the codes a page accepts and the range of each field, refer to Custom page settings.
To create the set with the Azion CLI, save a JSON file with one entry in pages per status code, here as pages.json. This set answers a 404 with the page at /errors/404.html, and answers a 403 with the same page and status 404:
Create the set from the file:
The command prints the ID of the new set. The deployment needs it in the next task:
A file whose pages list is empty is refused with Ensure this field has at least 1 elements.
Assign the set in the workload’s deployment
The deployment of a workload names its application, its firewall, and its custom page set. Only the custom page set changes here, so the application and the firewall keep the values the workload uses today.
To assign the set with the Azion CLI, create the workload’s deployment with the set in --custom-page:
The command prints the ID of the new deployment:
If the workload uses a firewall, add --firewall-id <firewall-id> to the command. On a workload that already has a deployment, the command fails with The maximum number of deployments allowed per workload is 1. Azion CLI 4.23.0 has no command that changes a deployment, so assign the set to that workload in Azion Console or with the API.
Confirm that a page replaces the error
The check is the same for every interface. A change to a workload’s deployment takes several minutes to reach all of Azion’s distributed infrastructure, and requests can receive the previous or the updated configuration meanwhile. Repeat a request until the answers agree.
Request a path for which your connector returns a status code the set covers. Replace <your-domain> with a domain the workload serves, such as its workload domain of the form <id>.map.azionedge.net:
For a page whose response status code is 404, the response starts with this status line, followed by the headers your connector sends and the document at the page’s path:
The response carries no Location header, so the client stays on the requested URL and is not redirected. If the connector’s own error response still arrives after the deployment change has spread, refer to Troubleshoot Workloads.