simple, lightweight link shortener written in C99 and configured in KDL 2
  • C 89.6%
  • Dockerfile 6%
  • Makefile 4.4%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
2026-10-22 08:54:52 +13:00
.gitignore gitignore stuff 2026-10-21 19:51:45 +13:00
BSDmakefile README and makefile 2026-10-20 22:01:30 +13:00
clinks.c fix more bugs 2026-10-22 08:54:52 +13:00
config.example.kdl add README 2026-10-21 21:00:56 +13:00
docker-compose.yml Dockerize 2026-10-21 21:18:37 +13:00
Dockerfile Dockerize 2026-10-21 21:18:37 +13:00
Makefile use the right flags so ssl actually works 2026-10-21 20:19:44 +13:00
README.md Update README for Docker 2026-10-21 21:21:12 +13:00

clinks

simple, lightweight link shortener written in C99 configured in KDL 2

Features

  • Can point short links to long URLs (no shit, it's a link shortener)
  • Can serve a configured landing page
  • Has SSL/HTTPS support
    • Requires libmicrohttpd compiled with support for GnuTLS. A reverse proxy is still recommended in production. clinks does not handle certificate reloading, OCSP stapling, HSTS, etc.
  • Configurable in KDL 2

Dependencies

Runtime

  • libmicrohttpd with TLS support
  • gnutls
  • ckdl

Build

  • All above dependencies
  • bmake (not GNU make)
  • pkg-config
  • a C99 compiler (preferrably gcc/clang)

Building

Install all the dependencies listed above, then run the following command to build clinks.

bmake

The built clinks binary alongside other artifacts can be found in the current directory.

Usage

Configuration

See config.example.kdl for a full example configuration.

Copy config.example.kdl to config.kdl and change the configuration as required.

Links are added as children in the links node.
For example, the following configuration example adds two shortlinks example and anotherExample which redirect to their long URLs respectively.

// (other config options here...)

links {
    example "https://example.com/my-long-link-123";
    anotherExample "https://example.com/this-is-an-even-longer-link-lorem-ipsum-dolor-sit-amet";
}

Running

Standalone

To start clinks, run the following command, replacing <host>, <port>, and <config-file> with their equivalents:

./clinks <host> <port> <config-file>

For example, this starts the server on 0.0.0.0:8080 with the config file located at config.kdl:

./clinks 0.0.0.0 8080 config.kdl

Docker

To run clinks in Docker, simply edit docker-compose.yml to fit your configuration, then run the following commands:

docker build -t clinks .
docker compose up -d

Behaviour

  • GET / serves the landing page if landing #true, otherwise returns a 404
  • GET /<shortlink> redirects (302) to the configured URL, and returns a 404 if no URL is set
  • Other methods return 405 Method Not Allowed