Use nginx as a hacker business card.

A friend of mine recently showed me his curl-able business card inspired by this Cloudflare worker template.

I liked the idea of returning something similar when running curl tsak.net, but using Cloudflare workers or any other complicated stack for that matter felt a bit like overkill to me. After all, I’m hosting my blog at home, using nginx.

Nginx supports a return directive that allows you to specify a response code and a URL or alternatively the content you would like to return.

So in my blog’s nginx config, I include the following config (note the \n to insert line-breaks):

if ($http_user_agent ~ "^(curl|HTTPie)") {
        return 200 "\n  ▀█▀ █▀ ▄▀█ █▄▀ ░ █▀▄ █▀▀ █░█\n  ░█░ ▄█ █▀█ █░█ ▄ █▄▀ ██▄ ▀▄▀\n\n  satan's hackathon boilerplate\n  shitpit co-lead developer\n\n  Blog: https://tsak.dev\n  Codeberg: https://codeberg.org/tsak\n\n";
}

I’m including this twice, once in the SSL-enabled server block and again in the HTTP-only server block that by default redirects any requests to the SSL encrypted version of the site, unless you’re hitting it via curl or HTTPie.

$ curl tsak.net

  ▀█▀ █▀ ▄▀█ █▄▀ ░ █▀▄ █▀▀ █░█
  ░█░ ▄█ █▀█ █░█ ▄ █▄▀ ██▄ ▀▄▀

  satan's hackathon boilerplate
  shitpit co-lead developer

  Blog: https://tsak.dev
  Codeberg: https://codeberg.org/tsak

Update: Having since moved my blog to Cloudflare Pages, I’ve moved the curl-goodness to tsak.net. Examples have been amended, but the screenshot and response stay the same.

Update 2: Updated Github link to Codeberg in the text, though the screenshot still shows the original link.