nginScript
nginScript (pronounced engine script) is essentially a subset of ECMA 5.1 JavaScript with a few ECMA 6.0 extensions implemented. It is available in two versions, ngx_http_js_module
for standard HTTP usage and ngx_stream_js_module
for TCP stream usage. Make sure one or both of these are included in your Nginx compile, if you're not sure, you can check by using nginx -V | grep js_module
in a terminal or by seeing if your main configuration file is loading either module dynamically.
nginScript works by implementing handlers that are passed two arguments, the client request and the client response. This allows you full access to the HTTP request to access and manipulate data. Additionally, nginScript allows you to assign nginScript function output to normal Nginx variables that can be used with the standard directives:
js_include http.js; js_set $foo foo; // Function implemented in http.js js_set $summary summary; // Function implemented in http.js server { listen 8000; location...