Intro
Do you often find yourself typing git clone https://github.com/yourusername/repo? I did.
In this tutorial, I will show you how I redirect from my custom domain maxis.me to github.com/maxisme/ using Traefik.
For example, this allows me to easily access my websites GitHub repo, max.me.uk, located at github.com/maxisme/max.me.uk by visiting maxis.me/max.me.uk.
Setup
In my Traefiks main config I have a provider for Files:
traefik.toml
[providers]
[providers.file]
directory = "/etc/traefik/rules/"
watch = true
Using a new file provider I created a simple middleware to redirect my custom domain maxis.me/repo to github.com/maxisme/repo using Traefiks redirect regex.
/etc/traefik/rules/github.toml
[http.routers.github]
rule = "Host(`maxis.me`)"
middlewares = ["github-redirect"]
service = "empty-service"
[http.routers.github.tls]
certResolver = "letsencrypt"
[http.services.empty-service.loadBalancer]
[http.middlewares.github-redirect.redirectRegex]
regex = "maxis.me/(.*)"
replacement = "github.com/maxisme/${1}"
permanent = true