Categories
How It Is

Shlinky Dinks

For a number of reasons it was time to move on to new things. I was looking for a better, more modern solution to running my own short URLs.

There are a lot of reasons people want these. When I started with them, it was because Twitter had limits and I wanted to control my tweets and short URLs. But then time moved on, Twitter decided to meh, not care about URL length, which meant I didn’t really need the extra weight.

But I had a reason to keep mine around, and that’s WordCamps. 99.999% of the use of have for short URLs is to link people to things for WordCamps, like my slides but also related links that otherwise would be too long for anyone to write down in a reasonable time frame.

And while I’d been using the same old, functional, system, it had quirks that had long since frustrated me, including not being a modern design. I felt like I was stepping back into the early 2000s, and yes, that UX matters to me.

After experimenting around, I found Shlink.io, a GDPR (yes!) friendly self-hosted URL shortener that is a little more tech, but a lot more smooth. It has a full blown API, a deep command line, and an (optional) admin that is, well, nifty.

Features include:

  • Custom short URLs
  • Multiple Domains
  • QR Codes
  • Tags
  • Robust stats
  • Validates URLs before linking

It’s not a set-and-forget install, to be sure, and each server is going to have some quirks, but overall I’m happy with it already.

Top ↑

What’s Missing What’s Missing

There’s no WordPress plugin. Yet. I suspect this will happen once people realize the API is so freaking crazy.

There’s no way to import everything from another service, but I did a fast export of my DB and then grep’d and search/replaced so I could run commands like this:

php bin/cli short-url:generate -c SHORT https://example.com/

Done and done. Imported a few thousand URLs. I will note that most of those links don’t matter, since nearly no one hit them, but I’m just a stickler for old URLs continuing to work. Most of the time. I went back through all the failed import and found I had old links to things like test sites.

Also the admin backend is an add-on (or non-hosted but I’m neurotic). I installed the web client at a subdomain and then used the configurator to allow passwordless logins. No, I didn’t leave it unprotected! I went old school:

#Protect Directory
AuthName "Dialog prompt"
AuthType Basic
AuthUserFile /home/ipstenu/example.com/admin/.htpasswd
Require valid-user

SSLOptions +StrictRequire
SSLRequireSSL
SSLRequire %{HTTP_HOST} eq "sub.example.com"

ErrorDocument 403 https://example.com

<Files "servers.json">
  Order Allow,Deny
  Deny from all
</Files>

Top ↑

What Was Messy What Was Messy

The GeoLiteDB stuff was weird. It took me a while to realize I was running out of space in tmp and that was blocking me from doing anything. Since I host this VPS on DreamHost at the moment, and I work there, I went and set tmp to disk instead of memory and that magically worked.

Now. Would I like the admin stuff to be built in and easier to manage? Of course. And would I like ‘better’ security when I use the server.json file (like maybe telling people to protect it and hide their API keys, hey) but I’ve properly opened up a ticket for them on that one.

Top ↑

End Result? End Result?

I like it. So I’m using Shlinks now and there you go.