A self-hosted URL shortener: Shlink - A Docker Quick-Start Guide (lnk.clifmo.com)
from clifmo@programming.dev to selfhosted@lemmy.world on 09 Mar 17:50
https://programming.dev/post/26631209

A self-hosted URL shortener: Shlink - Keep control over all your shortened URLs, by serving them under your own domains, using this simple yet powerful tool. shlink.io

I was very surprised to find this mature, full-featured URL shortener. It’s written in PHP and includes Geoblocking so your shortener isn’t abused.

A Docker quick-start guide: lnk.clifmo.com/ljk13

#selfhosted

threaded - newest

TheRealCharlesEames@lemm.ee on 09 Mar 18:11 next collapse

Do you know if there is any way to use this in combination with Raycast?

clifmo@programming.dev on 09 Mar 19:23 collapse

I’m not a raycast user, but it has a CLI and REST API, so if Raycast has any extensibility, my guess is yes

TheRealCharlesEames@lemm.ee on 09 Mar 19:27 collapse

Oh snap now I just need to learn how to code

harsh3466@lemmy.ml on 09 Mar 18:35 next collapse

Another great option is Yourls. I’ve been using it for years and it’s been fabulous

clifmo@programming.dev on 09 Mar 19:22 collapse

I looked at yourls, too. I found Shlink devex to be more mature and the automated geolocation-blocking integration sold me.

It also hasn’t had a release in 2 years and is a self-described “set of PHP scripts”. Doesn’t fit my standard for what I deploy to my homelab

harsh3466@lemmy.ml on 09 Mar 19:24 collapse

Totally fair.

dan@lemmy.i.secretponi.es on 09 Mar 23:54 next collapse

This maybe isn’t for everyone but I de-dockerified Shlink pretty quickly. Moving it to two nginx vhosts (server and admin) on a Shlink LXC and a centralized Postgres server made dealing with it a lot easier.

E.g., the initial API key shenanigans were less fiddly after I took more direct control.

clifmo@programming.dev on 10 Mar 00:42 collapse

Interesting. I deploy to my homelab with Docker so it was a fit for me. But I do want to tinker on the API to disable everything but GET. Can you share anything more about breaking it up?

dan@lemmy.i.secretponi.es on 10 Mar 05:06 collapse

It was mostly uneventful, to be honest. I downloaded the two apps (static admin and the php app), tossed them into /opt/www, and set up nginx to serve PHP. The config in the main app had a section for my Postgres settings and the docs gave the instructions on putting the default server configuration into the static site.

The only challenge was actually rather silly: I don’t use PHP so it took me a bit to understand why apt install php installed Apache when I had already installed nginx. Once I found php-fpm it was smooth sailing from there.

pulsewidth@lemmy.world on 10 Mar 09:04 collapse

Can I ask - why would anyone do this? Several URL shortening services of the past have shuttered and it has left the web littered with links to sites that can never be resolved (linkrot) - this to me just seems like a another surefire way to speedrun future deadlinks in forums etc. Why?

Edit - I have misunderstood the assignment.

This is targeted at self-hosted/personal-domain stuff only, not general internet site URL shortening/redirection.

clifmo@programming.dev on 10 Mar 10:56 next collapse

How so? I am hosting and maintaining it for my own work and links. I have every incentive to keep it up. And if it goes down, only my links to my own content go down. And, the reason I did this was Bluesky has a character limit.

pulsewidth@lemmy.world on 10 Mar 13:16 collapse

Ah that is probably my bad then, I read it as being able to redirect arbitrary URLs, hence the need for geoblock and abuse protections - if it’s only your own self-hosted/personal domains then yeah that absolutely makes sense.

clifmo@programming.dev on 10 Mar 14:16 collapse

I think the concern re:geoblock is that the REST API is just out there, unauthenticated. I need to shut those off or limit them to the internal network with Traefik, but I still need the short links to resolve. I’m not sure if that API is used for that, or what. I haven’t explored the code yet.

merthyr1831@lemmy.ml on 10 Mar 11:27 collapse

I find link shorteners useful for sharing (ephemeral) links to others (especially if they’re massive) but for linking stuff on the web where you can hide it under an anchor tag is definitely a bad idea.