Skip to content

wblondel/actes.williamblondel.fr

Repository files navigation

Caddy-only go-link/URL shortener service

en fr

This repository holds the configuration of my Caddy-only go-link service, used to have clean links in my genealogy data.

How does it work?

The service is deployed on Fly.io and its public URL is https://actes.williamblondel.fr.

Upon deployment, Fly builds a Docker image based on the official Caddy's Docker image. Caddy is configured to load the conf/caddy-config-loader.json configuration on start up.

This configuration tells Caddy to load via HTTP the configuration located at conf/caddy-config.json, which contains the defined links.

The links are managed via the Caddy API, exclusively through the Makefile.

Every 30 minutes, a workflow fetches the current Caddy configuration and commits it to the repository if changes were detected. This prevents the configuration from being lost when restarting the machine or Caddy.

Usage

The Fly.io CLI is required.

To get the list of available commands, execute make help (or make).

Shorten a URL

make short \
  url=https://example.org \
  shortcode=optional_shortcode \
  title="Page title"

This command allows you to create a go link to a specific url. A shortcode can be provided, otherwise it will be generated automatically.

A title is required. It will be encoded to Base64URL and saved into the @id field.

Delete a URL

make delete id="VGVzdCBQYWdl"

or

make delete shortcode="62f21770"

This command allows you to delete a URL by its id (the encoded title) or by its shortcode.

Show the Caddy configuration

make show_config

This command pretty prints the JSON full Caddy configuration.

Show the list of routes

make output_format=table show_routes

This command shows the list of routes defined in the Caddy configuration.

The output_format variable is optional and defaults to json, which pretty prints the JSON. Available output formats are json, table, and csv.

Restart the Fly.io application

make restart_app

This command restarts the Fly.io application.

Shut down Caddy

make stop_caddy

This command gracefully shuts down Caddy and exits the process.

About

URL shortener service using only the Caddy server, for my genealogy records

Topics

Resources

Stars

Watchers

Forks

Contributors 4

  •  
  •  
  •  
  •