网页
综合
更新时间 2026-11-15 11:46:31
nginx JavaScript module
自动蜘蛛
nginx.org
正文约 968 字
njs is an nginx module that extends the server's functionality through JavaScript scripting, enabling the creation of custom server-side logic and more.
nginx calls JavaScript handlers at a fixed set of integration points: HTTP request and response processing phases, stream session phases, variable evaluation, and periodic timers. njs is not a standalone application runtime: it has no start-up script and no event loop of its own, JavaScript code runs only when nginx invokes a configured handler, and control returns to nginx once the handler completes.
See examples for more njs use cases.
To use njs in nginx:
create an njs script file, for example, http.js. See Reference for the list of njs properties and methods.
in the nginx.conf file, enable ngx_http_js_module module and specify the js_import directive with the http.js script file:
There is also a standalone command line utility that can be used independently of nginx for njs development and debugging.
本页为82搜索生成的网页快照,内容来自站内索引;演示数据的原文链接仅作示例。