2019-02-26 05:50:07 -08:00
# ErrorPage
It Has Never Been Easier to Say That Something Went Wrong
{: .subtitle }
2021-06-11 15:30:05 +02:00
![ErrorPages ](../../assets/img/middleware/errorpages.png )
2019-02-26 05:50:07 -08:00
The ErrorPage middleware returns a custom page in lieu of the default, according to configured ranges of HTTP Status codes.
!!! important
2021-09-27 17:40:13 +02:00
2019-02-26 05:50:07 -08:00
The error page itself is _not_ hosted by Traefik.
## Configuration Examples
2019-03-29 12:34:05 +01:00
```yaml tab="Docker"
# Dynamic Custom Error Page for 5XX Status Code
labels:
2019-09-23 17:00:06 +02: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 12:34:05 +01:00
```
2019-04-03 14:32:04 +02:00
```yaml tab="Kubernetes"
apiVersion: traefik.containo.us/v1alpha1
kind: Middleware
metadata:
name: test-errorpage
spec:
errors:
status:
2020-12-16 15:20:04 +01:00
- "500-599"
2019-04-03 14:32:04 +02:00
query: /{status}.html
2019-09-10 17:24:03 +02:00
service:
name: whoami
port: 80
2019-04-03 14:32:04 +02:00
```
2019-10-15 18:34:08 +03:00
```yaml tab="Consul Catalog"
# Dynamic Custom Error Page for 5XX Status Code
- "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-15 18:22:07 +02: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 17:14:08 +02:00
```yaml tab="Rancher"
# Dynamic Custom Error Page for 5XX Status Code
labels:
2019-09-23 17:00:06 +02: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-04-08 17:14:08 +02:00
```
2019-07-22 09:58:04 +02:00
```yaml tab="File (YAML)"
# Custom Error Page for 5XX
http:
middlewares:
test-errorpage:
errors:
status:
2019-09-23 17:00:06 +02:00
- "500-599"
2019-07-22 09:58:04 +02:00
service: serviceError
query: "/{status}.html"
2021-06-19 00:08:08 +02:00
services:
# ... definition of error-handler-service and my-service
```
```toml tab="File (TOML)"
# Custom Error Page for 5XX
[http.middlewares]
[http.middlewares.test-errorpage.errors]
status = ["500-599"]
service = "serviceError"
query = "/{status}.html"
2019-07-22 09:58:04 +02:00
[http.services]
# ... definition of error-handler-service and my-service
```
2021-02-11 14:34:04 +01:00
!!! note ""
2019-09-03 18:02:05 +02:00
In this example, the error page URL is based on the status code (`query=/{status}.html` ).
2019-02-26 05:50:07 -08:00
## Configuration Options
2019-04-03 14:32:04 +02:00
### `status`
2019-02-26 05:50:07 -08:00
2021-02-11 14:34:04 +01:00
The `status` option defines which status or range of statuses should result in an error page.
2019-02-26 05:50:07 -08:00
The status code ranges are inclusive (`500-599` will trigger with every code between `500` and `599` , `500` and `599` included).
2021-02-11 14:34:04 +01:00
!!! note ""
2021-06-08 19:02:05 +02:00
You can define either a status code as a number (`500` ),
as multiple comma-separated numbers (`500,502` ),
as ranges by separating two codes with a dash (`500-599` ),
or a combination of the two (`404,418,500-599` ).
2019-02-26 05:50:07 -08:00
2019-04-03 14:32:04 +02:00
### `service`
2019-02-26 05:50:07 -08:00
The service that will serve the new requested error page.
2021-02-11 14:34:04 +01:00
!!! note ""
In Kubernetes, you need to reference a Kubernetes Service instead of a Traefik service.
2019-09-10 17:24:03 +02:00
2021-09-27 17:40:13 +02:00
!!! info "Host Header"
By default, the client `Host` header value is forwarded to the configured error [service ](#service ).
To forward the `Host` value corresponding to the configured error service URL, the [passHostHeader ](../../../routing/services/#pass-host-header ) option must be set to `false` .
2019-04-03 14:32:04 +02:00
### `query`
2019-02-26 05:50:07 -08:00
2021-02-11 14:34:04 +01:00
The URL for the error page (hosted by `service` ). You can use the `{status}` variable in the `query` option in order to insert the status code in the URL.