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
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/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.