{"id":13511477,"url":"https://github.com/nginx/njs","last_synced_at":"2026-04-23T20:00:35.076Z","repository":{"id":37391009,"uuid":"43038779","full_name":"nginx/njs","owner":"nginx","description":"A subset of JavaScript language to use in nginx","archived":false,"fork":false,"pushed_at":"2026-04-21T14:20:20.000Z","size":22660,"stargazers_count":1559,"open_issues_count":42,"forks_count":223,"subscribers_count":49,"default_branch":"master","last_synced_at":"2026-04-21T16:30:15.436Z","etag":null,"topics":["javascript","nginx","nginx-complex-access-control","nginx-custom-scripting","nginx-flexible-asynchronous-content-handlers","nginx-flexible-filters","nginx-javascript","nginx-javascript-module","nginx-manipulating-response-headers","nginx-module","nginx-security-checks","njs","quickjs"],"latest_commit_sha":null,"homepage":"http://nginx.org/en/docs/njs/","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nginx.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGES","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":"SUPPORT.md","governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2015-09-24T02:03:58.000Z","updated_at":"2026-04-21T14:18:54.000Z","dependencies_parsed_at":"2023-10-05T03:51:51.005Z","dependency_job_id":"c3b2c262-cb25-4693-a578-38b678725ae9","html_url":"https://github.com/nginx/njs","commit_stats":{"total_commits":2450,"total_committers":34,"mean_commits":72.05882352941177,"dds":0.3583673469387755,"last_synced_commit":"5247aac9f4cc6f49ccf4a1dcfb30581ae2837dd4"},"previous_names":[],"tags_count":79,"template":false,"template_full_name":null,"purl":"pkg:github/nginx/njs","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nginx%2Fnjs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nginx%2Fnjs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nginx%2Fnjs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nginx%2Fnjs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nginx","download_url":"https://codeload.github.com/nginx/njs/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nginx%2Fnjs/sbom","scorecard":{"id":683207,"data":{"date":"2025-08-11","repo":{"name":"github.com/nginx/njs","commit":"d157f564d665d806d4b5072c59d3e4760eddb966"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":7.6,"checks":[{"name":"Code-Review","score":10,"reason":"all changesets reviewed","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Maintained","score":10,"reason":"30 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 10","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Security-Policy","score":10,"reason":"security policy file detected","details":["Info: security policy file detected: SECURITY.md:1","Info: Found linked content: SECURITY.md:1","Info: Found disclosure, vulnerability, and/or timelines in security policy: SECURITY.md:1","Info: Found text in security policy: SECURITY.md:1"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: jobLevel 'actions' permission set to 'write': .github/workflows/f5_cla.yml:14","Warn: jobLevel 'statuses' permission set to 'write': .github/workflows/f5_cla.yml:16","Warn: no topLevel permission defined: .github/workflows/check-pr.yml:1","Warn: no topLevel permission defined: .github/workflows/ci.yml:1","Info: topLevel permissions set to 'read-all': .github/workflows/f5_cla.yml:8"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Pinned-Dependencies","score":5,"reason":"dependency not pinned by hash detected -- score normalized to 5","details":["Warn: third-party GitHubAction not pinned by hash: .github/workflows/ci.yml:11: update your workflow using https://app.stepsecurity.io/secureworkflow/nginx/njs/ci.yml/master?enable=pin","Info:   1 out of   1 GitHub-owned GitHubAction dependencies pinned","Info:   1 out of   2 third-party GitHubAction dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: BSD 2-Clause \"Simplified\" License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Fuzzing","score":10,"reason":"project is fuzzed","details":["Info: OSSFuzz integration found","Info: CLibFuzzer integration found: external/njs_shell.c:854"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":-1,"reason":"internal error: error during branchesHandler.setup: internal error: githubv4.Query: Resource not accessible by integration","details":null,"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 30 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-21T23:53:03.404Z","repository_id":37391009,"created_at":"2025-08-21T23:53:03.405Z","updated_at":"2025-08-21T23:53:03.405Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32196155,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-23T15:28:30.493Z","status":"ssl_error","status_checked_at":"2026-04-23T15:28:29.972Z","response_time":53,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["javascript","nginx","nginx-complex-access-control","nginx-custom-scripting","nginx-flexible-asynchronous-content-handlers","nginx-flexible-filters","nginx-javascript","nginx-javascript-module","nginx-manipulating-response-headers","nginx-module","nginx-security-checks","njs","quickjs"],"created_at":"2024-08-01T03:00:51.177Z","updated_at":"2026-04-23T20:00:35.027Z","avatar_url":"https://github.com/nginx.png","language":"C","readme":"[![Project Status: Active – The project has reached a stable, usable state and is being actively developed.](https://www.repostatus.org/badges/latest/active.svg)](https://www.repostatus.org/#active)\n[![Community Support](https://badgen.net/badge/support/commercial/green?icon=awesome)](/SUPPORT.md)\n\n![NGINX JavaScript Banner](NGINX-js-1660x332.png \"NGINX JavaScript Banner\")\n\n# NGINX JavaScript\nNGINX JavaScript, also known as [NJS](https://nginx.org/en/docs/njs/), is a dynamic module for [NGINX](https://nginx.org/en/download.html) that enables the extension of built-in functionality using familiar JavaScript syntax. The NJS language is a subset of JavaScript, compliant with [ES5](https://262.ecma-international.org/5.1/) (ECMAScript 5.1 [Strict Variant](https://262.ecma-international.org/5.1/#sec-4.2.2)) with some [ES6](https://262.ecma-international.org/6.0/) (ECMAScript 6) and newer extensions. See [compatibility](https://nginx.org/en/docs/njs/compatibility.html) for more details.\n\n# Table of Contents\n- [How it works](#how-it-works)\n- [Downloading and installing](#downloading-and-installing)\n  - [Provisioning the NGINX package repository](#provisioning-the-nginx-package-repository)\n  - [Installing the NGINX JavaScript modules](#installing-the-nginx-javascipt-modules)\n  - [Installed files and locations](#installed-files-and-locations)\n- [Getting started with NGINX JavaScript](#getting-started-with-nginx-javascript)\n  - [Verify NGINX is running](#verify-nginx-is-running)\n  - [Enabling the NGINX JavaScript modules](#enabling-the-nginx-javascipt-modules)\n  - [Basics of writing .js script files](#basics-of-writing-js-script-files)\n  - [Reference of custom objects, methods, and properties](#reference-of-custom-objects-methods-and-properties)\n  - [Example: Hello World](#example-hello-world)\n  - [The NJS command line interface (CLI)](#the-njs-command-line-interface-cli)\n- [Building from source](#building-from-source)\n  - [Installing dependencies](#installing-dependencies)\n  - [Cloning the NGINX JavaScript GitHub repository](#cloning-the-nginx-javascript-github-repository)\n  - [Building standalone command line interface utility (optional)](#building-standalone-command-line-interface-utility-optional)\n  - [Cloning the NGINX GitHub repository](#cloning-the-nginx-github-repository)\n  - [Building NGINX JavaScript as a module of NGINX](#building-nginx-javascript-as-a-module-of-nginx)\n- [NGINX JavaScript technical specifications](#nginx-javascript-technical-specifications)\n  - [Supported distributions](#supported-distributions)\n  - [Supported deployment environments](#supported-deployment-environments)\n  - [Supported NGINX versions](#supported-nginx-versions)\n  - [Sizing recommendations](#sizing-recommendations)\n- [Asking questions, reporting issues, and contributing](#asking-questions-reporting-issues-and-contributing)\n- [Change log](#change-log)\n- [License](#license)\n\n# How it works\n[NGINX JavaScript](https://nginx.org/en/docs/njs/) is provided as two [dynamic modules](https://nginx.org/en/linux_packages.html#dynmodules) for NGINX ([ngx_http_js_module](https://nginx.org/en/docs/http/ngx_http_js_module.html) and [ngx_stream_js_module](https://nginx.org/en/docs/stream/ngx_stream_js_module.html)) and can be added to any supported [NGINX Open Source](https://nginx.org/en/download.html) or [NGINX Plus](https://www.f5.com/products/nginx/nginx-plus) installation without recompilation. \n\nThe NJS module allows NGINX administrators to:\n- Add complex access control and security checks before requests reach upstream servers\n- Manipulate response headers\n- Write flexible, asynchronous content handlers, filters, and more!\n\nSee [examples](https://github.com/nginx/njs-examples/) and our various projects developed with NJS:\n\n#### https://github.com/nginxinc/nginx-openid-connect\nExtends NGINX Plus functionality to communicate directly with OIDC-compatible Identity Providers, authenticating users and authorizing content delivered by NGINX Plus.\n\n#### https://github.com/nginxinc/nginx-saml\nReference implementation of NGINX Plus as a service provider for SAML authentication.\n\n#### https://github.com/nginxinc/njs-prometheus-module\nExposes Prometheus metrics endpoint directly from NGINX Plus.\n\n\u003e [!TIP]\n\u003e NJS can also be used with the [NGINX Unit](https://unit.nginx.org/) application server. Learn more about NGINX Unit's [Control API](https://unit.nginx.org/controlapi/) and how to [define function calls with NJS](https://unit.nginx.org/scripting/).\n\n# Downloading and installing\nFollow these steps to download and install precompiled NGINX and NGINX JavaScript Linux binaries. You may also choose to [build the module locally from source code](#building-from-source).\n\n## Provisioning the NGINX package repository\nFollow [this guide](https://nginx.org/en/linux_packages.html) to add the official NGINX package repository to your system and install NGINX Open Source. If you already have NGINX Open Source or NGINX Plus installed, skip the NGINX installation portion in the last step.\n\n## Installing the NGINX JavaScript modules\nOnce the repository has been provisioned, you may install NJS by issuing the following command:\n\n### Ubuntu or Debian based systems\n```bash\nsudo apt install nginx-module-njs\n```\n\n### RHEL, RedHat and its derivatives\n```bash\nsudo yum install nginx-module-njs\n```\n\n### Alpine or similar systems\n```bash\nsudo apk add nginx-module-njs@nginx\n```\n\n### SuSE, SLES or similar systems\n```bash\nsudo zypper install nginx-module-njs\n```\n\n\u003e [!TIP] \n\u003e The package repository includes an alternate module that enables debug symbols. Although not recommended for production environments, this module may be helpful when developing NJS-based configurations. To download and install the debug version of the module, replace the module name in the previous command with `nginx-module-njs-dbg`.\n\n## Installed files and locations\nThe package installation scripts install two modules, supporting NGINX [`http`](https://nginx.org/en/docs/http/ngx_http_core_module.html#http) and [`stream`](https://nginx.org/en/docs/stream/ngx_stream_core_module.html#stream) contexts.\n\n- [ngx_http_js_module](https://nginx.org/en/docs/http/ngx_http_js_module.html)\n\n    This NJS module enables manipulation of data transmitted over HTTP.\n- [ngx_stream_js_module](https://nginx.org/en/docs/stream/ngx_stream_js_module.html)\n\n    This NJS module enables manipulation of data transmitted via stream protocols such as TCP and UDP.\n\nBy default, both modules are installed into the `/etc/nginx/modules` directory.\n\n# Getting started with NGINX JavaScript\nUsage of NJS involves enabling the module, adding JavaScript files with defined functions, and invoking exported functions in NGINX configuration files.\n\n## Verify NGINX is running\nNGINX JavaScript is a module for NGINX Open Source or NGINX Plus. If you haven't done so already, follow these steps to install [NGINX Open Source](https://docs.nginx.com/nginx/admin-guide/installing-nginx/installing-nginx-open-source/) or [NGINX Plus](https://docs.nginx.com/nginx/admin-guide/installing-nginx/installing-nginx-plus/). Once installed, ensure the NGINX instance is running and able to respond to HTTP requests.\n\n### Starting NGINX\nIssue the following command to start NGINX:\n\n```bash\nsudo nginx\n```\n\n### Verify NGINX is responding to HTTP requests\n```bash\ncurl -I 127.0.0.1\n```\n\nYou should see the following response:\n```bash\nHTTP/1.1 200 OK\nServer: nginx/1.25.5\n```\n\n## Enabling the NGINX JavaScript modules\nOnce installed, either (or both) NJS module(s) must be included in the NGINX configuration file. On most systems, the NGINX configuration file is located at `/etc/nginx/nginx.conf` by default.\n\n### Edit the NGINX configuration file\n\n```bash\nsudo vi /etc/nginx/nginx.conf\n```\n\n### Enable dynamic loading of NJS modules\nUse the [load_module](https://nginx.org/en/docs/ngx_core_module.html#load_module) directive in the top-level (“main”) context to enable either (or both) module(s).\n\n```nginx\nload_module modules/ngx_http_js_module.so;\nload_module modules/ngx_stream_js_module.so;\n```\n\n## Basics of writing .js script files\nNJS script files are typically named with a .js extension and placed in the `/etc/nginx/njs/` directory. They are usually comprised of functions that are then exported, making them available in NGINX configuration files.\n\n## Reference of custom objects, methods, and properties\nNJS provides a collection of objects with associated methods and properties that are not part of ECMAScript definitions. See the [complete reference](https://nginx.org/en/docs/njs/reference.html) to these objects and how they can be used to further extend and customize NGINX.\n\n## Example: Hello World\nHere's a basic \"Hello World\" example.\n\n### example.js\nThe `hello` function in this file returns an HTTP 200 OK status response code along with the string \"Hello World!\", followed by a line feed. The function is then exported for use in an NGINX configuration file.\n\nAdd this file to the `/etc/nginx/njs` directory:\n\n```JavaScript\nfunction hello(r) {\n  r.return(200, \"Hello world!\\n\");\n}\n\nexport default {hello}\n```\n\n### nginx.conf\nWe modify our NGINX configuration (`/etc/nginx/nginx.conf`) to import the JavaScript file and execute the function under specific circumstances.\n\n```nginx\n# Load the ngx_http_js_module module\nload_module modules/ngx_http_js_module.so;\n\nevents {}\n\nhttp {\n  # Set the path to our njs JavaScript files\n  js_path \"/etc/nginx/njs/\";\n\n  # Import our JavaScript file into the variable \"main\"\n  js_import main from http/hello.js;\n\n  server {\n    listen 80;\n\n    location / {\n      # Execute the \"hello\" function defined in our JavaScript file on all HTTP requests\n      # and respond with the contents of our function.\n      js_content main.hello;\n    }\n  }\n}\n```\n\nFor a full list of njs directives, see the [ngx_http_js_module](https://nginx.org/en/docs/http/ngx_http_js_module.html) and [ngx_stream_js_module](https://nginx.org/en/docs/stream/ngx_stream_js_module.html) module documentation pages.\n\n\u003e [!TIP]\n\u003e A more detailed version of this and other examples can be found in the official [njs-examples repository](https://github.com/nginx/njs-examples/tree/master).\n\n## The NJS command line interface (CLI)\nNGINX JavaScript installs with a command line interface utility. The interface can be opened as an interactive shell or used to process JavaScript syntax from predefined files or standard input. Since the utility runs independently, NGINX-specific objects such as [HTTP](https://nginx.org/en/docs/njs/reference.html#http) and [Stream](https://nginx.org/en/docs/njs/reference.html#http) are not available within its runtime.\n\n### Example usage of the interactive CLI\n```JavaScript\n$ njs\n\u003e\u003e globalThis\nglobal {\n  njs: njs {\n    version: '0.8.4'\n  },\n  global: [Circular],\n  process: process {\n    argv: ['/usr/bin/njs'],\n    env: {\n      PATH: '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',\n      HOSTNAME: 'f777c149d4f8',\n      TERM: 'xterm',\n      NGINX_VERSION: '1.25.5',\n      NJS_VERSION: '0.8.4',\n      PKG_RELEASE: '1~buster',\n      HOME: '/root'\n    }\n  },\n  console: {\n    log: [Function: native],\n    dump: [Function: native],\n    time: [Function: native],\n    timeEnd: [Function: native]\n  },\n  print: [Function: native]\n}\n\u003e\u003e\n```\n\n### Example usage of the non-interactive CLI\n```bash\n$ echo \"2**3\" | njs -q\n8\n```\n\n# Building from source\nThe following steps can be used to build NGINX JavaScript as a dynamic module to be integrated into NGINX or a standalone binary for use as a command line interface utility.\n\n\u003e [!IMPORTANT]\n\u003e To build the module for use with NGINX, you will also need to clone, configure and build NGINX by following the steps outlined in this document.\n\n## Installing dependencies\nMost Linux distributions will require several dependencies to be installed in order to build NGINX and NGINX JavaScript. The following instructions are specific to the `apt` package manager, widely available on most Ubuntu/Debian distributions and their derivatives.\n\n### Installing compiler and make utility\n\n```bash\nsudo apt install gcc make\n```\n\n### Installing dependency libraries\n\n```bash\nsudo apt install libpcre3-dev zlib1g-dev libssl-dev libxml2-dev libxslt-dev\n```\n\nFor building with [QuickJS](https://nginx.org/en/docs/njs/engine.html), you will also need to build the QuickJS library:\n\n```bash\ngit clone https://github.com/bellard/quickjs\ncd quickjs\nCFLAGS='-fPIC' make libquickjs.a\n```\n\n\u003e [!WARNING]\n\u003e This is the minimal set of dependency libraries needed to build NGINX and NJS. Other dependencies may be required if you choose to build NGINX with additional modules. Monitor the output of the `configure` command discussed in the following sections for information on which modules may be missing.\n\n## Cloning the NGINX JavaScript GitHub repository\nUsing your preferred method, clone the NGINX JavaScript repository into your development directory. See [Cloning a GitHub Repository](https://docs.github.com/en/repositories/creating-and-managing-repositories/cloning-a-repository) for additional help.\n\n```bash\nhttps://github.com/nginx/njs.git\n```\n\n## Building the standalone command line interface utility (Optional)\nThe following steps are optional and only needed if you choose to build NJS as a standalone utility.\n\n### Install dependencies\nTo use the NJS interactive shell, you will need to install the libedit-dev library\n\n```bash\nsudo apt install libedit-dev\n```\n\n### Configure and build\nRun the following commands from the root directory of your cloned repository:\n\n```bash\n./configure\n```\n\nBuild NGINX JavaScript:\n```bash\nmake\n```\n\nThe utility should now be available at `\u003cNJS_SRC_ROOT_DIR\u003e/build/njs`. See [The NJS Command Line Interface (CLI)](#the-njs-command-line-interface-cli) for information on usage.\n\n## Cloning the NGINX GitHub repository\nClone the NGINX source code repository in a directory outside of the previously cloned NJS source repository.\n\n```bash\nhttps://github.com/nginx/nginx.git\n```\n\n## Building NGINX JavaScript as a module of NGINX\nTo build NGINX JavaScript as a dynamic module, execute the following commands from the NGINX source code repository's root directory:\n\n\u003e [!NOTE]\n\u003e Replace `\u003cNJS_SRC_ROOT_DIR\u003e` with the actual path to your NJS source directory.\n\n```bash\nauto/configure --add-dynamic-module=\u003cNJS_SRC_ROOT_DIR\u003e/nginx\n```\n\nTo build with [QuickJS](https://nginx.org/en/docs/njs/engine.html) support, provide include and library path using `--with-cc-opt=` and `--with-ld-opt=` options:\n\n\u003e [!NOTE]\n\u003e Replace `\u003cNJS_SRC_ROOT_DIR\u003e` with the actual path to your NJS source directory and `\u003cQUICKJS_SRC_ROOT_DIR\u003e` with the actual path to your QuickJS source directory.\n\n```bash\nauto/configure --add-dynamic-module=\u003cNJS_SRC_ROOT_DIR\u003e/nginx \\\n    --with-cc-opt=\"-I\u003cQUICKJS_SRC_ROOT_DIR\u003e\" \\\n    --with-ld-opt=\"-L\u003cQUICKJS_SRC_ROOT_DIR\u003e\"\n```\n\n\u003e [!WARNING]\n\u003e By default, this method will only build the `ngx_http_js_module` module. To use NJS with the NGINX Stream module, you'll need to enable it during the `configure` step so it builds with the NGINX binary. Doing so will automatically compile the `ngx_stream_js_module` module when NJS is added to the build. One way of accomplishing this is to alter the `configure` step to:\n\u003e\n\u003e ```bash\n\u003e auto/configure --with-stream \\\n\u003e     --add-dynamic-module=\u003cNJS_SRC_ROOT_DIR\u003e/nginx\n\u003e ```\n\nCompile the module\n```bash\nmake\n```\n\n\u003e [!TIP]\n\u003e To build NGINX with NGINX JavaScript embedded into a single binary, alter the `configure` step to the following:\n\u003e ```bash\n\u003e auto/configure --add-module=\u003cNJS_SRC_ROOT_DIR\u003e/nginx\n\u003e ```\n\n### Install module\nIf built as a dynamic module(s), the NGINX JavaScript module(s) will be available in the `\u003cNGINX_SRC_ROOT_DIR\u003e/objs/` directory. The module(s) can then be copied to an existing NGINX installation and enabled. See [Enabling the NGINX JavaScript Modules](#enabling-the-nginx-javascipt-modules) for details.\n\n### Install compiled NGINX and NGINX JavaScript binaries\nAlternatively, you may choose to install the built NGINX and NGINX JavaScript binaries by issuing the following command:\n\n\u003e [!IMPORTANT]\n\u003e If built into the NGINX binary as a standard (not dynamic) module, this will be the easiest method of installation\n\n```bash\nmake install\n```\n\nBy default, the NGINX binary will be installed into `/usr/local/nginx/sbin/nginx`. The NGINX JavaScript module(s) will be copied to `/usr/local/nginx/modules/`.\n\n# NGINX JavaScript technical specifications\nTechnical specifications for NJS are identical to those of NGINX.\n\n## Supported distributions\nSee [Tested Operating Systems and Platforms](https://nginx.org/en/#tested_os_and_platforms) for a complete list of supported distributions. \n\n## Supported deployment environments\n- Container\n- Public cloud (AWS, Google Cloud Platform, Microsoft Azure)\n- Virtual machine\n\n## Supported NGINX versions\nNGINX JavaScript is supported by all NGINX Open Source versions starting with nginx-1.14 and all NGINX Plus versions starting with NGINX Plus R15.\n\n# Asking questions, reporting issues, and contributing\nWe encourage you to engage with us. Please see the [Contributing](CONTRIBUTING.md) guide for information on how to ask questions, report issues and contribute code.\n\n# Change log\nSee our [release page](https://nginx.org/en/docs/njs/changes.html) to keep track of updates.\n\n# License\n[2-clause BSD-like license](LICENSE)\n\n---\nAdditional documentation available at: https://nginx.org/en/docs/njs/\n\n©2024 F5, Inc. All rights reserved.\nhttps://www.f5.com/products/nginx\n","funding_links":[],"categories":["C"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnginx%2Fnjs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnginx%2Fnjs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnginx%2Fnjs/lists"}