No description
  • Go 95.6%
  • Dockerfile 4.4%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
2026-09-23 09:43:12 +00:00
.env.example Separated sources and compose file. Created examples 2026-09-22 12:25:27 +00:00
.gitignore Added redirector executable to gitignore 2026-09-22 14:48:34 +00:00
db.go Separated server logic in a dedicated file and added links listing logic 2026-09-23 09:43:12 +00:00
docker-compose.yml.example Added domain default and proper data volume location 2026-09-22 14:48:55 +00:00
Dockerfile Separated sources and compose file. Created examples 2026-09-22 12:25:27 +00:00
go.mod Transitioned to an sqlite database 2026-09-22 14:47:09 +00:00
go.sum Transitioned to an sqlite database 2026-09-22 14:47:09 +00:00
main.go Separated server logic in a dedicated file and added links listing logic 2026-09-23 09:43:12 +00:00
README.md Separated server logic in a dedicated file and added links listing logic 2026-09-23 09:43:12 +00:00
server.go Separated server logic in a dedicated file and added links listing logic 2026-09-23 09:43:12 +00:00
store.go Separated server logic in a dedicated file and added links listing logic 2026-09-23 09:43:12 +00:00

Redirector

Little containerized tool that enables you to conceal specific services of your choice between an undiscoverable random URL, with programmable expiry time. More features to come when I get some time

Data directory (rootless Docker)

Docker runs rootless here, so container UIDs don't match host UIDs. The nonroot user inside the container is UID 65532, which maps to a different UID on the host — currently 165531.

Setup:

sudo mkdir -p /srv/redirector-data
sudo chown 165531:165531 /srv/redirector-data
sudo chmod 700 /srv/redirector-data

compose:

volumes:
  - /srv/redirector-data:/data

If it stops working (UID changed after a Docker reinstall/upgrade), find the new mapping:

docker run -d --name uidtest alpine sleep 30
docker inspect uidtest --format '{{.State.Pid}}'
cat /proc/<pid>/uid_map
docker rm -f uidtest

Admin token creation

To use this app, you need to have generated an admin token and inserted it in a .env file. The following command gives you a random string to create an admin token:

openssl rand -hex 32

Or using python:

python3 -c "import secrets; print(secrets.token_hex(32))"

Redirection creation

The following is the template of a base request to setup a redirection, inputting the admin token, the target and the time to live, which returns the date and time of expiry, the slug and the full URL

Expiry time is in hours, 10 days (default) = 240 hours

curl -X POST \
  -H "X-Admin-Token: YOUR_ADMIN_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"target": "https://example.com", "ttl_hours" : "240"}' \
  http://localhost:5000/admin/new
curl http://localhost:5000/admin/links \
  -H "X-Admin-Token: $ADMIN_TOKEN"