3 ms·
It's funny. Any feature you don't want to use is bloat, but as soon as you need it is a necessity. The way I see it, they can either "bloat" nginx by adding scr
by n42 11y ago
It's funny. Any feature you don't want to use is bloat, but as soon as you need it is a necessity. The way I see it, they can either "bloat" nginx by adding scripting capabilities, or they can bloat it by covering all of the use cases that a scripting engine would otherwise enable, big and small.
One simple example that I would love to use this for: generating and adding a UUIDv4 to every request's headers. Doing so would allow us to append the UUID to virtually every log in our entire stack. Right now there is no easy out of box solution for this in nginx. With scripting capabilities it becomes trivial.
However, whether or not Lua was enough and adding JavaScript is overkill, I'm not sure.
- Dylan16807 11y agoYou can consider it bloat even if you want it, which is why you want to carefully manage the size of what you add. I wouldn't refer to JavaScript as 'overkill'; it's not more capable than Lua for scripting, it's just bigger.
- marcosdumay 11y ago> generating and adding a UUIDv4 to every request's headers Why you can't do that in Lua?
- alexbilbie 11y agoI do what you describe with no extra Nginx modules with the following line inside a location block: fastcgi_param X-REQUEST-ID $pid-$msec-$request_length-$remote_addr; Using the more headers module you can also pluck things like Oauth access tokens and append them too
- erikcw 11y agoI've had the following Lua adding request UUIDs to our logs in production for over a year. Feel free to give it a try: https://gist.github.com/erikcw/e999e1fb438dbbb91533 https://gist.github.com/erikcw/e999e1fb438dbbb91533