Skip to content

self-hosting

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.

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 functions via CLI and a REST API, which is probably part of what keeps abuse manageable.

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 Docker 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