- C 89.6%
- Dockerfile 6%
- Makefile 4.4%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
| .gitignore | ||
| BSDmakefile | ||
| clinks.c | ||
| config.example.kdl | ||
| docker-compose.yml | ||
| Dockerfile | ||
| Makefile | ||
| README.md | ||
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
libmicrohttpdcompiled with support for GnuTLS. A reverse proxy is still recommended in production. clinks does not handle certificate reloading, OCSP stapling, HSTS, etc.
- Requires
- Configurable in KDL 2
Dependencies
Runtime
libmicrohttpdwith TLS supportgnutlsckdl
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 iflanding #true, otherwise returns a 404GET /<shortlink>redirects (302) to the configured URL, and returns a 404 if no URL is set- Other methods return 405 Method Not Allowed