Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/esnunes/redirecterrors
Redirect Errors Middleware
https://github.com/esnunes/redirecterrors
traefik traefik-plugin
Last synced: about 2 months ago
JSON representation
Redirect Errors Middleware
- Host: GitHub
- URL: https://github.com/esnunes/redirecterrors
- Owner: esnunes
- Created: 2024-03-07T16:57:08.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2024-03-08T05:19:24.000Z (11 months ago)
- Last Synced: 2024-06-21T14:18:19.618Z (7 months ago)
- Topics: traefik, traefik-plugin
- Language: Go
- Homepage:
- Size: 5.86 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# Redirect On Errors
A [Traefik](https://traefik.io) middleware plugin to redirect to another URL on specific HTTP statuses.
Similar to the built-in `Errors` middleware, but this generates a HTTP 302 redirect, instead of an internal proxy action.
It was created to make `ForwardAuth` easier to use.
### Example Configuration
Example configuration with `ForwardAuth`:
```yaml
# Static configurationexperimental:
plugins:
redirectErrors:
moduleName: github.com/esnunes/redirecterrors
version: v0.1.0
``````yaml
# Dynamic configurationhttp:
routers:
secured-router:
rule: host(`secured.localhost`)
service: service-secured
middlewares:
- auth-redirect
auth-router:
rule: host(`auth.localhost`)
service: service-auth
middlewares:
- my-pluginservices:
service-secured:
loadBalancer:
servers:
- url: http://localhost:5001/
service-auth:
loadBalancer:
servers:
- url: http://localhost:5002/middlewares:
auth-redirect-error:
plugin:
redirectErrors:
status:
- "401"
target: "http://auth.localhost/oauth2/sign_in?rd={url}"
outputStatus: 302
auth-check:
forwardAuth:
address: "http://localhost:5002/oauth2/auth"
trustForwardHeader: true
auth-redirect:
chain:
- auth-redirect-error
- auth-check
```### Configuration Options:
- `status`: list of statuses / status ranges (eg `401-403`). See the [Error middleware's description](https://doc.traefik.io/traefik/middlewares/http/errorpages/#status) for details.
- `target`: redirect target URL. `{status}` will be replaced with the original HTTP status code, and `{url}` will be replaced with the url-safe version of the original, full URL.
- `outputStatus`: HTTP code for the redirect. Default is 302.