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.dev, but using Cloudflare workers or any other complicated stack for th…

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.dev, 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  Github: https://github.com/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.dev

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

  satan's hackathon boilerplate
  shitpit co-lead developer

  Blog: https://tsak.dev
  Github: https://github.com/tsak

Print Share Comment Cite Upload Translate
APA
tsak | Sciencx (2024-03-28T22:55:44+00:00) » Use nginx as a hacker business card. Retrieved from https://www.scien.cx/2022/09/13/use-nginx-as-a-hacker-business-card/.
MLA
" » Use nginx as a hacker business card." tsak | Sciencx - Tuesday September 13, 2022, https://www.scien.cx/2022/09/13/use-nginx-as-a-hacker-business-card/
HARVARD
tsak | Sciencx Tuesday September 13, 2022 » Use nginx as a hacker business card., viewed 2024-03-28T22:55:44+00:00,<https://www.scien.cx/2022/09/13/use-nginx-as-a-hacker-business-card/>
VANCOUVER
tsak | Sciencx - » Use nginx as a hacker business card. [Internet]. [Accessed 2024-03-28T22:55:44+00:00]. Available from: https://www.scien.cx/2022/09/13/use-nginx-as-a-hacker-business-card/
CHICAGO
" » Use nginx as a hacker business card." tsak | Sciencx - Accessed 2024-03-28T22:55:44+00:00. https://www.scien.cx/2022/09/13/use-nginx-as-a-hacker-business-card/
IEEE
" » Use nginx as a hacker business card." tsak | Sciencx [Online]. Available: https://www.scien.cx/2022/09/13/use-nginx-as-a-hacker-business-card/. [Accessed: 2024-03-28T22:55:44+00:00]
rf:citation
» Use nginx as a hacker business card | tsak | Sciencx | https://www.scien.cx/2022/09/13/use-nginx-as-a-hacker-business-card/ | 2024-03-28T22:55:44+00:00
https://github.com/addpipe/simple-recorderjs-demo