statico.link / ianl.link short URLs
Why? I wanted an easy way to paste URLs that I use and share a lot.
How? This started as a simple NGINX redirect map like this because I already run NGINX for other things and wanted the simplest thing possible. Then people wanted an index page, and then the ipdata.co free API stopped working, so I made it a tiny service that would parse the existing config file. Now it uses PostgreSQL for better scalability and management.
What else? The site is marked noindex, nofollow to prevent crawling. Redirects are sent with a Referrer-Policy: unsafe-url header for reasons that I think sounded smart at the time but I'm too lazy to look up right now.
The application uses PostgreSQL to store links. Create the database schema using the provided schema.sql file:
psql $DATABASE_URL -f schema.sqlThe schema includes a links table with the following structure:
slug(TEXT PRIMARY KEY) - The short URL slugurl(TEXT NOT NULL) - The destination URLprivate(BOOLEAN DEFAULT FALSE) - If true, the link won't appear on the index page but will still work for redirects
Keys should be whole words. The server strips all non-word characters from the key so that you can add a link like foobarbaz and then paste https://your.links/foo-bar-baz into chat to make it more readable.
Configure the following env vars either through Docker or a .env file (Node.js will automatically load .env files):
DATABASE_URL- PostgreSQL connection string (required)PORT- Port number to listen on, defaults to 8080IPDATA_KEY- Get an API key from https://dashboard.ipdata.co/api.htmlBASE_URL- Base URL likehttps://cool.linkTITLE- Title to appear on the pageDESCRIPTION- Byline to appear on the pageGITHUB_URL- Link to this page
Get a recent Node.js and pnpm and run:
$ pnpm install
$ pnpm run devMake sure you have a PostgreSQL database running and set the DATABASE_URL environment variable (or create a .env file).
$ docker build . --tag ghcr.io/statico/statico.link
Etc.
MIT
