shlink

A self-hosted URL shortener.

Run docker instance

docker run \
    --name my_shlink \
    -p 8080:8080 \
    -e DEFAULT_DOMAIN=s.test \
    -e IS_HTTPS_ENABLED=true \
    -e GEOLITE_LICENSE_KEY=xyz123 \
    shlinkio/shlink:stable
  • --name - can be whatever
  • DEFAULT_DOMAIN - set to yourdomain.com
  • IS_HTTPS_ENABLED - enable for HTTPS support (automatic via LetsEncrypt)
  • GEOLITE_LICENSE_KEY - optional - read about it here. You can exclude this setting if you don't want to geolocate where your link clicks are coming from.

Enable HTTPS using Caddy

Use a Caddyfile such as:

yourdomain.com {
    reverse_proxy http://127.0.0.1:8080
}

Then run it:

./caddy run --config ./Caddyfile

Generate an API key via docker

sudo docker exec -it my_shlink shlink api-key:generate

Write it down!

  • Download from here
  • Unzip the zip

Using something like Caddy where /home/www/ is where the shlink Web interface is unzipped:

Enable HTTPS in the Web management portal

Per this discussion on GitHub, you'll have problems copying links to clipboard in the browser if you're not in a secure context while doing so. So once I get the Caddy file server going (see previous section) I setup another tmux session and run something like:

sudomain-I-setup-for-shlink-admin.mydomain.com {
    reverse_proxy http://127.0.0.1:8888
}

Stop/restart the instance

You can press Ctrl+C to stop the instance, but next time you start it docker will complain that the container name is in use, so you can just do:

sudo docker start my_shlink

Stop it again:

sudo docker stop my_shlink

Review the logs with:

review