Rearchitecting GitHub Pages
I find that for such tasks it makes sense instead of trying to hack around nginx config and its lua scripting, to throw it away and write a small app in, say, Haskell+Warp that would do the job. It's as fast as nginx (and probably faster than nginx+lua), would have much more static guarantees, express logic more clear.