I hacked together DSLF today because paying a monthly fee for a plain 301 felt silly. It’s a tiny Rust service that reads a CSV and spits out redirects—nothing more.
In the process I learned that HTTP has two “new” redirect codes that slipped past me years ago.
Four ways to say “go over there”
Old code | New code | Keeps the HTTP method? |
---|---|---|
301 | 308 | Yes |
302 | 307 | Yes |
301 and 302 can turn a POST into a GET. 307 and 308 guarantee the original method sticks. Neat.
DSLF defaults to the classic pair, but you can switch to the modern ones with a single flag.
./dslf --modern
Quick start
-
Drop your links in
redirects.csv
:url,target,status /gh,https://github.com/vpetersson,301 /blog,https://vpetersson.com,301
-
Run the binary:
./dslf
It listens on
0.0.0.0:3000
. -
Or run it in Docker:
docker run -p 3000:3000 \ -v $(pwd)/redirects.csv:/redirects.csv \ vpetersson/dslf --modern
(
dslf
is already the entrypoint, so just pass the flag.)
Cheap hosting on Fly.io
Fly’s smallest instance plus their free credit is often enough for a personal short-link service.
Point fly.toml
at vpetersson/dslf
, hit fly deploy
, and you’re live for pennies—or free if your traffic is tiny.
What I haven’t done yet
- Load testing – numbers will come later once I point k6 at it.
- Click counts – might add an optional flag, but only if it stays lightweight.
Grab the code:
git clone https://github.com/vpetersson/dslf
If you need a no-nonsense, self-hosted link shortener—and want to use those shiny 307/308 codes—give DSLF a spin and tell me what you think.
Enjoyed this post? Check out my podcast!
If you found this interesting, you might enjoy "Nerding Out with Viktor" - my podcast where I dive deep into tech, entrepreneurship, and security with industry experts.