You can do that with nginx https://docs.nginx.com/nginx/admin-guide/dynamic-modules/lua... . IIRC Cloudflare uses this extensively.
Thanks for this mention - I found:
CloudFlare repos on GitHub using Lua: https://github.com/cloudflare?q=lua
Blog posts with "Lua" tag: https://blog.cloudflare.com/tag/lua/
Pushing Nginx to its limit with Lua - https://blog.cloudflare.com/pushing-nginx-to-its-limit-with-...