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…


This content originally appeared on DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’» and was authored by tsak

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


This content originally appeared on DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’» and was authored by tsak


Print Share Comment Cite Upload Translate Updates
APA

tsak | Sciencx (2022-09-13T22:12:41+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 ,<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 ]. 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 . 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: ]
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/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.