2019-02-26 13:50:07 +00:00
|
|
|
# ErrorPage
|
|
|
|
|
|
|
|
It Has Never Been Easier to Say That Something Went Wrong
|
|
|
|
{: .subtitle }
|
|
|
|
|
|
|
|
![ErrorPages](../assets/img/middleware/errorpages.png)
|
|
|
|
|
|
|
|
The ErrorPage middleware returns a custom page in lieu of the default, according to configured ranges of HTTP Status codes.
|
|
|
|
|
|
|
|
!!! important
|
|
|
|
The error page itself is _not_ hosted by Traefik.
|
|
|
|
|
|
|
|
## Configuration Examples
|
|
|
|
|
2019-03-29 11:34:05 +00:00
|
|
|
```yaml tab="Docker"
|
|
|
|
# Dynamic Custom Error Page for 5XX Status Code
|
|
|
|
labels:
|
2019-04-01 15:56:04 +00:00
|
|
|
- "traefik.http.middlewares.test-errorpage.errors.status=500-599"
|
|
|
|
- "traefik.http.middlewares.test-errorpage.errors.service=serviceError"
|
|
|
|
- "traefik.http.middlewares.test-errorpage.errors.query=/{status}.html"
|
2019-03-29 11:34:05 +00:00
|
|
|
```
|
|
|
|
|
2019-04-03 12:32:04 +00:00
|
|
|
```yaml tab="Kubernetes"
|
|
|
|
apiVersion: traefik.containo.us/v1alpha1
|
|
|
|
kind: Middleware
|
|
|
|
metadata:
|
|
|
|
name: test-errorpage
|
|
|
|
spec:
|
|
|
|
errors:
|
|
|
|
status:
|
|
|
|
- 500-599
|
|
|
|
service: serviceError
|
|
|
|
query: /{status}.html
|
|
|
|
```
|
|
|
|
|
2019-04-15 16:22:07 +00:00
|
|
|
```json tab="Marathon"
|
|
|
|
"labels": {
|
|
|
|
"traefik.http.middlewares.test-errorpage.errors.status": "500-599",
|
|
|
|
"traefik.http.middlewares.test-errorpage.errors.service": "serviceError",
|
|
|
|
"traefik.http.middlewares.test-errorpage.errors.query": "/{status}.html"
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2019-04-08 15:14:08 +00:00
|
|
|
```yaml tab="Rancher"
|
|
|
|
# Dynamic Custom Error Page for 5XX Status Code
|
|
|
|
labels:
|
|
|
|
- "traefik.http.middlewares.test-errorpage.errors.status=500-599"
|
|
|
|
- "traefik.http.middlewares.test-errorpage.errors.service=serviceError"
|
|
|
|
- "traefik.http.middlewares.test-errorpage.errors.query=/{status}.html"
|
|
|
|
```
|
|
|
|
|
2019-07-22 07:58:04 +00:00
|
|
|
```toml tab="File (TOML)"
|
2019-03-29 11:34:05 +00:00
|
|
|
# Custom Error Page for 5XX
|
|
|
|
[http.middlewares]
|
2019-07-01 09:30:05 +00:00
|
|
|
[http.middlewares.test-errorpage.errors]
|
2019-03-29 11:34:05 +00:00
|
|
|
status = ["500-599"]
|
2019-04-03 12:32:04 +00:00
|
|
|
service = "serviceError"
|
|
|
|
query = "/{status}.html"
|
|
|
|
|
2019-03-29 11:34:05 +00:00
|
|
|
[http.services]
|
|
|
|
# ... definition of error-handler-service and my-service
|
|
|
|
```
|
|
|
|
|
2019-07-22 07:58:04 +00:00
|
|
|
```yaml tab="File (YAML)"
|
|
|
|
# Custom Error Page for 5XX
|
|
|
|
http:
|
|
|
|
middlewares:
|
|
|
|
test-errorpage:
|
|
|
|
errors:
|
|
|
|
status:
|
|
|
|
- "500-599"
|
|
|
|
service: serviceError
|
|
|
|
query: "/{status}.html"
|
|
|
|
|
|
|
|
[http.services]
|
|
|
|
# ... definition of error-handler-service and my-service
|
|
|
|
```
|
|
|
|
|
2019-03-29 11:34:05 +00:00
|
|
|
!!! note
|
2019-09-03 16:02:05 +00:00
|
|
|
In this example, the error page URL is based on the status code (`query=/{status}.html`).
|
2019-02-26 13:50:07 +00:00
|
|
|
|
|
|
|
## Configuration Options
|
|
|
|
|
2019-04-03 12:32:04 +00:00
|
|
|
### `status`
|
2019-02-26 13:50:07 +00:00
|
|
|
|
|
|
|
The `status` that will trigger the error page.
|
|
|
|
|
|
|
|
The status code ranges are inclusive (`500-599` will trigger with every code between `500` and `599`, `500` and `599` included).
|
|
|
|
|
|
|
|
!!! Note
|
|
|
|
|
|
|
|
You can define either a status code like `500` or ranges with a syntax like `500-599`.
|
|
|
|
|
2019-04-03 12:32:04 +00:00
|
|
|
### `service`
|
2019-02-26 13:50:07 +00:00
|
|
|
|
|
|
|
The service that will serve the new requested error page.
|
|
|
|
|
2019-04-03 12:32:04 +00:00
|
|
|
### `query`
|
2019-02-26 13:50:07 +00:00
|
|
|
|
|
|
|
The URL for the error page (hosted by `service`). You can use `{status}` in the query, that will be replaced by the received status code.
|