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