Fork of link with some extra features.
Find a file
swirl 6abaf1abbb switch to FS-based storage
removed all SQLite stuff, and switched to a fully filesystem-based
storage system, which just uses plain files.

also moved self-host instructions to README
2021-08-28 17:40:36 -04:00
doc switch to FS-based storage 2021-08-28 17:40:36 -04:00
.gitignore install target, added environment file for systemd service 2021-08-12 15:30:47 -04:00
go.mod switch to FS-based storage 2021-08-28 17:40:36 -04:00
go.sum switch to FS-based storage 2021-08-28 17:40:36 -04:00
index.html switch to FS-based storage 2021-08-28 17:40:36 -04:00
LICENSE install target, added environment file for systemd service 2021-08-12 15:30:47 -04:00
main.go switch to FS-based storage 2021-08-28 17:40:36 -04:00
makefile switch to FS-based storage 2021-08-28 17:40:36 -04:00
README.md switch to FS-based storage 2021-08-28 17:40:36 -04:00

Fork of link with extra features, a filesystem-based backend, and more.

Please access this project on my Gitea instance, NOT GitHub.

Self-Hosting

You can host this yourself.

Note: all commands here are done as root.

Building & Installing

To build this project, you'll need Go and Git. Most Linux distributions should have these in their repositories, i.e.:

  • pacman -S go git
  • emerge --ask dev-lang/go dev-vcs/git
  • apt install go git
  1. Clone this repository:
git clone https://git.swurl.xyz/swirl/link && cd link
  1. Compile:
make
  1. Now, you need to install. NGINX and systemd files are provided in this project; you may choose not to install them.

For all install commands, you may optionally provide prefix and DESTDIR options. This is useful for packagers; i.e. for a PKGBUILD: make prefix=/usr DESTDIR=${pkgdir} install.

Available install commands are as follows:

  • make install installs the executable, NGINX, and systemd files.
  • make install-bin installs the executable file.
  • make install-systemd installs the systemd file, as well as its environment file.
  • make install-nginx installs the NGINX file.

For example, on a non-systemd system using NGINX, you would run make install-bin install-nginx.

  1. If using systemd, change the environment file to reflect your desired options:
vim /etc/link.conf
  1. You can now enable and start the service:
systemctl enable --now link

The server should now be running on localhost at port 8080.

NGINX Reverse Proxy

An NGINX file is provided with this project. Sorry, no support for Apache or lighttpd or anything else; should've chosen a better HTTP server.

For this, you'll need NGINX (obviously), certbot, and its NGINX plugin. Most Linux distributions should have these in their repositories, i.e.:

  • pacman -S nginx certbot-nginx
  • emerge --ask www-servers/nginx app-crypt/certbot-nginx
  • apt install nginx python-certbot-nginx

This section assumes you've already followed the last.

  1. Change the domain in the NGINX file:
sed -i 's/your.doma.in/[DOMAIN HERE]' /etc/nginx/sites-available/link
  1. Enable the site:
ln -s /etc/nginx/sites-{available,enabled}/link
  1. Enable HTTPS for the site:
certbot --nginx -d [DOMAIN HERE]
  1. Enable and start NGINX:
systemctl enable --now nginx

If it's already running, reload:

systemctl reload nginx

Your site should be running at https://your.doma.in. Test it by going there, and trying the examples. If they don't work, open an issue.

Contributions

Contributions are always welcome.

FAQ

Clean it up, janny!

Deleting a link can be done simply by running:

rm /srv/link/*/BADLINKHERE

Replace /srv/link with whatever your data directory is.

Not currently. Might implement this in the future.

Can I run this in a subdirectory of my site?

Yes. Simply put the proxy_pass directive in a subdirectory, i.e.:

location /shortener {
    proxy_pass http://localhost:8080;
}

Why'd you make this fork?

While link was by far the best link shortener I could find, it had a few problems:

  • No query-string support: had to make POST requests
  • Didn't decode URLs
  • SQLite is not the greatest storage method out there
  • No pre-provided systemd or NGINX files
  • No install target for the makefile

The first two are mostly problems when using them with specific services; i.e. PrivateBin, which expects to be able to use query-strings and encoded URLs.