A Great Old-Timey Game-Programming Hack (2013)
blog.moertel.com4 pointsby palsecam0 comments
# Nothing to hack around here, I’m just a teapot:
location ~* \.(?:php|aspx?|jsp|dll|sql|bak)$ {
return 418;
}
error_page 418 /418.html;
No hard block, instead reply to bots the funny HTTP 418 code (https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/...). That makes filtering logs easier. SocksPort 0
ExitRelay 0
ORPort NNNN
DirPort NNNN
Nickname X
ContactInfo [email protected]
RelayBandwidthRate 80 megabits
RelayBandwidthBurst 120 megabits
MaxMemInQueues 384 megabytes
AvoidDiskWrites 1
HardwareAccel 1
NoExec 1
NumCPUs 1
Here’s my override config for systemd (Ubuntu 24.04): $ sudo systemctl edit tor@default
[Service]
Nice=15
CPUAffinity=0
CPUWeight=60
StartupCPUWeight=6
IOWeight=60
TimerSlackNSec=100us
MemoryMax=896M
MemoryHigh=800M
OOMScoreAdjust=1000
LimitAS=2G
LimitNPROC=512
LimitNOFILE=10240
PrivateDevices=true
ProtectSystem=true
ProtectHome=true const atom = new XMLHttpRequest, xslt = new XMLHttpRequest;
atom.open("GET", "feed.xml"); xslt.open("GET", "atom2html.xsl");
atom.onload = xslt.onload = function() {
if (atom.readyState !== 4 || xslt.readyState !== 4) return;
const proc = new XSLTProcessor;
proc.importStylesheet(xslt.responseXML);
const frag = proc.transformToFragment(atom.responseXML, document);
document.getElementById("feed").appendChild(frag.querySelector("[role='feed']"));
};
atom.send(); xslt.send();
Server-side, I’ve leveraged XSLT (2.0) in the build process of another website, to slightly transform (X)HTML pages before publishing (canonicalize URLs, embed JS & CSS directly in the page, etc.): https://github.com/PaulCapron/pwa2uwp/blob/master/postprod.x...
> You have an image on your error page, which some crappy bots will download over and over again.
Most bots won’t download subresources (almost none of them do, actually). The HTML page itself is lean (475 bytes); the image is an Easter egg for humans ;-) Moreover, I use a caching CDN (Cloudflare).