redirector/README.md
Nicola Zambello fb5c29eec8
All checks were successful
Docker CI / release (push) Successful in 37s
ci: remove git server and image tag
2024-05-21 22:22:20 +03:00

63 lines
1.4 KiB
Markdown

# Redirector
Simple redirection service.
Runs on [Bun](https://bun.sh) and uses [Hono](https://hono.dev).
Can be adapted to run on Node, Cloudflare Workers, or any other serverless platform.
Available as a [Docker image](https://hub.docker.com/r/nzambello/redirector).
Repository: [nzambello/redirector](https://code.nzambello.dev/nzambello/redirector).
## Usage
```sh
yarn install
REDIRECT_URL=https://nzambello.dev PERMANENT=true PRESERVE_PATH=false bun start
```
Then, open http://localhost:8787/ in your browser.
```sh
open http://localhost:8787
```
and you will be redirected to `REDIRECT_URL` from your env.
### Configuration
It loads configuration from environment variables:
- `REDIRECT_URL`: (**required**) the url to redirect to
- `PERMANENT`: if true, it will return a 301 status code, otherwise 302
- `PRESERVE_PATH`: if true, it will preserve the path of the original request
### Docker example
```sh
docker run -p 8787:8787 -e REDIRECT_URL=https://nzambello.dev -e PERMANENT=true -e PRESERVE_PATH=false nzambello/redirector:latest
```
### Docker compose example
```yaml
version: "3.8"
services:
redirector:
image: nzambello/redirector:latest
environment:
- REDIRECT_URL=https://nzambello.dev
- PERMANENT=true
- PRESERVE_PATH=false
ports:
- 8787:8787
```
## Development
To update the Docker image:
```sh
docker buildx build --platform linux/amd64,linux/arm64 -t nzambello/redirector:latest --push .
```