An easy to use http redirect server configurable using only environment variables.
This small server is available as a docker image from ghcr.io.
docker pull ghcr.io/egidiusmengelberg/http-redirect:latestThe server is configured using environment variables. This makes it easy to deploy on kubernetes or docker compose.
PORT=1234 # default is 3000
DEBUG=true # default is false (logs redirects)
DEFAULT_REDIRECT_URL="https://google.com"
DEFAULT_REDIRECT_CODE=302
REDIRECT_EXAMPLE_COM_URL="https://something.io"
REDIRECT_EXAMPLE_COM_CODE=301
REDIRECT_EXAMPLE_COM_KEEP_PATH=true
REDIRECT_SUB_EXAMPLE_COM_URL="https://hello.io"
REDIRECT_SUB_EXAMPLE_COM_CODE=302
REDIRECT_SUB_EXAMPLE_COM_KEEP_PATH=false
The env above results in the following:
| From | To | Code | Keep Path |
|---|---|---|---|
| example.com | https://something.io | 301 | true |
| sub.example.com | https://hello.io | 302 | false |
| * | https://google.com | 302 | false |
Note
It's not possible to keep the path on the default redirect.
To install dependencies:
bun installTo run:
bun run startDuring development run:
bun run devDuring development you can add a .env file to easily manage your environment variables