Shorty is a link shortening middleware for Traefik. It allows you to create short URLs that redirect to longer URLs. This README outlines how to install and configure Shorty in your Traefik setup.
-
YAML Configuration: Add Shorty to your Traefik YAML configuration file (
traefik.yml
):experimental: plugins: shorty: moduleName: "github.com/Spakl-io/shorty" version: "v1.0.0"
Replace
v1.0.0
with the version of your desire. -
Command-Line Configuration: Alternatively, you can configure Traefik to use Shorty via command line:
traefik --experimental.plugins.shorty.moduleName=github.com/Spakl-io/shorty --experimental.plugins.shorty.version=v1.0.0
Add the following labels to your Docker service to use Shorty. These labels define the router, service, middleware, and link mappings.
services:
your-service:
labels:
- "traefik.http.routers.shorty.rule=Host(`shorty.io`)"
- "traefik.http.routers.shorty.service=traefik-shorty@docker"
- "traefik.http.routers.shorty.middlewares=my-shorty@docker"
- "traefik.http.middlewares.my-shorty.plugin.shorty.links.proxmox=https://proxmox.ops.spakl.io"
- "traefik.http.middlewares.my-shorty.plugin.shorty.links.proxmox2=https://proxmox2.ops.spakl.io"
- "traefik.http.middlewares.my-shorty.plugin.shorty.links.google=https://google.com"
The Host
rule in the router label defines the domain name. For example, Host(
shorty.localhost)
sets up shorty.localhost
as the domain.
Here's a localhost example docker-compose.yml
snippet:
version: '3'
services:
traefik:
# ... Traefik configuration ...
command:
- "--experimental.plugins.shorty.moduleName=github.com/Spakl-io/shorty"
- "--experimental.plugins.shorty.version=v1.0.0"
# other configurations...
labels:
- "traefik.http.routers.shorty.rule=Host(`shorty.localhost`)"
- "traefik.http.routers.shorty.service=traefik-shorty@docker"
- "traefik.http.routers.shorty.middlewares=shorty1@docker"
- "traefik.http.middlewares.shorty1.plugin.shorty.links.proxmox=https://proxmox.ops.spakl.io"
- "traefik.http.middlewares.shorty1.plugin.shorty.links.proxmox2=https://proxmox2.ops.spakl.io"
- "traefik.http.middlewares.shorty1.plugin.shorty.links.google=https://google.com"
Once configured, Shorty will intercept requests to the specified short URLs and redirect them to the corresponding target URLs.
Contributions to Shorty are welcome. Please refer to the project's GitHub repository for contribution guidelines.