Skip to content

Instantly share code, notes, and snippets.

@TobiX
Last active October 16, 2024 20:50
Show Gist options
  • Save TobiX/9daa43186bcd80071fcfe726f91c9bc6 to your computer and use it in GitHub Desktop.
Save TobiX/9daa43186bcd80071fcfe726f91c9bc6 to your computer and use it in GitHub Desktop.
Caddy Tar Pit

This is a silly snippet of caddy config file to send heavily compressed huge files to clients prodding "stupid" URLs. (idea from https://tech.lgbt/@becomethewaifu/111879788755441482)

This needs a directory with 3 precompressed files, which may be created like this (tune numbers if you have more/less bandwith to spare or want to annoy "visitors" more/less):

dd if=/dev/zero bs=1M count=10240 status=progress | gzip -9 > 42.gzip
dd if=/dev/zero bs=1M count=102400 status=progress | brotli > 42.br
dd if=/dev/zero bs=1M count=102400 status=progress | zstd -9 -T0 > 42.zstd

I got these compression ratios:

File Compressed Uncompressed
42.gzip 9.937 MiB 10 GiB
42.br 82.032 KiB 100 GiB
42.zstd 3.17 MiB 100 GiB
# Tar pit
@shit {
path */.env
path /wp-login.php
}
handle @shit {
root * /srv/www
vars compression gzip
@is_br header Accept-Encoding *br*
vars @is_br compression br
@is_zstd header Accept-Encoding *zstd*
vars @is_zstd compression zstd
header {
Content-Encoding {vars.compression}
Content-Type "text/html; charset=utf-8"
}
rewrite * /42.{vars.compression}
file_server
}
@TobiX
Copy link
Author

TobiX commented Apr 24, 2024

@sussycatgirl Updated. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment