Skip to content

Instantly share code, notes, and snippets.

@fjacobi
Created July 22, 2024 10:49
Show Gist options
  • Save fjacobi/27869aadb965f1d88695eea004055976 to your computer and use it in GitHub Desktop.
Save fjacobi/27869aadb965f1d88695eea004055976 to your computer and use it in GitHub Desktop.
Minimal shortlink service
:80 {
map {path} {redirect-uri} {
/example https://www.google.de
# more
# ...
}
# 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 shortlink isn't here
respond "Thas's an unknown short URL ... :("
}
services:
caddy:
image: caddy:2.8.4-alpine
container_name: shorty
networks:
- traefik-proxy
restart: unless-stopped
volumes:
- ./Caddyfile:/etc/caddy/Caddyfile
- data:/data
- config:/config
labels:
- 'traefik.enable=true'
- '[...]'
volumes:
data:
config:
networks:
traefik-proxy:
external: true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment