A simple URL shortener written in Java. Create shortened links, store them in Redis, and redirect visitors to the original URLs.
Only authenticated admins can create or delete short links.
Note
You need JDK 25+ to build this project. The bundled Gradle wrapper provides Gradle 9.5,
so no separate Gradle installation is required — just run ./gradlew.
A running Redis instance is required. Start one with:
docker run -p 6379:6379 redis:alpineThen start the application. The admin password must be supplied via SHORTY_ADMIN_PASSWORD —
there is no default and the application will not start without it:
SHORTY_ADMIN_PASSWORD=change-me ./gradlew bootRunOpen http://localhost:8080 and log in as an admin.
The admin username (SHORTY_ADMIN, default admin) and password (SHORTY_ADMIN_PASSWORD, required)
are configured via environment variables. The password is stored hashed (BCrypt), never in plain text.
In the admin menu you can add new short links. Redirect to the original URL by visiting:
http://localhost:8080/<your-short-link>
Important
Open redirect by design. A URL shortener forwards visitors to whatever destination an
admin stored, so any short link is an open redirect to an arbitrary site. Destinations are
constrained to the http/https schemes — javascript:, data:, file: and the like are
rejected both when a link is created and again before each redirect — but the target host
itself is not restricted. Only trusted admins can create links.
We automatically build a Docker image for Shorty.
docker pull ghcr.io/n2o/url-shortener:latestBrowse available versions on the GitHub Container Registry.
Tip
Copy skeleton.env to production.env and adjust the values before starting.
Use Docker Compose for a production setup:
docker compose upThis starts a Redis server with persistent storage and exposes the application on port 8080.
- Write in English
- Open an Issue and assign yourself before working on it
- Create Pull Requests
- Read and follow the Code of Conduct
