Mercurial > hg > nginx-site
view xml/en/docs/njs/index.xml @ 2455:a81518fa3802
Removed obsolete note from Russian njs Reference.
author | Yaroslav Zhuravlev <yar@nginx.com> |
---|---|
date | Thu, 31 Oct 2019 15:34:18 +0300 |
parents | dce69c8e4c7d |
children | 73d254c3376d |
line wrap: on
line source
<?xml version="1.0"?> <!-- Copyright (C) Nginx, Inc. --> <!DOCTYPE article SYSTEM "../../../../dtd/article.dtd"> <article name="njs scripting language" link="/en/docs/njs/index.html" lang="en" rev="28" toc="no"> <section id="summary"> <para> njs is a subset of the JavaScript language that allows extending nginx functionality. njs is created in compliance with <link url="http://www.ecma-international.org/ecma-262/5.1/">ECMAScript 5.1</link> (strict mode) with some <link url="http://www.ecma-international.org/ecma-262/6.0/">ECMAScript 6</link> and later extensions. The compliance is still <link doc="compatibility.xml">evolving</link>. </para> </section> <section id="links"> <para> <list type="bullet"> <listitem> <link doc="install.xml"/> </listitem> <listitem> <link doc="changes.xml"/> </listitem> <listitem> <link doc="reference.xml"/> </listitem> <listitem> <link doc="examples.xml"/> </listitem> <listitem> <link doc="compatibility.xml"/> </listitem> <listitem> <link doc="cli.xml"/> </listitem> </list> </para> <para> <list type="bullet"> <listitem> <link doc="../http/ngx_http_js_module.xml"> ngx_http_js_module</link> </listitem> <listitem> <link doc="../stream/ngx_stream_js_module.xml"> ngx_stream_js_module</link> </listitem> </list> </para> </section> <section id="usecases" name="Use cases"> <para> <list type="bullet"> <listitem> Complex access control and security checks in njs before a request reaches an upstream server </listitem> <listitem> Manipulating response headers </listitem> <listitem> Writing flexible asynchronous content handlers and filters </listitem> </list> See <link doc="examples.xml">examples</link> and <link url="https://www.nginx.com/blog/tag/nginx-javascript-module/">blog posts</link> for more njs use cases. </para> </section> <section id="example" name="Basic HTTP Example"> <para> To use njs in nginx: <list type="bullet"> <listitem> <para> <link doc="install.xml">install</link> njs scripting language </para> </listitem> <listitem id="hello_world"> <para> create an njs script file, for example, <path>hello_world.js</path>. See <link doc="reference.xml">Reference</link> for the list of njs properties and methods. <example> function hello(r) { r.return(200, "Hello world!"); } </example> </para> </listitem> <listitem> <para> in the <path>nginx.conf</path> file, enable <link doc="../http/ngx_http_js_module.xml">ngx_http_js_module</link> module and specify the <link doc="../http/ngx_http_js_module.xml" id="js_include">js_include</link> directive with the <path>hello_world.js</path> script file: <example> load_module modules/ngx_http_js_module.so; events {} http { js_include hello_world.js; server { listen 8000; location / { js_content hello; } } } </example> </para> </listitem> </list> There is also a standalone <link doc="cli.xml">command line</link> utility that can be used independently of nginx for njs development and debugging. </para> </section> <section id="presentation" name="Presentation at nginx.conf 2018"> <para><video id="Jc_L6UffFOs" /></para> </section> </article>