If you;re doing this with an ec2, why not use CloudFront, and if you need a tiny bit of logic you could use API GW edge optimized and toss a lambda in there to do the logic bits.
That would work, too. It would be very expensive at scale and would be difficult to keep tail latencies down. Which might be ok for some cases, but wasn't for mine.
At Edge workers really are great at solving so many of these use cases.
Nginx itself supports lua and JavaScript
yeah but with an EC2 you're always running it. Going serverless you only pay when there's use.
but when you have a lot of processing, lambdas can get really expensive, more than dedicated ec2 machines