njs Support

NGINX for Azure supports the open-source njs module, allowing the extension of NGINX functionality with a subset of the Javascript language.

Upload NGINX Configuration with njs

Create an njs script file by uploading a gzipped tar file or create the script file in the editor. See NGINX Configuration for a step-by-step guide.

Switch between language options to see syntax highlighting for NGINX configs or Javascript.

NJS Configuration

To use njs, enable the ngx_http_js_module module and specify the js_import directive with your njs file.

load_module modules/ngx_http_js_module.so;

http {
    js_import http.js;

    server {
        location / {
            js_content http.hello;
        }
    }
}

njs Validation

NGINX for Azure validates imported njs files and module names referenced in the NGINX configuration exist. However, NGINX for Azure will not parse, evaluate, or run any provided njs scripts when validating the NGINX configuration. Error logs are not available yet.

fs Module

The njs File System module provides operations with files. NGINX for Azure only allows reading and writing from specifed directories.

What’s Next

For help with troubleshooting, see Enable NGINX for Azure Monitoring