A very simple link shortener, written in Rust, made to self host.
What is lonk
Lonk provides an HTTP interface where you input a URL, and get a short, standardized URL
.../l/ plus a sequence of letters and numbers) that will redirect you to the provided
Such link shorteners can be useful to share links where copy-pasting is not an option, or undesirable.
By default, links shortened with lonk expire after 3 days; this period can be refreshed by resubmitting the URL, without changing the shortened URL.
lonk can be served with
docker-compose (recommended) or as a binary.
docker-compose is trivial: pull the repository to a chosen
git clone https://git.cumperativa.xyz/meeg_leeto/lonk /etc/lonk
... and serve:
cd /etc/lonk && docker-compose up
By default, this will serve
localhost:8892. You can change this port in
docker-compose.yml. Likewise, you may adjust other parameters in
Mind that some of these parameters correspond to the container; so, in particular,
you should not change the port or database location in
config.json, unless you make the
corresponding changes in
docker-compose.yml. (If you are unfamiliar with
docker-compose, just leave these parameters alone; they do not affect your system in any
Serving as a binary
Please make sure you know what you are doing.
Although I've tried my best for
lonkto be correct, I cannot guarantee its safety. Using containerization will provide (at least) some level of extra security, in case
lonkis exploitable. By running
lonkdirectly as an executable, you are removing a layer between a potential attacker and your system.
lonk as a binary, preferably create a dedicated user and directory:
root# useradd --no-create-home --disabled-login lonk
root# mkdir /etc/lonk
root# chown lonk:lonk /etc/lonk
... place the lonk executable in that directory...
root# mv lonk /etc/lonk/lonk
root# chown lonk:lonk /etc/lonk/lonk
... and then run the
lonk executable as this user. Configuring
lonk is done the same
as in the
docker-compose case, namely by creating the appropriate
for a starting point, run
root# sudo -u lonk /bin/bash
lonk$ mkdir /etc/lonk/served
lonk$ /etc/lonk/lonk --print-default-config > etc/lonk/lonk.json
You may set a different configuration file by setting the environment variable
You will have to have Redis running and listening
on the port specified in the configuration file. Also, if you don't want to write your
own HTTP frontend, you'll have to copy the contents of the
data directory from
the repository into the newly created
/etc/lonk/served directory. (Don't forget to
chown lonk:lonk the copied contents.)
(The frontend is quite minimalist, and I encourage you to look at
main.js and write
lonk (in the location specified in the configuration file):
root# sudo -u lonk /etc/lonk/lonk
Pull requests are welcome. Issues are not guaranteed to be addressed.
built primarily for self-use, provided to you for free, and not my primary
occupation. Please respect this.
lonk is licenced under a GNU General Public License, version 3. This
informally means that:
You may copy, distribute and modify the software as long as you track changes/dates in source files. Any modifications to or software including (via compiler) GPL-licensed code must also be made available under the GPL along with build & install instructions.
You can find a copy of the licence under
Getting donations, no matter how small, lets me know that people use and appreciate the software I've published.
💕 If you like and use
buying me a coffee.