- Go 95.6%
- Dockerfile 4.4%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
| .env.example | ||
| .gitignore | ||
| db.go | ||
| docker-compose.yml.example | ||
| Dockerfile | ||
| go.mod | ||
| go.sum | ||
| main.go | ||
| README.md | ||
| server.go | ||
| store.go | ||
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
Links listing
curl http://localhost:5000/admin/links \
-H "X-Admin-Token: $ADMIN_TOKEN"