Skip to content

Self-hosted URL Shortener: Shlink

Posted by author in the category "self-hosting"

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. By default, it only functinos via CLI and a REST API (which I suppose is what could be abused).

You can install a separate web UI which I'll eventually host on my internal network. I will have to somehow block the non-read REST API methods which maybe means I'll fork the project.

Quick-start Dock Self-host Guide

Full docs

compose.yml

services:
  shlink:
    image: shlinkio/shlink:stable
    ports:
      - "8080:8080"
    env_file:
      - .env
    environment:
      DEFAULT_DOMAIN: "${DEFAULT_DOMAIN}"
      IS_HTTPS_ENABLED: true
      GEOLITE_LICENSE_KEY: "${GEOLITE_LICENSE_KEY}"
      SHELL_VERBOSITY: 3 #For debugging output
    networks:
      - proxy

networks:
  proxy:
    external: true

.env

DEFAULT_DOMAIN=ur.shrt.domain
GEOLITE_LICENSE_KEY=

Geolite

  • Create a MaxMind account for GeoLite2. (link)
  • Generate a license key. (link)
End of article