Can I show a custom page for 503/502/504 errors generated by TR7 itself?
Short answer
Yes, on the HTTP vService. In the Show Content for Traffic Manager Errors action, codes such as 502, 503 and 504 are selected from the Error Codes list; when TR7 produces these errors, it shows the selected Content Page with the selected Status Code instead of its default page. Status code comes as 200 by default and is applied to all the codes in the action; if each error is to return with its own code, a separate action is added for each code. Redirect for Traffic Manager Errors is used to send the user to an address outside TR7. These actions cover the responses produced by TR7 itself, such as the Backend Service being unreachable, timeouts and bad requests.
Problem: TR7's Error Page Does Not Match the Corporate Look
When the Backend Services cannot be reached, when the response times out or when the request is bad, TR7 produces the response and shows its own default error page. This page is replaced with a page that matches the design of the organization and tells the user what to do.
| Code | When TR7 produces it |
|---|---|
| 503 Service Unavailable | When no usable Backend Service remains in the vService (all unhealthy or in Maintenance mode) |
| 502 Bad Gateway | When the Backend Service closes the connection or returns an invalid response |
| 504 Gateway Timeout | When the Backend Service response does not arrive within the timeout period |
| 400, 408, 429 | Bad request, request timeout, request limit exceeded |
Solution: Two Methods
Neither action takes a condition, and both take effect only on the selected errors produced by TR7 itself; since they do not affect normal traffic, they can stay on the vService permanently. For the errors returned by the Backend Service itself: Can I show a custom error page when the backend returns 404 or 500?
| Your situation | Suitable method |
|---|---|
| A custom page on TR7's errors | Method 1: Show Content for Traffic Manager Errors |
| Sending to an address outside TR7 on TR7's errors | Method 2: Redirect for Traffic Manager Errors |
Method 1: Show Content for Traffic Manager Errors Recommended
- How it works On the selected error codes produced by TR7, the selected content page is shown instead of the default page, with the Status code value of the action.
- Where it is openedLoad Balancer → Actions → Show Content for Traffic Manager Errors
- Requirement The error page is in Content Pages; the styles and images of the page are embedded in the page (the Backend Service cannot be reached at the time of the error)
- vService type HTTP
Step-by-Step Configuration
Load Balancer → Profiles → Content Pages → Add is clicked (how to add).
Content Page Name, Content Type (default text/html) and Content are entered; if desired, one of the ready page templates is copied. For Turkish characters, <meta charset="utf-8"> is written in the page.
Add is clicked.
Load Balancer → Actions → Add is clicked (how to add).
Action Name is entered, and Action Type = Show content for traffic manager errors is selected. Error Codes = 503; Content Page = the page from step 3 (its default is Access Denied Page (English)); Status Code = 503 (default 200).
Add is clicked.
Steps 4–6 are repeated with Error Codes = 502, Status Code = 502 and Error Codes = 504, Status Code = 504. If the codes do not need to be kept separate, the three codes are selected together in a single action; then all three return with the same Status code.
On the Load Balancer → Load Balancer vService List screen, the HTTP vService is selected and Edit is clicked.
Save is clicked. The change is applied without dropping open connections; in a cluster, it is also sent to the peer device with the default auto-sync (if Manual Sync Mode is on, with Synchronize).
Verification
On the test vService, all the Backend Services are put into Maintenance mode and curl -i https://www.example.com/ is sent.
HTTP/1.1 503 + custom pageOn the HTTP Logs screen, the request appears with the 503 status code.
Status code 503Method 2: Redirect for Traffic Manager Errors
- How it works On the selected errors produced by TR7, the client is redirected to a fixed address with 302.
- Where it is openedLoad Balancer → Actions → Redirect for Traffic Manager Errors
- Requirement A target address outside TR7, not bound to the same vService
- vService type HTTP
Step-by-Step Configuration
Load Balancer → Actions → Add is clicked.
Action Name is entered, and Action Type = Redirect for traffic manager errors is selected. Error Codes = 502, 503, 504; Redirect Location = https://durum.example.com/ (which errors fall to this action).
Add is clicked.
On the Load Balancer → Load Balancer vService List screen, the HTTP vService is selected and Edit is clicked.
The action is selected in the Details → Actions field.
Save is clicked.
Verification
While the Backend Services are in maintenance, curl -sI https://www.example.com/
302 + Location: https://durum.example.com/Common Mistakes
The Status code default is 200
If Status code is not changed, the error page goes out with the 200 code; monitoring tools and search engines do not notice the error. Since Status code is applied to all the Error codes in the action, if each code is to return with its own value, a separate action is added for each code.
- Expecting this action to handle the 500 returned by the Backend Service. The errors returned from the server are within the scope of the Show Content for Backend Service Errors and Redirect for Backend Service Errors actions (Can I show a custom error page when the backend returns 404 or 500?).
- Saving without selecting any code. While Error codes is empty, the action does nothing, and no warning is given.
- Expecting the WAF, CAPTCHA, quarantine and waiting room pages to change as well. These pages are managed with the content pages in their own profiles.
- Pulling the styles and images of the page from the Backend Service. Since the Backend Service cannot be reached at the time of the error, the page looks bare; the content is embedded in the page.
- Hosting the redirect target on the same vService. The target also gives the same error, and the user enters a loop.
How it is done in the documentation
