Skip to content

shlink Shlink

Shlink is used as an internal URL shortener.

🛠 Installation

Default Port: 8081

homelab/docker/shlink

task up
docker compose up

âš™ Config

Create an account at GeoLite2 and generate a license key.

homelab/docker/shlink/.env

CONFIG_DIR=/etc/shlink
INSTALL_DIR=/opt/shlink
SERVICE_NAME=shlink
GEOLITE_LICENSE_KEY=

I am running both the server and the optional web client.

The https://app.shlink.io/ also may be used.

The application runs 100% in the browser, so you can safely access any Shlink server from there.

homelab/docker/shlink/compose.yaml
---

services:
  shlink:
    container_name: shlink-backend
    image: shlinkio/shlink:4.4.6
    env_file:
      - .env
    environment:
      - DEFAULT_DOMAIN=localhost:8080
      - IS_HTTPS_ENABLED=false
      - GEOLITE_LICENSE_KEY=${GEOLITE_LICENSE_KEY}
      - SHELL_VERBOSITY=3
    ports:
      - '8080:8080'
    restart: always

  shlink-web-client:
    image: shlinkio/shlink-web-client
    restart: always
    container_name: shlink-frontend
    environment:
      - SHLINK_SERVER_URL=localhost:8080
      # - SHLINK_SERVER_API_KEY=
    depends_on:
      - shlink
    ports:
      - 8081:8080

Traefik

homelab/pve/traefik/conf.d/shlink.yaml
---
http:
 #region routers 
  routers:
    shlink:
      entryPoints:
        - "websecure"
      rule: "Host(`sh.rt`)"
      middlewares:
        - default-headers@file
        - https-redirectscheme@file
      tls: {}
      service: shlink
    shlink2:
      entryPoints:
        - "websecure"
      rule: "Host(`shlink.l.nicholaswilde.io`)"
      middlewares:
        - default-headers@file
        - https-redirectscheme@file
      tls: {}
      service: shlink2
#endregion
#region services
  services:
    shlink:
      loadBalancer:
        servers:
          - url: "http://192.168.2.92:8080"
        passHostHeader: true
    shlink2:
      loadBalancer:
        servers:
          - url: "http://192.168.2.92:8081"
        passHostHeader: true

#endregion
  middlewares:
    https-redirectscheme:
      redirectScheme:
        scheme: https
        permanent: true
    default-headers:
      headers:
        frameDeny: true
        browserXssFilter: true
        contentTypeNosniff: true
        forceSTSHeader: true
        stsIncludeSubdomains: true
        stsPreload: true
        stsSeconds: 15552000
        customFrameOptionsValue: SAMEORIGIN
        customRequestHeaders:
          X-Forwarded-Proto: https

    default-whitelist:
      ipAllowList:
        sourceRange:
        - "10.0.0.0/8"
        - "192.168.0.0/16"
        - "172.16.0.0/12"

    secured:
      chain:
        middlewares:
        - default-whitelist
        - default-headers

Task List

task: Available tasks for this project:
* decrypt:       Decrypt .env using SOPS
* encrypt:       Encrypt .env using SOPS
* export:        Export the task list
* gen:           Generate an api key
* init:          Init
* mklinks:       Make client symlinks
* restart:       Restart Docker containers
* status:        Status
* stop:          Stop registry container
* up:            Tun Docker compose in the foreground.
* up-d:          Run Docker compose in the background.
* update:        Update running containers
* upgrade:       upgrade

🔗 References