Use Caddy server to shorten custom URL's
Vision:
- resolve only my custom short links (No need to tech junk)
- not a public, internet-facing service (No overkill)
- The most minimal setup I could think off
Requirements:
- A domain name that will be the root for a subdomain i.e url.domain.org/*
- A webserver with a public-facing IPV4 address
- A wee bit of Linux knowledge
- Install caddy server on your web server (I use Ubuntu 20.04)
- Point the IP address of the webserver to your subdomain
Caddyfile config
# /etc/caddy/Caddyfile
url.domain.org { # replace it your subdomain
map {path} {redirect-uri} {
/deals https://www.govdeals.ca
/voice https://www.voiceflow.com
/killer https://www.youtube.com/watch?v=_6ZGgdeWfSM
# will add new ones here like the above
# ...
}
# this below code is required to actually make the above `map` work
@hasRedir expression `{redirect-uri} != ""`
redir @hasRedir {redirect-uri}
# code below is to set the default response if the requested URL isn't here
respond "Error: unknown short URL ... :("
Note: Please remember to restart the Caddy server every time you update the site list
Le Fin
That's all folks. I hope you enjoyed this blog post