diff --git "a/nginx-docs.jsonl" "b/nginx-docs.jsonl" new file mode 100644--- /dev/null +++ "b/nginx-docs.jsonl" @@ -0,0 +1,151 @@ +{"path": "robots.txt", "extension": ".txt", "size_bytes": 72, "content": "User-Agent: *\nDisallow: /libxslt/\nSitemap: http://nginx.org/sitemap.xml\n", "encoding": "utf-8"} +{"path": "css\\style_en.css", "extension": ".css", "size_bytes": 7928, "content": "body {\n background: white;\n color: black;\n font-family: sans-serif;\n line-height: 1.4em;\n text-align: center;\n margin: 0;\n padding: 0;\n}\n\n#banner {\n background: black;\n color: #F2F2F2;\n line-height: 1.2em;\n padding: .3em 1em .3em 1em;\n box-shadow: 0 5px 10px black;\n}\n\n#banner a {\n color: #00B140;\n}\n\n#main {\n text-align: left;\n margin: 0 auto;\n min-width: 32em;\n max-width: 66em;\n}\n\n#menu {\n float: right;\n width: 13em;\n padding: 0;\n border-left: 2px solid #DDD;\n}\n.nav ul{\n margin:0;\n padding:20px;\n}\n.nav h1{\n padding:0 20px;\n}\n.nav ul li{\n list-style-type:none;\n padding:0;\n margin:0;\n}\n\n#content {\n margin-right: 13.5em;\n padding: 0 2.5em 0 1.5em;\n}\n\nh1 {\n display: block;\n font-size: 3em;\n text-align: left;\n margin: 0.5rem 0 0 0;\n}\n\nh1 img {\n width: 100%;\n}\n\nh2 {\n font-size: 2rem;\n line-height: 2.25rem;\n margin: 1rem 0 .5rem 0;\n overflow-wrap: break-word;\n}\n\nh4 {\n font-size: 1.5rem;\n margin: 2rem 0 .5rem 0;\n}\n/* Center field override */\ncenter h4 {\n text-align: left!important;\n}\n\nh5 {\n font-size: 1.25rem;\n text-align: center;\n margin: 0.25rem 0 0 0;\n}\n\np {\n text-align: justify;\n margin-bottom: 0;\n}\n\ntable.news p {\n margin-top: 0;\n}\n\ntable.news td {\n vertical-align: baseline;\n}\n\ntable.news .date {\n text-align: right;\n padding: 0.75rem 0.5rem 0 0;\n white-space: nowrap;\n}\n\ntable.donors td {\n vertical-align: baseline;\n}\n\ntable.donors li {\n text-align: left;\n}\n\n/* News Archive button */\n.dropbtn {\n background-color: #808080;\n color: white;\n padding: 0.3rem;\n font-size: 1rem;\n border: 1px solid #606060;\n}\n.dropdown {\n position: relative;\n display: inline-block;\n padding-bottom: 0.5em;\n}\n.dropdown-content {\n display: none;\n position: absolute;\n background-color: #f0f0f0;\n min-width: 160px;\n box-shadow: 0px 8px 12px 0px #909090;\n z-index: 1;\n}\n.dropdown-content a {\n padding: 0.33em;\n text-decoration: none;\n display: block;\n}\n.dropdown-content a:hover {background-color: #a0a0a0;}\n.dropdown:hover .dropdown-content {display: block;}\n.dropdown:hover .dropbtn {background-color: #909090;}\n\ndiv.directive {\n background: #F2F2F2;\n line-height: 1em;\n margin: 1em 0 1em -1em;\n padding: .7em .7em .7em 1em;\n border-top: 2px solid #DDD;\n width:100%;\n}\n\ndiv.directive th {\n padding-left: 0;\n padding-right: .5em;\n vertical-align: baseline;\n text-align: left;\n font-weight: normal;\n}\n\ndiv.directive td {\n vertical-align: baseline;\n}\n\ndiv.directive pre {\n padding: 0;\n margin: 0;\n}\n\ndiv.directive code {\n background: none!important;\n padding: 0!important;\n border: none;\n}\n\ndiv.directive p {\n margin: .5em 0 0 .1em;\n font-size: .8em;\n}\n\na.notrans {\n color: #808080;\n text-decoration:none;\n}\n\nspan.initial {\n font-size: 200%;\n float: left;\n padding-right: 10pt;\n}\n\nul, ol {\n margin: .5em 0 1em 1em;\n padding: 0 .5em;\n}\n\nol {\n list-style-position: inside;\n}\n\nli {\n padding: .5em 0 0 1px;\n}\n\n.compact li {\n padding-top: 0;\n}\n\ndl {\n margin: .5em 0 1em 0;\n}\n\ndt {\n margin: 1em 0 0 0!important;\n font-size: 0.9rem;\n}\n\n.compact dt {\n margin-bottom: .2em;\n}\n\ndd {\n margin: 0.25rem 0 1.5rem 1rem;\n padding-left: 1px;\n text-align: justify;\n}\n\ntd.list {\n background: #f2f2f2;\n}\n\nblockquote {\n margin: 0.5rem 0 0 0;\n padding: 0;\n}\n\nli blockquote, dd blockquote {\n margin: .7em 0;\n}\n\nblockquote.note {\n padding: 0.5rem;\n border: 1px dotted #999;\n line-height: 1.2em;\n text-align: justify;\n}\n\npre {\n border: 0;\n display: block;\n margin: 1em 0;\n padding: 0.6em 1em;\n overflow-x: auto;\n line-height: 1.05rem;\n}\n\ncode,.legacy{\n font-size: 100%;\n padding: 3px 7px;\n overflow-x: scroll;\n background: #eee;\n}\n\npre code{\n background: none;\n padding: 0;\n border-radius: 0;\n}\n\nblockquote pre {\n background-color: #f8f8f8!important;\n color: #222!important;\n margin: 0;\n border: 1px solid #ddd;\n}\n\nblockquote.terminal pre{\n background-color: #444!important;\n color: #fff!important;\n}\n\nblockquote.example {\n line-height: 1em;\n}\n\nsup {\n font-size: 50%;\n}\n\n.video {\n position: relative;\n padding-bottom: 56.25%;\n overflow: hidden;\n}\n\n.video iframe, .video object, .video embed {\n position: absolute;\n top:0;\n left:0;\n width:100%;\n height:100%;\n}\n\n@media screen and (max-width:750px) {\n #main {\n padding: 20px;\n min-width: inherit;\n }\n #main #content {\n width: 100%!important;\n padding: 0;\n border: none;\n }\n\n #banner-content {\n max-width: 70vw;\n }\n\n #menu {\n text-align: left;\n }\n\n /* Menu Mobile */\n :root {\n --white: #f9f9f9;\n --black: #000;\n --gray: #85888C;\n --green: #b6d7a8;\n color-scheme: light dark;\n } /* variables*/\n\n /* Nav menu */\n .nav {\n width: 15rem;\n height: 100%;\n max-height: 0;\n position: fixed;\n top: 50px;\n right: 0;\n border-left: 1px solid #909090;\n background-color: var(--white);\n overflow: hidden;\n transition: .5s ease-in-out;\n }\n .nav ul {\n margin: 0;\n padding: 20px;\n }\n .nav h1 {\n padding: 0 20px;\n }\n .nav ul li {\n list-style-type: none;\n padding:0;\n margin:0;\n }\n\n .hamb {\n cursor: pointer;\n float: right;\n position: absolute;\n top: 0;\n right: 0.25em;\n width: 3.5em;\n padding-top: 1.5em;\n z-index: 1100;\n }\n .hamb-line {\n background: var(--green);\n display: block;\n position: relative;\n height: 0.3em;\n width: 2.75em;\n border-radius:3px;\n }\n .hamb-line::before,.hamb-line::after {\n background: var(--green);\n content: '';\n display: block;\n height: 100%;\n position: absolute;\n transition: all .2s ease-in-out;\n width: 100%;\n border-radius:3px;\n }\n .hamb-line::before{\n top: 10px;\n }\n .hamb-line::after{\n top: -10px;\n }\n .side-menu {\n display: none;\n } /* Hide checkbox */\n .side-menu:checked ~ .nav{\n max-height: 100%;\n top: 50px;\n\n }\n .side-menu:checked ~ .hamb .hamb-line {\n background: transparent;\n }\n .side-menu:checked ~ .hamb .hamb-line::before {\n transform: rotate(-45deg);\n top: 0;\n }\n .side-menu:checked ~ .hamb .hamb-line::after {\n transform: rotate(45deg);\n top: 0;\n }\n\n code {\n white-space: pre-line;\n }\n}\n\n@media screen and (min-width:750px){\n .side-menu,.hamb-line {\n display: none;\n }\n}\n\n/* Dark Mode */\n@media (prefers-color-scheme: dark) {\n\tbody {\n\t\tbackground-color: #1c262d;\n color:#eee;\n\t}\n h1,h2,h3,h4,h5,h6,p {\n color: #eee;\n }\n a {\n color: #55A4F1;\n text-decoration: underline;\n }\n a:visited {\n color: #8b79c0!important;\n }\n .nav {\n background:var(--black);\n }\n #menu a {\n color: #55A4F1;\n }\n blockquote pre {\n color: #ddd!important;\n background: #0f1b29!important;\n border: 1px solid #132235;\n }\n div.directive {\n background: #0c1622!important;\n border-top: 2px solid #203c5e!important;\n }\n code {\n background:#0c1622;\n color: #ddd!important;\n }\n .lightimage {\n display: none!important;\n }\n .darkimageWrapper, .darkimage {\n display: block!important;\n }\n .dropbtn {background-color: #202020;}\n .dropdown-content {\n background-color: #404040;\n box-shadow: 0px 8px 12px 0px #101010;\n }\n .dropdown-content a:hover {background-color: #242424;}\n .dropdown:hover .dropbtn {background-color: #202020;}\n}\n", "encoding": "utf-8"} +{"path": "img\\nginx_logo.svg", "extension": ".svg", "size_bytes": 10689, "content": "\n\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n", "encoding": "utf-8"} +{"path": "img\\nginx_logo_dark.svg", "extension": ".svg", "size_bytes": 10634, "content": "\n\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n", "encoding": "utf-8"} +{"path": "en\\docs\\beginners_guide.html", "extension": ".html", "size_bytes": 18254, "content": "\nBeginner’s Guide
\n\nPlanning your ingress-nginx migration? Start here:\nkubernetes.nginx.org.\n\n

Beginner’s Guide

Starting, Stopping, and Reloading Configuration
Configuration File’s Structure
Serving Static Content
Setting Up a Simple Proxy Server
Setting Up FastCGI Proxying

\nThis guide gives a basic introduction to nginx and describes some\nsimple tasks that can be done with it.\nIt is supposed that nginx is already installed on the reader’s machine.\nIf it is not, see the Installing nginx page.\nThis guide describes how to start and stop nginx, and reload its\nconfiguration, explains the structure\nof the configuration file and describes how to set up nginx\nto serve out static content, how to configure nginx as a proxy\nserver, and how to connect it with a FastCGI application.\n

\nnginx has one master process and several worker processes.\nThe main purpose of the master process is to read and evaluate configuration,\nand maintain worker processes.\nWorker processes do actual processing of requests.\nnginx employs event-based model and OS-dependent mechanisms to efficiently\ndistribute requests among worker processes.\nThe number of worker processes is defined in the configuration file and\nmay be fixed for a given configuration or automatically adjusted to the\nnumber of available CPU cores (see\nworker_processes).\n

\nThe way nginx and its modules work is determined in the configuration file.\nBy default, the configuration file is named nginx.conf\nand placed in the directory\n/usr/local/nginx/conf,\n/etc/nginx, or\n/usr/local/etc/nginx.\n

Starting, Stopping, and Reloading Configuration

\nTo start nginx, run the executable file.\nOnce nginx is started, it can be controlled by invoking the executable\nwith the -s parameter.\nUse the following syntax:\n

\nnginx -s signal\n

\nWhere signal may be one of the following:\n

\nFor example, to stop nginx processes with waiting for the worker processes\nto finish serving current requests, the following command can be executed:\n

\nnginx -s quit\n

\n

This command should be executed under the same user that\nstarted nginx.

\n

\nChanges made in the configuration file\nwill not be applied until the command to reload configuration is\nsent to nginx or it is restarted.\nTo reload configuration, execute:\n

\nnginx -s reload\n

\n

\nOnce the master process receives the signal to reload configuration,\nit checks the syntax validity\nof the new configuration file and tries to apply the configuration provided\nin it.\nIf this is a success, the master process starts new worker processes\nand sends messages to old worker processes, requesting them to\nshut down.\nOtherwise, the master process rolls back the changes and\ncontinues to work with the old configuration.\nOld worker processes, receiving a command to shut down,\nstop accepting new connections and continue to service current requests until\nall such requests are serviced.\nAfter that, the old worker processes exit.\n

\nA signal may also be sent to nginx processes with the help of Unix tools\nsuch as the kill utility.\nIn this case a signal is sent directly to a process with a given process ID.\nThe process ID of the nginx master process is written, by default, to the\nnginx.pid in the directory\n/usr/local/nginx/logs or\n/var/run.\nFor example, if the master process ID is 1628, to send the QUIT signal\nresulting in nginx’s graceful shutdown, execute:\n

\nkill -s QUIT 1628\n

\nFor getting the list of all running nginx processes, the ps\nutility may be used, for example, in the following way:\n

\nps -ax | grep nginx\n

\nFor more information on sending signals to nginx, see\nControlling nginx.\n

Configuration File’s Structure

\nnginx consists of modules which are controlled by directives specified\nin the configuration file.\nDirectives are divided into simple directives and block directives.\nA simple directive consists of the name and parameters separated by spaces\nand ends with a semicolon (;).\nA block directive has the same structure as a simple directive, but\ninstead of the semicolon it ends with a set of additional instructions\nsurrounded by braces ({ and }).\nIf a block directive can have other directives inside braces,\nit is called a context (examples:\nevents,\nhttp,\nserver,\nand\nlocation).\n

\nDirectives placed in the configuration file outside\nof any contexts are considered to be in the\nmain context.\nThe events and http directives\nreside in the main context, server\nin http, and location in\nserver.\n

\nThe rest of a line after the # sign is considered a comment.\n

Serving Static Content

\nAn important web server task is serving out\nfiles (such as images or static HTML pages).\nYou will implement an example where, depending on the request,\nfiles will be served from different local directories: /data/www\n(which may contain HTML files) and /data/images\n(containing images).\nThis will require editing of the configuration file and setting up of a\nserver\nblock inside the http\nblock with two location\nblocks.\n

\nFirst, create the /data/www directory and put an\nindex.html file with any text content into it and\ncreate the /data/images directory and place some\nimages in it.\n

\nNext, open the configuration file.\nThe default configuration file already includes several examples of\nthe server block, mostly commented out.\nFor now comment out all such blocks and start a new\nserver block:\n

\nhttp {\n    server {\n    }\n}\n

\nGenerally, the configuration file may include several\nserver blocks\ndistinguished by ports on which\nthey listen to\nand by\nserver names.\nOnce nginx decides which server processes a request,\nit tests the URI specified in the request’s header against the parameters of the\nlocation directives defined inside the\nserver block.\n

\nAdd the following location block to the\nserver block:\n

\nlocation / {\n    root /data/www;\n}\n

\nThis location block specifies the\n“/” prefix compared with the URI from the request.\nFor matching requests, the URI will be added to the path specified in the\nroot\ndirective, that is, to /data/www,\nto form the path to the requested file on the local file system.\nIf there are several matching location blocks nginx\nselects the one with the longest prefix.\nThe location block above provides the shortest\nprefix, of length one,\nand so only if all other location\nblocks fail to provide a match, this block will be used.\n

\nNext, add the second location block:\n

\nlocation /images/ {\n    root /data;\n}\n

\nIt will be a match for requests starting with /images/\n(location / also matches such requests,\nbut has shorter prefix).\n

\nThe resulting configuration of the server block should\nlook like this:\n

\nserver {\n    location / {\n        root /data/www;\n    }\n\n    location /images/ {\n        root /data;\n    }\n}\n

\nThis is already a working configuration of a server that listens\non the standard port 80 and is accessible on the local machine at\nhttp://localhost/.\nIn response to requests with URIs starting with /images/,\nthe server will send files from the /data/images directory.\nFor example, in response to the\nhttp://localhost/images/example.png request nginx will\nsend the /data/images/example.png file.\nIf such file does not exist, nginx will send a response\nindicating the 404 error.\nRequests with URIs not starting with /images/ will be\nmapped onto the /data/www directory.\nFor example, in response to the\nhttp://localhost/some/example.html request nginx will\nsend the /data/www/some/example.html file.\n

\nTo apply the new configuration, start nginx if it is not yet started or\nsend the reload signal to the nginx’s master process,\nby executing:\n

\nnginx -s reload\n

\n

\n

\nIn case something does not work as expected, you may try to find out\nthe reason in access.log and\nerror.log files in the directory\n/usr/local/nginx/logs or\n/var/log/nginx.\n

\n

Setting Up a Simple Proxy Server

\nOne of the frequent uses of nginx is setting it up as a proxy server, which\nmeans a server that receives requests, passes them to the proxied servers,\nretrieves responses from them, and sends them to the clients.\n

\nWe will configure a basic proxy server, which serves requests of\nimages with files from the local directory and sends all other requests to a\nproxied server.\nIn this example, both servers will be defined on a single nginx instance.\n

\nFirst, define the proxied server by adding one more server\nblock to the nginx’s configuration file with the following contents:\n

\nserver {\n    listen 8080;\n    root /data/up1;\n\n    location / {\n    }\n}\n

\nThis will be a simple server that listens on the port 8080\n(previously, the listen directive has not been specified\nsince the standard port 80 was used) and maps\nall requests to the /data/up1 directory on the local\nfile system.\nCreate this directory and put the index.html file into it.\nNote that the root directive is placed in the\nserver context.\nSuch root directive is used when the\nlocation block selected for serving a request does not\ninclude its own root directive.\n

\nNext, use the server configuration from the previous section\nand modify it to make it a proxy server configuration.\nIn the first location block, put the\nproxy_pass\ndirective with the protocol, name and port of the proxied server specified\nin the parameter (in our case, it is http://localhost:8080):\n

\nserver {\n    location / {\n        proxy_pass http://localhost:8080;\n    }\n\n    location /images/ {\n        root /data;\n    }\n}\n

\n

\nWe will modify the second location\nblock, which currently maps requests with the /images/\nprefix to the files under the /data/images directory,\nto make it match the requests of images with typical file extensions.\nThe modified location block looks like this:\n

\nlocation ~ \\.(gif|jpg|png)$ {\n    root /data/images;\n}\n

\nThe parameter is a regular expression matching all URIs ending\nwith .gif, .jpg, or .png.\nA regular expression should be preceded with ~.\nThe corresponding requests will be mapped to the /data/images\ndirectory.\n

\nWhen nginx selects a location block to serve a request\nit first checks location\ndirectives that specify prefixes, remembering location\nwith the longest prefix, and then checks regular expressions.\nIf there is a match with a regular expression, nginx picks this\nlocation or, otherwise, it picks the one remembered earlier.\n

\nThe resulting configuration of a proxy server will look like this:\n

\nserver {\n    location / {\n        proxy_pass http://localhost:8080/;\n    }\n\n    location ~ \\.(gif|jpg|png)$ {\n        root /data/images;\n    }\n}\n

\nThis server will filter requests ending with .gif,\n.jpg, or .png\nand map them to the /data/images directory (by adding URI to the\nroot directive’s parameter) and pass all other requests\nto the proxied server configured above.\n

\nTo apply new configuration, send the reload signal to\nnginx as described in the previous sections.\n

\nThere are many more\ndirectives that may be used to further configure a proxy connection.\n

Setting Up FastCGI Proxying

\nnginx can be used to route requests to FastCGI servers which run\napplications built with various frameworks and programming languages\nsuch as PHP.\n

\nThe most basic nginx configuration to work with a FastCGI server\nincludes using the\nfastcgi_pass\ndirective instead of the proxy_pass directive,\nand fastcgi_param\ndirectives to set parameters passed to a FastCGI server.\nSuppose the FastCGI server is accessible on localhost:9000.\nTaking the proxy configuration from the previous section as a basis,\nreplace the proxy_pass directive with the\nfastcgi_pass directive and change the parameter to\nlocalhost:9000.\nIn PHP, the SCRIPT_FILENAME parameter is used for\ndetermining the script name, and the QUERY_STRING\nparameter is used to pass request parameters.\nThe resulting configuration would be:\n

\nserver {\n    location / {\n        fastcgi_pass  localhost:9000;\n        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;\n        fastcgi_param QUERY_STRING    $query_string;\n    }\n\n    location ~ \\.(gif|jpg|png)$ {\n        root /data/images;\n    }\n}\n

\nThis will set up a server that will route all requests except for\nrequests for static images to the proxied server operating on\nlocalhost:9000 through the FastCGI protocol.\n

\n", "encoding": "utf-8"} +{"path": "en\\docs\\configure.html", "extension": ".html", "size_bytes": 35145, "content": "\nBuilding nginx from Sources
\n\nPlanning your ingress-nginx migration? Start here:\nkubernetes.nginx.org.\n\n

Building nginx from Sources

\nThe build is configured using the configure command.\nIt defines various aspects of the system, including the methods nginx\nis allowed to use for connection processing.\nAt the end it creates a Makefile.\n

\nThe configure command supports the following parameters:\n

\n

\n\n
\n--help\n
\n
\nprints a help message.\n
\n\n

\n

\n

\n\n
\n--prefix=path\n
\n
\ndefines a directory that will keep server files.\nThis same directory will also be used for all relative paths set by\nconfigure (except for paths to libraries sources)\nand in the nginx.conf configuration file.\nIt is set to the /usr/local/nginx directory by default.\n
\n\n
\n--sbin-path=path\n
\n
\nsets the name of an nginx executable file.\nThis name is used only during installation.\nBy default the file is named\nprefix/sbin/nginx.\n
\n\n
\n--modules-path=path\n
\n
\ndefines a directory where nginx dynamic modules will be installed.\nBy default the prefix/modules directory is used.\n
\n\n
\n--conf-path=path\n
\n
\nsets the name of an nginx.conf configuration file.\nIf needs be, nginx can always be started with a different configuration file,\nby specifying it in the command-line parameter\n-c file.\nBy default the file is named\nprefix/conf/nginx.conf.\n
\n\n
\n--error-log-path=path\n
\n
\nsets the name of the primary error, warnings, and diagnostic file.\nAfter installation, the file name can always be changed in the\nnginx.conf configuration file using the\nerror_log directive.\nBy default the file is named\nprefix/logs/error.log.\n
\n\n
\n--pid-path=path\n
\n
\nsets the name of an nginx.pid file\nthat will store the process ID of the main process.\nAfter installation, the file name can always be changed in the\nnginx.conf configuration file using the\npid directive.\nBy default the file is named\nprefix/logs/nginx.pid.\n
\n\n
\n--lock-path=path\n
\n
\nsets a prefix for the names of lock files.\nAfter installation, the value can always be changed in the\nnginx.conf configuration file using the\nlock_file directive.\nBy default the value is\nprefix/logs/nginx.lock.\n
\n\n

\n

\n

\n\n
\n--user=name\n
\n
\nsets the name of an unprivileged user whose credentials will be used\nby worker processes.\nAfter installation, the name can always be changed in the\nnginx.conf configuration file using the\nuser directive.\nThe default user name is nobody.\n
\n\n
\n--group=name\n
\n
\nsets the name of a group whose credentials will be used\nby worker processes.\nAfter installation, the name can always be changed in the\nnginx.conf configuration file using the\nuser directive.\nBy default, a group name is set to the name of an unprivileged user.\n
\n\n

\n

\n

\n\n
\n--build=name\n
\n
\nsets an optional nginx build name.\n
\n\n
\n--builddir=path\n
\n
\nsets a build directory.\n
\n\n

\n

\n

\n\n
\n--with-select_module
\n--without-select_module\n
\n
\nenables or disables building a module that allows the server to work\nwith the select() method.\nThis module is built automatically if the platform does not appear\nto support more appropriate methods such as kqueue, epoll, or /dev/poll.\n
\n\n
\n--with-poll_module
\n--without-poll_module\n
\n
\nenables or disables building a module that allows the server to work\nwith the poll() method.\nThis module is built automatically if the platform does not appear\nto support more appropriate methods such as kqueue, epoll, or /dev/poll.\n
\n\n
\n--with-threads\n
\n
\nenables the use of\nthread pools.\n
\n\n
\n--with-file-aio\n
\n
\nenables the use of\nasynchronous file I/O\n(AIO) on FreeBSD and Linux.\n
\n\n

\n

\n

\n\n
\n--with-http_ssl_module\n
\n
\nenables building a module that adds the\nHTTPS protocol support\nto an HTTP server.\nThis module is not built by default.\nThe OpenSSL library is required to build and run this module.\n
\n\n
\n--with-http_v2_module\n
\n
\nenables building a module that provides support for\nHTTP/2.\nThis module is not built by default.\n
\n\n
\n--with-http_v3_module\n
\n
\nenables building a module that provides support for\nHTTP/3.\nThis module is not built by default.\nThe OpenSSL library that provides HTTP/3 support\nis required to build and run this module.\n
\n\n
\n--with-http_realip_module\n
\n
\nenables building the\nngx_http_realip_module\nmodule that changes the client address to the address\nsent in the specified header field.\nThis module is not built by default.\n
\n\n
\n--with-http_addition_module\n
\n
\nenables building the\nngx_http_addition_module\nmodule that adds text before and after a response.\nThis module is not built by default.\n
\n\n
\n--with-http_xslt_module
\n--with-http_xslt_module=dynamic\n
\n
\nenables building the\nngx_http_xslt_module\nmodule that transforms XML responses using one or more XSLT stylesheets.\nThis module is not built by default.\nThe libxml2 and\nlibxslt libraries\nare required to build and run this module.\n
\n\n
\n--with-http_image_filter_module
\n--with-http_image_filter_module=dynamic\n
\n
\nenables building the\nngx_http_image_filter_module\nmodule that transforms images in JPEG, GIF, PNG, and WebP formats.\nThis module is not built by default.\n
\n\n
\n--with-http_geoip_module
\n--with-http_geoip_module=dynamic\n
\n
\nenables building the\nngx_http_geoip_module\nmodule that creates variables depending on the client IP address\nand the precompiled\nMaxMind databases.\nThis module is not built by default.\n
\n\n
\n--with-http_sub_module\n
\n
\nenables building the\nngx_http_sub_module\nmodule that modifies a response by replacing one specified string by another.\nThis module is not built by default.\n
\n\n
\n--with-http_dav_module\n
\n
\nenables building the\nngx_http_dav_module\nmodule that provides file management automation via the WebDAV protocol.\nThis module is not built by default.\n
\n\n
\n--with-http_flv_module\n
\n
\nenables building the\nngx_http_flv_module\nmodule that provides pseudo-streaming server-side support\nfor Flash Video (FLV) files.\nThis module is not built by default.\n
\n\n
\n--with-http_mp4_module\n
\n
\nenables building the\nngx_http_mp4_module\nmodule that provides pseudo-streaming server-side support\nfor MP4 files.\nThis module is not built by default.\n
\n\n
\n--with-http_gunzip_module\n
\n
\nenables building the\nngx_http_gunzip_module\nmodule that decompresses responses\nwith “Content-Encoding: gzip”\nfor clients that do not support “gzip” encoding method.\nThis module is not built by default.\n
\n\n
\n--with-http_gzip_static_module\n
\n
\nenables building the\nngx_http_gzip_static_module\nmodule that enables sending precompressed files\nwith the “.gz” filename extension instead of regular files.\nThis module is not built by default.\n
\n\n
\n--with-http_auth_request_module\n
\n
\nenables building the\nngx_http_auth_request_module\nmodule that implements client authorization\nbased on the result of a subrequest.\nThis module is not built by default.\n
\n\n
\n--with-http_random_index_module\n
\n
\nenables building the\nngx_http_random_index_module\nmodule that processes requests\nending with the slash character (‘/’) and picks a random\nfile in a directory to serve as an index file.\nThis module is not built by default.\n
\n\n
\n--with-http_secure_link_module\n
\n
\nenables building the\nngx_http_secure_link_module\nmodule.\nThis module is not built by default.\n
\n\n
\n--with-http_degradation_module\n
\n
\nenables building the\nngx_http_degradation_module module.\nThis module is not built by default.\n
\n\n
\n--with-http_slice_module\n
\n
\nenables building the\nngx_http_slice_module\nmodule that splits a request into subrequests,\neach returning a certain range of response.\nThe module provides more effective caching of big responses.\nThis module is not built by default.\n
\n\n
\n--with-http_stub_status_module\n
\n
\nenables building the\nngx_http_stub_status_module\nmodule that provides access to basic status information.\nThis module is not built by default.\n
\n\n

\n

\n

\n\n
\n--without-http_charset_module\n
\n
\ndisables building the\nngx_http_charset_module\nmodule that adds the specified charset to the\n“Content-Type” response header field\nand can additionally convert data from one charset to another.\n
\n\n
\n--without-http_gzip_module\n
\n
\ndisables building a module\nthat compresses responses\nof an HTTP server.\nThe zlib library is required to build and run this module.\n
\n\n
\n--without-http_ssi_module\n
\n
\ndisables building the\nngx_http_ssi_module\nmodule that processes SSI (Server Side Includes) commands in responses\npassing through it.\n
\n\n
\n--without-http_userid_module\n
\n
\ndisables building the\nngx_http_userid_module\nmodule that sets cookies suitable for client identification.\n
\n\n
\n--without-http_access_module\n
\n
\ndisables building the\nngx_http_access_module\nmodule that allows limiting access to certain client addresses.\n
\n\n
\n--without-http_auth_basic_module\n
\n
\ndisables building the\nngx_http_auth_basic_module\nmodule that allows limiting access to resources by validating the user name\nand password using the “HTTP Basic Authentication” protocol.\n
\n\n
\n--without-http_mirror_module\n
\n
\ndisables building the\nngx_http_mirror_module\nmodule that implements mirroring of an original request\nby creating background mirror subrequests.\n
\n\n
\n--without-http_autoindex_module\n
\n
\ndisables building the\nngx_http_autoindex_module\nmodule that processes requests\nending with the slash character (‘/’) and produces\na directory listing in case the\nngx_http_index_module module\ncannot find an index file.\n
\n\n
\n--without-http_geo_module\n
\n
\ndisables building the\nngx_http_geo_module\nmodule that creates variables\nwith values depending on the client IP address.\n
\n\n
\n--without-http_map_module\n
\n
\ndisables building the\nngx_http_map_module\nmodule that creates variables\nwith values depending on values of other variables.\n
\n\n
\n--without-http_split_clients_module\n
\n
\ndisables building the\nngx_http_split_clients_module\nmodule that creates variables for A/B testing.\n
\n\n
\n--without-http_referer_module\n
\n
\ndisables building the\nngx_http_referer_module\nmodule that can block access to a site for requests with invalid values\nin the “Referer” header field.\n
\n\n
\n--without-http_rewrite_module\n
\n
\ndisables building a module that allows an HTTP server to\nredirect requests and change URI\nof requests.\nThe PCRE library is required to build and run this module.\n
\n\n
\n--without-http_proxy_module\n
\n
\ndisables building an HTTP server\nproxying module.\n\n
\n\n
\n--without-http_fastcgi_module\n
\n
\ndisables building the\nngx_http_fastcgi_module\nmodule that passes requests to a FastCGI server.\n
\n\n
\n--without-http_uwsgi_module\n
\n
\ndisables building the\nngx_http_uwsgi_module\nmodule that passes requests to a uwsgi server.\n
\n\n
\n--without-http_scgi_module\n
\n
\ndisables building the\nngx_http_scgi_module\nmodule that passes requests to an SCGI server.\n
\n\n
\n--without-http_grpc_module\n
\n
\ndisables building the\nngx_http_grpc_module\nmodule that passes requests to a gRPC server.\n
\n\n
\n--without-http_memcached_module\n
\n
\ndisables building the\nngx_http_memcached_module\nmodule that obtains responses from a memcached server.\n
\n\n
\n--without-http_limit_conn_module\n
\n
\ndisables building the\nngx_http_limit_conn_module\nmodule that limits the number of connections per key, for example,\nthe number of connections from a single IP address.\n
\n\n
\n--without-http_limit_req_module\n
\n
\ndisables building the\nngx_http_limit_req_module\nmodule that limits the request processing rate per key, for example,\nthe processing rate of requests coming from a single IP address.\n
\n\n
\n--without-http_empty_gif_module\n
\n
\ndisables building a module that\nemits single-pixel\ntransparent GIF.\n
\n\n
\n--without-http_browser_module\n
\n
\ndisables building the\nngx_http_browser_module\nmodule that creates variables whose values depend on the value of the\n“User-Agent” request header field.\n
\n\n
\n--without-http_upstream_hash_module\n
\n
\ndisables building a module that implements the\nhash\nload balancing method.\n
\n\n
\n--without-http_upstream_ip_hash_module\n
\n
\ndisables building a module that implements the\nip_hash\nload balancing method.\n
\n\n
\n--without-http_upstream_least_conn_module\n
\n
\ndisables building a module that implements the\nleast_conn\nload balancing method.\n
\n\n
\n--without-http_upstream_least_time_module\n
\n
\ndisables building a module that implements the\nleast_time\nload balancing method.\n
\n\n
\n--without-http_upstream_random_module\n
\n
\ndisables building a module that implements the\nrandom\nload balancing method.\n
\n\n
\n--without-http_upstream_keepalive_module\n
\n
\ndisables building a module that provides\ncaching of\nconnections to upstream servers.\n
\n\n
\n--without-http_upstream_zone_module\n
\n
\ndisables building a module that makes it possible to store run-time state\nof an upstream group in a shared memory\nzone.\n
\n\n
\n--without-http_upstream_sticky_module\n
\n
\ndisables building a module that provides\nsession\naffinity to upstream servers.\n
\n\n

\n

\n

\n\n
\n--with-http_perl_module
\n--with-http_perl_module=dynamic\n
\n
\nenables building the\nembedded Perl module.\nThis module is not built by default.\n
\n\n
\n--with-perl_modules_path=path\n
\n
\ndefines a directory that will keep Perl modules.\n
\n\n
\n--with-perl=path\n
\n
\nsets the name of the Perl binary.\n
\n\n

\n

\n

\n\n
\n--http-log-path=path\n
\n
\nsets the name of the primary request log file of the HTTP server.\nAfter installation, the file name can always be changed in the\nnginx.conf configuration file using the\naccess_log directive.\nBy default the file is named\nprefix/logs/access.log.\n
\n\n
\n--http-client-body-temp-path=path\n
\n
\ndefines a directory for storing temporary files\nthat hold client request bodies.\nAfter installation, the directory can always be changed in the\nnginx.conf configuration file using the\nclient_body_temp_path\ndirective.\nBy default the directory is named\nprefix/client_body_temp.\n
\n\n
\n--http-proxy-temp-path=path\n
\n
\ndefines a directory for storing temporary files\nwith data received from proxied servers.\nAfter installation, the directory can always be changed in the\nnginx.conf configuration file using the\nproxy_temp_path\ndirective.\nBy default the directory is named\nprefix/proxy_temp.\n
\n\n
\n--http-fastcgi-temp-path=path\n
\n
\ndefines a directory for storing temporary files\nwith data received from FastCGI servers.\nAfter installation, the directory can always be changed in the\nnginx.conf configuration file using the\nfastcgi_temp_path\ndirective.\nBy default the directory is named\nprefix/fastcgi_temp.\n
\n\n
\n--http-uwsgi-temp-path=path\n
\n
\ndefines a directory for storing temporary files\nwith data received from uwsgi servers.\nAfter installation, the directory can always be changed in the\nnginx.conf configuration file using the\nuwsgi_temp_path\ndirective.\nBy default the directory is named\nprefix/uwsgi_temp.\n
\n\n
\n--http-scgi-temp-path=path\n
\n
\ndefines a directory for storing temporary files\nwith data received from SCGI servers.\nAfter installation, the directory can always be changed in the\nnginx.conf configuration file using the\nscgi_temp_path\ndirective.\nBy default the directory is named\nprefix/scgi_temp.\n
\n\n

\n

\n

\n\n
\n--without-http\n
\n
\ndisables the HTTP server.\n
\n\n
\n--without-http-cache\n
\n
\ndisables HTTP cache.\n
\n\n

\n

\n

\n\n
\n--with-mail
\n--with-mail=dynamic\n
\n
\nenables POP3/IMAP4/SMTP\nmail proxy server.\n
\n\n
\n--with-mail_ssl_module\n
\n
\nenables building a module that adds the\nSSL/TLS protocol support\nto the mail proxy server.\nThis module is not built by default.\nThe OpenSSL library is required to build and run this module.\n
\n\n
\n--without-mail_pop3_module\n
\n
\ndisables the POP3 protocol\nin mail proxy server.\n
\n\n
\n--without-mail_imap_module\n
\n
\ndisables the IMAP protocol\nin mail proxy server.\n
\n\n
\n--without-mail_smtp_module\n
\n
\ndisables the SMTP protocol\nin mail proxy server.\n
\n\n

\n

\n

\n\n
\n--with-stream
\n--with-stream=dynamic\n
\n
\nenables building the\nstream module\nfor generic TCP/UDP proxying and load balancing.\nThis module is not built by default.\n
\n\n
\n--with-stream_ssl_module\n
\n
\nenables building a module that adds the\nSSL/TLS protocol support\nto the stream module.\nThis module is not built by default.\nThe OpenSSL library is required to build and run this module.\n
\n\n
\n--with-stream_realip_module\n
\n
\nenables building the\nngx_stream_realip_module\nmodule that changes the client address to the address\nsent in the PROXY protocol header.\nThis module is not built by default.\n
\n\n
\n--with-stream_geoip_module
\n--with-stream_geoip_module=dynamic\n
\n
\nenables building the\nngx_stream_geoip_module\nmodule that creates variables depending on the client IP address\nand the precompiled\nMaxMind databases.\nThis module is not built by default.\n
\n\n
\n--with-stream_ssl_preread_module\n
\n
\nenables building the\nngx_stream_ssl_preread_module\nmodule that allows extracting information from the\nClientHello\nmessage without terminating SSL/TLS.\nThis module is not built by default.\n
\n\n
\n--without-stream_limit_conn_module\n
\n
\ndisables building the\nngx_stream_limit_conn_module\nmodule that limits the number of connections per key, for example,\nthe number of connections from a single IP address.\n
\n\n
\n--without-stream_access_module\n
\n
\ndisables building the\nngx_stream_access_module\nmodule that allows limiting access to certain client addresses.\n
\n\n
\n--without-stream_geo_module\n
\n
\ndisables building the\nngx_stream_geo_module\nmodule that creates variables\nwith values depending on the client IP address.\n
\n\n
\n--without-stream_map_module\n
\n
\ndisables building the\nngx_stream_map_module\nmodule that creates variables\nwith values depending on values of other variables.\n
\n\n
\n--without-stream_split_clients_module\n
\n
\ndisables building the\nngx_stream_split_clients_module\nmodule that creates variables for A/B testing.\n
\n\n
\n--without-stream_return_module\n
\n
\ndisables building the\nngx_stream_return_module\nmodule that sends some specified value to the client\nand then closes the connection.\n
\n\n
\n--without-stream_pass_module\n
\n
\ndisables building the\nngx_stream_pass_module\nmodule that passes accepted connections to other listening sockets.\n
\n\n
\n--without-stream_set_module\n
\n
\ndisables building the\nngx_stream_set_module\nmodule that sets a value for a variable.\n
\n\n
\n--without-stream_upstream_hash_module\n
\n
\ndisables building a module that implements the\nhash\nload balancing method.\n
\n\n
\n--without-stream_upstream_least_conn_module\n
\n
\ndisables building a module that implements the\nleast_conn\nload balancing method.\n
\n\n
\n--without-stream_upstream_least_time_module\n
\n
\ndisables building a module that implements the\nleast_time\nload balancing method.\n
\n\n
\n--without-stream_upstream_random_module\n
\n
\ndisables building a module that implements the\nrandom\nload balancing method.\n
\n\n
\n--without-stream_upstream_zone_module\n
\n
\ndisables building a module that makes it possible to store run-time state\nof an upstream group in a shared memory\nzone.\n
\n\n

\n

\n

\n\n
\n--with-google_perftools_module\n
\n
\nenables building the\nngx_google_perftools_module\nmodule that enables profiling of nginx worker processes using\nGoogle Performance Tools.\nThe module is intended for nginx developers and is not built by default.\n
\n\n
\n--with-cpp_test_module\n
\n
\nenables building the\nngx_cpp_test_module module.\n
\n\n

\n

\n

\n\n
\n--add-module=path\n
\n
\nenables an external module.\n
\n\n
\n--add-dynamic-module=path\n
\n
\nenables an external dynamic module.\n
\n\n

\n

\n

\n\n
\n--with-compat\n
\n
\nenables dynamic modules compatibility.\n
\n\n

\n

\n

\n\n
\n--with-cc=path\n
\n
\nsets the name of the C compiler.\n
\n\n
\n--with-cpp=path\n
\n
\nsets the name of the C preprocessor.\n
\n\n
\n--with-cc-opt=parameters\n
\n
\nsets additional parameters that will be added to the CFLAGS variable.\nWhen using the system PCRE library under FreeBSD,\n--with-cc-opt=\"-I /usr/local/include\"\nshould be specified.\nIf the number of files supported by select() needs to be\nincreased it can also be specified here such as this:\n--with-cc-opt=\"-D FD_SETSIZE=2048\".\n
\n\n
\n--with-ld-opt=parameters\n
\n
\nsets additional parameters that will be used during linking.\nWhen using the system PCRE library under FreeBSD,\n--with-ld-opt=\"-L /usr/local/lib\"\nshould be specified.\n
\n\n
\n--with-cpu-opt=cpu\n
\n
\nenables building per specified CPU:\npentium, pentiumpro,\npentium3, pentium4,\nathlon, opteron,\nsparc32, sparc64,\nppc64.\n
\n\n

\n

\n

\n\n
\n--without-pcre\n
\n
\ndisables the usage of the PCRE library.\n
\n\n
\n--with-pcre\n
\n
\nforces the usage of the PCRE library.\n
\n\n
\n--with-pcre=path\n
\n
\nsets the path to the sources of the PCRE library.\nThe library distribution needs to be downloaded from the\nPCRE site and extracted.\nThe rest is done by nginx’s ./configure and\nmake.\nThe library is required for regular expressions support in the\nlocation directive\nand for the\nngx_http_rewrite_module\nmodule.\n
\n\n
\n--with-pcre-opt=parameters\n
\n
\nsets additional build options for PCRE.\n
\n\n
\n--with-pcre-jit\n
\n
\nbuilds the PCRE library with\n“just-in-time compilation” support (1.1.12, the\npcre_jit directive).\n
\n\n
\n--without-pcre2\n
\n
\ndisables use of the PCRE2 library\ninstead of the original PCRE library (1.21.5).\n
\n\n

\n

\n

\n\n
\n--with-zlib=path\n
\n
\nsets the path to the sources of the zlib library.\nThe library distribution needs to be downloaded from the\nzlib site and extracted.\nThe rest is done by nginx’s ./configure and\nmake.\nThe library is required for the\nngx_http_gzip_module module.\n
\n\n
\n--with-zlib-opt=parameters\n
\n
\nsets additional build options for zlib.\n
\n\n
\n--with-zlib-asm=cpu\n
\n
\nenables the use of the zlib assembler sources optimized\nfor one of the specified CPUs:\npentium, pentiumpro.\n
\n\n

\n

\n

\n\n
\n--with-libatomic\n
\n
\nforces the libatomic_ops library usage.\n
\n\n
\n--with-libatomic=path\n
\n
\nsets the path to the libatomic_ops library sources.\n
\n\n

\n

\n

\n\n
\n--with-openssl=path\n
\n
\nsets the path to the OpenSSL library sources.\n
\n\n
\n--with-openssl-opt=parameters\n
\n
\nsets additional build options for OpenSSL.\n
\n\n

\n

\n

\n\n
\n--with-debug\n
\n
\nenables the debugging log.\n
\n\n

\n

\nExample of parameters usage (all of this needs to be typed in one line):\n

\n./configure\n    --sbin-path=/usr/local/nginx/nginx\n    --conf-path=/usr/local/nginx/nginx.conf\n    --pid-path=/usr/local/nginx/nginx.pid\n    --with-http_ssl_module\n    --with-pcre=../pcre2-10.39\n    --with-zlib=../zlib-1.3\n

\n

\nAfter configuration,\nnginx is compiled and installed using make.\n

\n", "encoding": "utf-8"} +{"path": "en\\docs\\contributing_changes.html", "extension": ".html", "size_bytes": 6629, "content": "\nContributing Changes
\n\nPlanning your ingress-nginx migration? Start here:\nkubernetes.nginx.org.\n\n

Contributing Changes

Getting Sources
Formatting Changes
Before Submitting
Submitting Changes
Website
License

Getting Sources

\nGitHub is used\nto store source code.\nThe repository can be cloned\nwith the following command:\n

\ngit clone https://github.com/nginx/nginx.git\n

\n

Formatting Changes

\nChanges should be formatted according to the\ncode style\nused by nginx.\nSometimes, there is no clear rule; in such cases\nexamine how existing nginx sources are formatted and mimic this style.\nChanges will more likely be accepted if style corresponds to the surrounding\ncode.\n

\nCommit\nthe changes in your nginx GitHub fork.\nPlease ensure that the specified\ne-mail\naddress and real name of the author are correct.\n

\nThe commit message should have a single-line synopsis followed by verbose\ndescription after an empty line.\nLimit the subject and commit message body lines to 72 characters.\nThe resulting commit can be obtained using the\ngit show command:\n

\ncommit 067d766f210ee914b750d79d9284cbf8801058f3\nAuthor: Zoey <username@example.com>\nDate:   Sun Apr 5 11:31:15 2026 +0200\n\n    Fix $request_port and $is_request_port in subrequests\n\n    Closes #1247.\n\ndiff --git a/src/http/ngx_http_core_module.c b/src/http/ngx_http_core_module.c\nindex 0c46106db..53ddf39bb 100644\n--- a/src/http/ngx_http_core_module.c\n+++ b/src/http/ngx_http_core_module.c\n@@ -2453,6 +2453,8 @@ ngx_http_subrequest(ngx_http_request_t *r,\n     sr->method = NGX_HTTP_GET;\n     sr->http_version = r->http_version;\n\n+    sr->port = r->port;\n+\n     sr->request_line = r->request_line;\n     sr->uri = *uri;\n\n

\n

Before Submitting

\nSeveral points are worth to consider before submitting changes:\n

\n

Submitting Changes

\nThe proposed changes should be submitted from your fork to\nnginx repository\nas a\npull request.\n

Website

\nGitHub is used to store the sources for this website.\nThe repository\ncan be cloned with the following command:\n

\ngit clone https://github.com/nginx/nginx.org.git\n

\nDocumentation changes should be submitted from your fork\nas a pull request.\n

License

\nSubmitting changes implies granting project a permission to use it under\nan appropriate license.\n

\n", "encoding": "utf-8"} +{"path": "en\\docs\\control.html", "extension": ".html", "size_bytes": 11358, "content": "\nControlling nginx
\n\nPlanning your ingress-nginx migration? Start here:\nkubernetes.nginx.org.\n\n

Controlling nginx

Changing Configuration
Rotating Log-files
Upgrading Executable on the Fly

\nnginx can be controlled with signals.\nThe process ID of the master process is written to the file\n/usr/local/nginx/logs/nginx.pid by default.\nThis name may be changed at configuration time, or in\nnginx.conf using the\npid\ndirective.\nThe master process supports the following signals:\n

\n\n\n\n\n\n\n\n\n\n
TERM, INTfast shutdown
QUITgraceful shutdown
HUPchanging configuration,\nkeeping up with a changed time zone (only for FreeBSD and Linux),\nstarting new worker processes with a new configuration,\ngraceful shutdown of old worker processes
USR1re-opening log files
USR2upgrading an executable file
WINCHgraceful shutdown of worker processes
\n

\n

\nIndividual worker processes can be controlled with signals as well,\nthough it is not required.\nThe supported signals are:\n

\n\n\n\n\n\n\n\n
TERM, INTfast shutdown
QUITgraceful shutdown
USR1re-opening log files
WINCHabnormal termination for debugging\n(requires debug_points to be enabled)\n
\n

\n

Changing Configuration

\nIn order for nginx to re-read the configuration file, a HUP\nsignal should be sent to the master process.\nThe master process first checks the syntax validity, then tries\nto apply new configuration, that is, to open log files and new\nlisten sockets.\nIf this fails, it rolls back changes and continues to work\nwith old configuration.\nIf this succeeds, it starts new worker processes, and\nsends messages to old worker processes requesting them to\nshut down gracefully.\nOld worker processes close listen sockets and continue to service\nold clients.\nAfter all clients are serviced, old worker processes are shut down.\n

\nLet’s illustrate this by example.\nImagine that nginx is run on FreeBSD and the command\n

\nps axw -o pid,ppid,user,%cpu,vsz,wchan,command | egrep '(nginx|PID)'\n

\nproduces the following output:\n

\n  PID  PPID USER    %CPU   VSZ WCHAN  COMMAND\n33126     1 root     0.0  1148 pause  nginx: master process /usr/local/nginx/sbin/nginx\n33127 33126 nobody   0.0  1380 kqread nginx: worker process (nginx)\n33128 33126 nobody   0.0  1364 kqread nginx: worker process (nginx)\n33129 33126 nobody   0.0  1364 kqread nginx: worker process (nginx)\n

\n

\nIf HUP is sent to the master process, the output becomes:\n

\n  PID  PPID USER    %CPU   VSZ WCHAN  COMMAND\n33126     1 root     0.0  1164 pause  nginx: master process /usr/local/nginx/sbin/nginx\n33129 33126 nobody   0.0  1380 kqread nginx: worker process is shutting down (nginx)\n33134 33126 nobody   0.0  1368 kqread nginx: worker process (nginx)\n33135 33126 nobody   0.0  1368 kqread nginx: worker process (nginx)\n33136 33126 nobody   0.0  1368 kqread nginx: worker process (nginx)\n

\n

\nOne of the old worker processes with PID 33129 still continues to work.\nAfter some time it exits:\n

\n  PID  PPID USER    %CPU   VSZ WCHAN  COMMAND\n33126     1 root     0.0  1164 pause  nginx: master process /usr/local/nginx/sbin/nginx\n33134 33126 nobody   0.0  1368 kqread nginx: worker process (nginx)\n33135 33126 nobody   0.0  1368 kqread nginx: worker process (nginx)\n33136 33126 nobody   0.0  1368 kqread nginx: worker process (nginx)\n

\n

Rotating Log-files

\nIn order to rotate log files, they need to be renamed first.\nAfter that USR1 signal should be sent to the master process.\nThe master process will then re-open all currently open log files and\nassign them an unprivileged user under which the worker processes\nare running, as an owner.\nAfter successful re-opening, the master process closes all open files and\nsends the message to worker process to ask them to re-open files.\nWorker processes also open new files and close old files right away.\nAs a result, old files are almost immediately available for post\nprocessing, such as compression.\n

Upgrading Executable on the Fly

\nIn order to upgrade the server executable, the new executable file\nshould be put in place of an old file first.\nAfter that USR2 signal should be sent to the master process.\nThe master process first renames its file with the process ID to a\nnew file with the .oldbin suffix, e.g.\n/usr/local/nginx/logs/nginx.pid.oldbin,\nthen starts a new executable file that in turn starts new\nworker processes:\n

\n  PID  PPID USER    %CPU   VSZ WCHAN  COMMAND\n33126     1 root     0.0  1164 pause  nginx: master process /usr/local/nginx/sbin/nginx\n33134 33126 nobody   0.0  1368 kqread nginx: worker process (nginx)\n33135 33126 nobody   0.0  1380 kqread nginx: worker process (nginx)\n33136 33126 nobody   0.0  1368 kqread nginx: worker process (nginx)\n36264 33126 root     0.0  1148 pause  nginx: master process /usr/local/nginx/sbin/nginx\n36265 36264 nobody   0.0  1364 kqread nginx: worker process (nginx)\n36266 36264 nobody   0.0  1364 kqread nginx: worker process (nginx)\n36267 36264 nobody   0.0  1364 kqread nginx: worker process (nginx)\n

\n

\nAfter that all worker processes (old and new ones) continue to accept requests.\nIf the WINCH signal is sent to the first master process, it will\nsend messages to its worker processes, requesting them to shut\ndown gracefully, and they will start to exit:\n

\n  PID  PPID USER    %CPU   VSZ WCHAN  COMMAND\n33126     1 root     0.0  1164 pause  nginx: master process /usr/local/nginx/sbin/nginx\n33135 33126 nobody   0.0  1380 kqread nginx: worker process is shutting down (nginx)\n36264 33126 root     0.0  1148 pause  nginx: master process /usr/local/nginx/sbin/nginx\n36265 36264 nobody   0.0  1364 kqread nginx: worker process (nginx)\n36266 36264 nobody   0.0  1364 kqread nginx: worker process (nginx)\n36267 36264 nobody   0.0  1364 kqread nginx: worker process (nginx)\n

\n

\nAfter some time, only the new worker processes will process requests:\n

\n  PID  PPID USER    %CPU   VSZ WCHAN  COMMAND\n33126     1 root     0.0  1164 pause  nginx: master process /usr/local/nginx/sbin/nginx\n36264 33126 root     0.0  1148 pause  nginx: master process /usr/local/nginx/sbin/nginx\n36265 36264 nobody   0.0  1364 kqread nginx: worker process (nginx)\n36266 36264 nobody   0.0  1364 kqread nginx: worker process (nginx)\n36267 36264 nobody   0.0  1364 kqread nginx: worker process (nginx)\n

\n

\nIt should be noted that the old master process does not close its listen\nsockets, and it can be managed to start its worker processes again if needed.\nIf for some reason the new executable file works unacceptably, one of the\nfollowing can be done:\n

\n\n

\nIf the new master process exits then the old master process discards\nthe .oldbin suffix from the file name with the process ID.\n

\nIf upgrade was successful, then the QUIT signal should be sent to\nthe old master process, and only new processes will stay:\n

\n  PID  PPID USER    %CPU   VSZ WCHAN  COMMAND\n36264     1 root     0.0  1148 pause  nginx: master process /usr/local/nginx/sbin/nginx\n36265 36264 nobody   0.0  1364 kqread nginx: worker process (nginx)\n36266 36264 nobody   0.0  1364 kqread nginx: worker process (nginx)\n36267 36264 nobody   0.0  1364 kqread nginx: worker process (nginx)\n

\n

\n", "encoding": "utf-8"} +{"path": "en\\docs\\debugging_log.html", "extension": ".html", "size_bytes": 5803, "content": "\nA debugging log
\n\nPlanning your ingress-nginx migration? Start here:\nkubernetes.nginx.org.\n\n

A debugging log

Debugging log for selected clients
Logging to a cyclic memory buffer

\nTo enable a debugging log, nginx needs to be configured to support\ndebugging during the build:\n\n

\n./configure --with-debug ...\n

\n\nThen the debug level should be set with the\nerror_log directive:\n\n

\nerror_log /path/to/log debug;\n

\n\nTo verify that nginx is configured to support debugging,\nrun the nginx -V command:\n\n

\nconfigure arguments: --with-debug ...\n

\n\nPre-built Linux packages\nprovide out-of-the-box support for debugging log with\nthe nginx-debug binary (1.9.8)\nwhich can be run using commands\n\n

\nservice nginx stop\nservice nginx-debug start\n

\n\nand then set the debug level.\nThe nginx binary version for Windows is always built with the debugging log\nsupport, so only setting the debug level will suffice.\n

\nNote that redefining the log without also specifying the\ndebug\nlevel will disable the debugging log.\nIn the example below, redefining the log on the\nserver\nlevel disables the debugging log for this server:\n

\nerror_log /path/to/log debug;\n\nhttp {\n    server {\n        error_log /path/to/log;\n        ...\n

\nTo avoid this, either the line redefining the log should be\ncommented out, or the debug level specification should\nalso be added:\n

\nerror_log /path/to/log debug;\n\nhttp {\n    server {\n        error_log /path/to/log debug;\n        ...\n

\n

Debugging log for selected clients

\nIt is also possible to enable the debugging log for\nselected\nclient addresses only:\n\n

\nerror_log /path/to/log;\n\nevents {\n    debug_connection 192.168.1.1;\n    debug_connection 192.168.10.0/24;\n}\n

\n

Logging to a cyclic memory buffer

\nThe debugging log can be written to a cyclic memory buffer:\n

\nerror_log memory:32m debug;\n

\nLogging to the memory buffer on the debug level\ndoes not have significant impact on performance even under high load.\nIn this case, the log can be extracted using\na gdb script like the following one:\n

\nset $log = ngx_cycle->log\n\nwhile $log->writer != ngx_log_memory_writer\n    set $log = $log->next\nend\n\nset $buf = (ngx_log_memory_buf_t *) $log->wdata\ndump binary memory debug_log.txt $buf->start $buf->end\n

\nOr using an lldb script as follows:\n

\nexpr ngx_log_t *$log = ngx_cycle->log\nexpr while ($log->writer != ngx_log_memory_writer) { $log = $log->next; }\nexpr ngx_log_memory_buf_t *$buf = (ngx_log_memory_buf_t *) $log->wdata\nmemory read --force --outfile debug_log.txt --binary $buf->start $buf->end\n

\n

\n", "encoding": "utf-8"} +{"path": "en\\docs\\dirindex.html", "extension": ".html", "size_bytes": 89132, "content": "\nAlphabetical index of directives
\n\nPlanning your ingress-nginx migration? Start here:\nkubernetes.nginx.org.\n\n

Alphabetical index of directives

\n absolute_redirect
accept_mutex
accept_mutex_delay
accept_terms_of_service
access_log (ngx_http_log_module)
access_log (ngx_stream_log_module)
account_key
acme_certificate
acme_issuer
acme_shared_zone
add_after_body
add_before_body
add_header
add_header_inherit
add_trailer
add_trailer_inherit
addition_types
aio
aio_write
alias
allow (ngx_http_access_module)
allow (ngx_stream_access_module)
ancient_browser
ancient_browser_value
api
auth_basic
auth_basic_user_file
auth_delay
auth_http
auth_http_header
auth_http_pass_client_cert
auth_http_timeout
auth_jwt
auth_jwt_claim_set
auth_jwt_header_set
auth_jwt_key_cache
auth_jwt_key_file
auth_jwt_key_request
auth_jwt_leeway
auth_jwt_require
auth_jwt_type
auth_oidc
auth_request
auth_request_set
auth_require
autoindex
autoindex_exact_size
autoindex_format
autoindex_localtime
break
challenge
charset
charset_map
charset_types
chunked_transfer_encoding
client_body_buffer_size
client_body_in_file_only
client_body_in_single_buffer
client_body_temp_path
client_body_timeout
client_header_buffer_size
client_header_timeout
client_id
client_max_body_size
client_secret
common_name_in_csr
config_url
connection_pool_size
contact
cookie_name
create_full_put_path
daemon
dav_access
dav_methods
debug_connection
debug_points
default_type
deny (ngx_http_access_module)
deny (ngx_stream_access_module)
directio
directio_alignment
disable_symlinks
early_hints
empty_gif
enforce_initial_report
env
error_log
error_log_tag
error_page
etag
events
expires
external_account_key
extra_auth_args
f4f
f4f_buffer_size
fastcgi_allow_upstream
fastcgi_bind
fastcgi_bind_dynamic
fastcgi_buffer_size
fastcgi_buffering
fastcgi_buffers
fastcgi_busy_buffers_size
fastcgi_cache
fastcgi_cache_background_update
fastcgi_cache_bypass
fastcgi_cache_key
fastcgi_cache_lock
fastcgi_cache_lock_age
fastcgi_cache_lock_timeout
fastcgi_cache_max_range_offset
fastcgi_cache_methods
fastcgi_cache_min_uses
fastcgi_cache_path
fastcgi_cache_purge
fastcgi_cache_revalidate
fastcgi_cache_use_stale
fastcgi_cache_valid
fastcgi_catch_stderr
fastcgi_connect_timeout
fastcgi_force_ranges
fastcgi_hide_header
fastcgi_ignore_client_abort
fastcgi_ignore_headers
fastcgi_index
fastcgi_intercept_errors
fastcgi_keep_conn
fastcgi_limit_rate
fastcgi_max_temp_file_size
fastcgi_next_upstream
fastcgi_next_upstream_timeout
fastcgi_next_upstream_tries
fastcgi_no_cache
fastcgi_param
fastcgi_pass
fastcgi_pass_header
fastcgi_pass_request_body
fastcgi_pass_request_headers
fastcgi_read_timeout
fastcgi_request_buffering
fastcgi_request_dynamic
fastcgi_send_lowat
fastcgi_send_timeout
fastcgi_socket_keepalive
fastcgi_split_path_info
fastcgi_store
fastcgi_store_access
fastcgi_temp_file_write_size
fastcgi_temp_path
flv
frontchannel_logout_uri
geo (ngx_http_geo_module)
geo (ngx_stream_geo_module)
geoip_city (ngx_http_geoip_module)
geoip_city (ngx_stream_geoip_module)
geoip_country (ngx_http_geoip_module)
geoip_country (ngx_stream_geoip_module)
geoip_org (ngx_http_geoip_module)
geoip_org (ngx_stream_geoip_module)
geoip_proxy
geoip_proxy_recursive
google_perftools_profiles
grpc_allow_upstream
grpc_bind
grpc_bind_dynamic
grpc_buffer_size
grpc_connect_timeout
grpc_hide_header
grpc_ignore_headers
grpc_intercept_errors
grpc_next_upstream
grpc_next_upstream_timeout
grpc_next_upstream_tries
grpc_pass
grpc_pass_header
grpc_read_timeout
grpc_request_dynamic
grpc_send_timeout
grpc_set_header
grpc_socket_keepalive
grpc_ssl_certificate
grpc_ssl_certificate_cache
grpc_ssl_certificate_key
grpc_ssl_ciphers
grpc_ssl_conf_command
grpc_ssl_crl
grpc_ssl_key_log
grpc_ssl_name
grpc_ssl_password_file
grpc_ssl_protocols
grpc_ssl_server_name
grpc_ssl_session_reuse
grpc_ssl_trusted_certificate
grpc_ssl_verify
grpc_ssl_verify_depth
gunzip
gunzip_buffers
gzip
gzip_buffers
gzip_comp_level
gzip_disable
gzip_http_version
gzip_min_length
gzip_proxied
gzip_static
gzip_types
gzip_vary
hash (ngx_http_upstream_module)
hash (ngx_stream_upstream_module)
health_check (ngx_http_upstream_hc_module)
health_check (ngx_stream_upstream_hc_module)
health_check_timeout
hls
hls_buffers
hls_forward_args
hls_fragment
hls_mp4_buffer_size
hls_mp4_max_buffer_size
http
http2
http2_body_preread_size
http2_chunk_size
http2_idle_timeout
http2_max_concurrent_pushes
http2_max_concurrent_streams
http2_max_field_size
http2_max_header_size
http2_max_requests
http2_push
http2_push_preload
http2_recv_buffer_size
http2_recv_timeout
http3
http3_hq
http3_max_concurrent_streams
http3_stream_buffer_size
if
if_modified_since
ignore_invalid_headers
image_filter
image_filter_buffer
image_filter_interlace
image_filter_jpeg_quality
image_filter_sharpen
image_filter_transparency
image_filter_webp_quality
imap_auth
imap_capabilities
imap_client_buffer
include
index
internal
internal_redirect
ip_hash
issuer
js_access (ngx_http_js_module)
js_access (ngx_stream_js_module)
js_body_filter
js_content
js_context_reuse (ngx_http_js_module)
js_context_reuse (ngx_stream_js_module)
js_engine (ngx_http_js_module)
js_engine (ngx_stream_js_module)
js_fetch_buffer_size (ngx_http_js_module)
js_fetch_buffer_size (ngx_stream_js_module)
js_fetch_ciphers (ngx_http_js_module)
js_fetch_ciphers (ngx_stream_js_module)
js_fetch_keepalive (ngx_http_js_module)
js_fetch_keepalive (ngx_stream_js_module)
js_fetch_keepalive_requests (ngx_http_js_module)
js_fetch_keepalive_requests (ngx_stream_js_module)
js_fetch_keepalive_time (ngx_http_js_module)
js_fetch_keepalive_time (ngx_stream_js_module)
js_fetch_keepalive_timeout (ngx_http_js_module)
js_fetch_keepalive_timeout (ngx_stream_js_module)
js_fetch_max_response_buffer_size (ngx_http_js_module)
js_fetch_max_response_buffer_size (ngx_stream_js_module)
js_fetch_protocols (ngx_http_js_module)
js_fetch_protocols (ngx_stream_js_module)
js_fetch_proxy (ngx_http_js_module)
js_fetch_proxy (ngx_stream_js_module)
js_fetch_timeout (ngx_http_js_module)
js_fetch_timeout (ngx_stream_js_module)
js_fetch_trusted_certificate (ngx_http_js_module)
js_fetch_trusted_certificate (ngx_stream_js_module)
js_fetch_verify (ngx_http_js_module)
js_fetch_verify (ngx_stream_js_module)
js_fetch_verify_depth (ngx_http_js_module)
js_fetch_verify_depth (ngx_stream_js_module)
js_filter
js_header_filter
js_import (ngx_http_js_module)
js_import (ngx_stream_js_module)
js_include (ngx_http_js_module)
js_include (ngx_stream_js_module)
js_load_http_native_module
js_load_stream_native_module
js_path (ngx_http_js_module)
js_path (ngx_stream_js_module)
js_periodic (ngx_http_js_module)
js_periodic (ngx_stream_js_module)
js_preload_object (ngx_http_js_module)
js_preload_object (ngx_stream_js_module)
js_preread
js_set (ngx_http_js_module)
js_set (ngx_stream_js_module)
js_shared_dict_zone (ngx_http_js_module)
js_shared_dict_zone (ngx_stream_js_module)
js_var (ngx_http_js_module)
js_var (ngx_stream_js_module)
keepalive
keepalive_disable
keepalive_min_timeout
keepalive_requests (ngx_http_core_module)
keepalive_requests (ngx_http_upstream_module)
keepalive_time (ngx_http_core_module)
keepalive_time (ngx_http_upstream_module)
keepalive_timeout (ngx_http_core_module)
keepalive_timeout (ngx_http_upstream_module)
keyval (ngx_http_keyval_module)
keyval (ngx_stream_keyval_module)
keyval_zone (ngx_http_keyval_module)
keyval_zone (ngx_stream_keyval_module)
large_client_header_buffers
least_conn (ngx_http_upstream_module)
least_conn (ngx_stream_upstream_module)
least_time (ngx_http_upstream_module)
least_time (ngx_stream_upstream_module)
license_token
limit_conn (ngx_http_limit_conn_module)
limit_conn (ngx_stream_limit_conn_module)
limit_conn_dry_run (ngx_http_limit_conn_module)
limit_conn_dry_run (ngx_stream_limit_conn_module)
limit_conn_log_level (ngx_http_limit_conn_module)
limit_conn_log_level (ngx_stream_limit_conn_module)
limit_conn_status
limit_conn_zone (ngx_http_limit_conn_module)
limit_conn_zone (ngx_stream_limit_conn_module)
limit_except
limit_rate
limit_rate_after
limit_req
limit_req_dry_run
limit_req_log_level
limit_req_status
limit_req_zone
limit_zone
lingering_close
lingering_time
lingering_timeout
listen (ngx_http_core_module)
listen (ngx_mail_core_module)
listen (ngx_stream_core_module)
load_module
location
lock_file
log_format (ngx_http_log_module)
log_format (ngx_stream_log_module)
log_not_found
log_subrequest
logout_token_hint
logout_uri
mail
map (ngx_http_map_module)
map (ngx_stream_map_module)
map_hash_bucket_size (ngx_http_map_module)
map_hash_bucket_size (ngx_stream_map_module)
map_hash_max_size (ngx_http_map_module)
map_hash_max_size (ngx_stream_map_module)
master_process
match (ngx_http_upstream_hc_module)
match (ngx_stream_upstream_hc_module)
max_errors
max_headers
max_ranges
memcached_allow_upstream
memcached_bind
memcached_bind_dynamic
memcached_buffer_size
memcached_connect_timeout
memcached_gzip_flag
memcached_next_upstream
memcached_next_upstream_timeout
memcached_next_upstream_tries
memcached_pass
memcached_read_timeout
memcached_send_timeout
memcached_socket_keepalive
merge_slashes
mgmt
min_delete_depth
mirror
mirror_request_body
modern_browser
modern_browser_value
mp4
mp4_buffer_size
mp4_limit_rate
mp4_limit_rate_after
mp4_max_buffer_size
mp4_start_key_frame
mqtt
mqtt_buffers
mqtt_preread
mqtt_rewrite_buffer_size
mqtt_set_connect
msie_padding
msie_refresh
multi_accept
ntlm
num_map (ngx_http_num_map_module)
num_map (ngx_stream_num_map_module)
oidc_provider
open_file_cache
open_file_cache_errors
open_file_cache_min_uses
open_file_cache_valid
open_log_file_cache (ngx_http_log_module)
open_log_file_cache (ngx_stream_log_module)
otel_exporter
otel_resource_attr
otel_service_name
otel_span_attr
otel_span_name
otel_trace
otel_trace_context
output_buffers
override_charset
pass
pcre_jit
perl
perl_modules
perl_require
perl_set
pid
pkce
pop3_auth
pop3_capabilities
port_in_redirect
post_logout_uri
postpone_output
preferred_chain
preread_buffer_size
preread_timeout
profile
protocol
proxy
proxy_allow_upstream
proxy_bind (ngx_http_proxy_module)
proxy_bind (ngx_stream_proxy_module)
proxy_bind_dynamic (ngx_http_proxy_module)
proxy_bind_dynamic (ngx_stream_proxy_module)
proxy_buffer
proxy_buffer_size (ngx_http_proxy_module)
proxy_buffer_size (ngx_stream_proxy_module)
proxy_buffering
proxy_buffers
proxy_busy_buffers_size
proxy_cache
proxy_cache_background_update
proxy_cache_bypass
proxy_cache_convert_head
proxy_cache_key
proxy_cache_lock
proxy_cache_lock_age
proxy_cache_lock_timeout
proxy_cache_max_range_offset
proxy_cache_methods
proxy_cache_min_uses
proxy_cache_path
proxy_cache_purge
proxy_cache_revalidate
proxy_cache_use_stale
proxy_cache_valid
proxy_connect_timeout (ngx_http_proxy_module)
proxy_connect_timeout (ngx_stream_proxy_module)
proxy_cookie_domain
proxy_cookie_flags
proxy_cookie_path
proxy_download_rate
proxy_force_ranges
proxy_half_close
proxy_headers_hash_bucket_size
proxy_headers_hash_max_size
proxy_hide_header
proxy_http_version
proxy_ignore_client_abort
proxy_ignore_headers
proxy_intercept_errors
proxy_limit_rate
proxy_max_temp_file_size
proxy_method
proxy_next_upstream (ngx_http_proxy_module)
proxy_next_upstream (ngx_stream_proxy_module)
proxy_next_upstream_timeout (ngx_http_proxy_module)
proxy_next_upstream_timeout (ngx_stream_proxy_module)
proxy_next_upstream_tries (ngx_http_proxy_module)
proxy_next_upstream_tries (ngx_stream_proxy_module)
proxy_no_cache
proxy_pass (ngx_http_proxy_module)
proxy_pass (ngx_stream_proxy_module)
proxy_pass_error_message
proxy_pass_header
proxy_pass_request_body
proxy_pass_request_headers
proxy_pass_trailers
proxy_password
proxy_protocol (ngx_mail_proxy_module)
proxy_protocol (ngx_stream_proxy_module)
proxy_protocol_timeout
proxy_read_timeout
proxy_redirect
proxy_request_buffering
proxy_request_dynamic
proxy_requests
proxy_responses
proxy_send_lowat
proxy_send_timeout
proxy_session_drop
proxy_set_body
proxy_set_header
proxy_smtp_auth
proxy_socket_keepalive (ngx_http_proxy_module)
proxy_socket_keepalive (ngx_stream_proxy_module)
proxy_ssl
proxy_ssl_alpn
proxy_ssl_certificate (ngx_http_proxy_module)
proxy_ssl_certificate (ngx_stream_proxy_module)
proxy_ssl_certificate_cache (ngx_http_proxy_module)
proxy_ssl_certificate_cache (ngx_stream_proxy_module)
proxy_ssl_certificate_key (ngx_http_proxy_module)
proxy_ssl_certificate_key (ngx_stream_proxy_module)
proxy_ssl_ciphers (ngx_http_proxy_module)
proxy_ssl_ciphers (ngx_stream_proxy_module)
proxy_ssl_conf_command (ngx_http_proxy_module)
proxy_ssl_conf_command (ngx_stream_proxy_module)
proxy_ssl_crl (ngx_http_proxy_module)
proxy_ssl_crl (ngx_stream_proxy_module)
proxy_ssl_key_log (ngx_http_proxy_module)
proxy_ssl_key_log (ngx_stream_proxy_module)
proxy_ssl_name (ngx_http_proxy_module)
proxy_ssl_name (ngx_stream_proxy_module)
proxy_ssl_password_file (ngx_http_proxy_module)
proxy_ssl_password_file (ngx_stream_proxy_module)
proxy_ssl_protocols (ngx_http_proxy_module)
proxy_ssl_protocols (ngx_stream_proxy_module)
proxy_ssl_server_name (ngx_http_proxy_module)
proxy_ssl_server_name (ngx_stream_proxy_module)
proxy_ssl_session_reuse (ngx_http_proxy_module)
proxy_ssl_session_reuse (ngx_stream_proxy_module)
proxy_ssl_trusted_certificate (ngx_http_proxy_module)
proxy_ssl_trusted_certificate (ngx_stream_proxy_module)
proxy_ssl_verify (ngx_http_proxy_module)
proxy_ssl_verify (ngx_stream_proxy_module)
proxy_ssl_verify_depth (ngx_http_proxy_module)
proxy_ssl_verify_depth (ngx_stream_proxy_module)
proxy_store
proxy_store_access
proxy_temp_file_write_size
proxy_temp_path
proxy_timeout (ngx_mail_proxy_module)
proxy_timeout (ngx_stream_proxy_module)
proxy_upload_rate
proxy_username
queue
quic_active_connection_id_limit
quic_bpf
quic_gso
quic_host_key
quic_retry
random (ngx_http_upstream_module)
random (ngx_stream_upstream_module)
random_index
read_ahead
real_ip_header
real_ip_recursive
recursive_error_pages
redirect_uri
referer_hash_bucket_size
referer_hash_max_size
request_pool_size
reset_timedout_connection
resolver (ngx_http_core_module)
resolver (ngx_http_upstream_module)
resolver (ngx_mail_core_module)
resolver (ngx_stream_core_module)
resolver (ngx_stream_upstream_module)
resolver (ngx_mgmt_module)
resolver_timeout (ngx_http_core_module)
resolver_timeout (ngx_http_upstream_module)
resolver_timeout (ngx_mail_core_module)
resolver_timeout (ngx_stream_core_module)
resolver_timeout (ngx_stream_upstream_module)
return (ngx_http_rewrite_module)
return (ngx_stream_return_module)
rewrite
rewrite_log
root
satisfy
scgi_allow_upstream
scgi_bind
scgi_bind_dynamic
scgi_buffer_size
scgi_buffering
scgi_buffers
scgi_busy_buffers_size
scgi_cache
scgi_cache_background_update
scgi_cache_bypass
scgi_cache_key
scgi_cache_lock
scgi_cache_lock_age
scgi_cache_lock_timeout
scgi_cache_max_range_offset
scgi_cache_methods
scgi_cache_min_uses
scgi_cache_path
scgi_cache_purge
scgi_cache_revalidate
scgi_cache_use_stale
scgi_cache_valid
scgi_connect_timeout
scgi_force_ranges
scgi_hide_header
scgi_ignore_client_abort
scgi_ignore_headers
scgi_intercept_errors
scgi_limit_rate
scgi_max_temp_file_size
scgi_next_upstream
scgi_next_upstream_timeout
scgi_next_upstream_tries
scgi_no_cache
scgi_param
scgi_pass
scgi_pass_header
scgi_pass_request_body
scgi_pass_request_headers
scgi_read_timeout
scgi_request_buffering
scgi_request_dynamic
scgi_send_timeout
scgi_socket_keepalive
scgi_store
scgi_store_access
scgi_temp_file_write_size
scgi_temp_path
scope
secure_link
secure_link_md5
secure_link_secret
send_lowat
send_timeout
sendfile
sendfile_max_chunk
server (ngx_http_core_module)
server (ngx_http_upstream_module)
server (ngx_mail_core_module)
server (ngx_stream_core_module)
server (ngx_stream_upstream_module)
server_name (ngx_http_core_module)
server_name (ngx_mail_core_module)
server_name (ngx_stream_core_module)
server_name_in_redirect
server_names_hash_bucket_size (ngx_http_core_module)
server_names_hash_bucket_size (ngx_stream_core_module)
server_names_hash_max_size (ngx_http_core_module)
server_names_hash_max_size (ngx_stream_core_module)
server_tokens
session_log
session_log_format
session_log_zone
session_store
session_timeout
set (ngx_http_rewrite_module)
set (ngx_stream_set_module)
set_real_ip_from (ngx_http_realip_module)
set_real_ip_from (ngx_mail_realip_module)
set_real_ip_from (ngx_stream_realip_module)
slice
smtp_auth
smtp_capabilities
smtp_client_buffer
smtp_greeting_delay
source_charset
split_clients (ngx_http_split_clients_module)
split_clients (ngx_stream_split_clients_module)
ssi
ssi_last_modified
ssi_min_file_chunk
ssi_silent_errors
ssi_types
ssi_value_length
ssl (ngx_http_ssl_module)
ssl (ngx_mail_ssl_module)
ssl_alpn
ssl_buffer_size
ssl_certificate (ngx_http_ssl_module)
ssl_certificate (ngx_mail_ssl_module)
ssl_certificate (ngx_stream_ssl_module)
ssl_certificate_cache (ngx_http_ssl_module)
ssl_certificate_cache (ngx_stream_ssl_module)
ssl_certificate_compression (ngx_http_ssl_module)
ssl_certificate_compression (ngx_mail_ssl_module)
ssl_certificate_compression (ngx_stream_ssl_module)
ssl_certificate_key (ngx_http_ssl_module)
ssl_certificate_key (ngx_mail_ssl_module)
ssl_certificate_key (ngx_stream_ssl_module)
ssl_ciphers (ngx_http_ssl_module)
ssl_ciphers (ngx_mail_ssl_module)
ssl_ciphers (ngx_stream_ssl_module)
ssl_client_certificate (ngx_http_ssl_module)
ssl_client_certificate (ngx_mail_ssl_module)
ssl_client_certificate (ngx_stream_ssl_module)
ssl_conf_command (ngx_http_ssl_module)
ssl_conf_command (ngx_mail_ssl_module)
ssl_conf_command (ngx_stream_ssl_module)
ssl_crl (ngx_http_oidc_module)
ssl_crl (ngx_http_ssl_module)
ssl_crl (ngx_mail_ssl_module)
ssl_crl (ngx_stream_ssl_module)
ssl_crl (ngx_mgmt_module)
ssl_dhparam (ngx_http_ssl_module)
ssl_dhparam (ngx_mail_ssl_module)
ssl_dhparam (ngx_stream_ssl_module)
ssl_early_data
ssl_ecdh_curve (ngx_http_ssl_module)
ssl_ecdh_curve (ngx_mail_ssl_module)
ssl_ecdh_curve (ngx_stream_ssl_module)
ssl_ech_file (ngx_http_ssl_module)
ssl_ech_file (ngx_stream_ssl_module)
ssl_engine
ssl_handshake_timeout
ssl_key_log (ngx_http_ssl_module)
ssl_key_log (ngx_stream_ssl_module)
ssl_object_cache_inheritable
ssl_ocsp (ngx_http_ssl_module)
ssl_ocsp (ngx_stream_ssl_module)
ssl_ocsp_cache (ngx_http_ssl_module)
ssl_ocsp_cache (ngx_stream_ssl_module)
ssl_ocsp_responder (ngx_http_ssl_module)
ssl_ocsp_responder (ngx_stream_ssl_module)
ssl_password_file (ngx_http_ssl_module)
ssl_password_file (ngx_mail_ssl_module)
ssl_password_file (ngx_stream_ssl_module)
ssl_prefer_server_ciphers (ngx_http_ssl_module)
ssl_prefer_server_ciphers (ngx_mail_ssl_module)
ssl_prefer_server_ciphers (ngx_stream_ssl_module)
ssl_preread
ssl_protocols (ngx_http_ssl_module)
ssl_protocols (ngx_mail_ssl_module)
ssl_protocols (ngx_stream_ssl_module)
ssl_reject_handshake (ngx_http_ssl_module)
ssl_reject_handshake (ngx_stream_ssl_module)
ssl_session_cache (ngx_http_ssl_module)
ssl_session_cache (ngx_mail_ssl_module)
ssl_session_cache (ngx_stream_ssl_module)
ssl_session_ticket_key (ngx_http_ssl_module)
ssl_session_ticket_key (ngx_mail_ssl_module)
ssl_session_ticket_key (ngx_stream_ssl_module)
ssl_session_tickets (ngx_http_ssl_module)
ssl_session_tickets (ngx_mail_ssl_module)
ssl_session_tickets (ngx_stream_ssl_module)
ssl_session_timeout (ngx_http_ssl_module)
ssl_session_timeout (ngx_mail_ssl_module)
ssl_session_timeout (ngx_stream_ssl_module)
ssl_stapling (ngx_http_ssl_module)
ssl_stapling (ngx_stream_ssl_module)
ssl_stapling_file (ngx_http_ssl_module)
ssl_stapling_file (ngx_stream_ssl_module)
ssl_stapling_responder (ngx_http_ssl_module)
ssl_stapling_responder (ngx_stream_ssl_module)
ssl_stapling_verify (ngx_http_ssl_module)
ssl_stapling_verify (ngx_stream_ssl_module)
ssl_trusted_certificate (ngx_http_oidc_module)
ssl_trusted_certificate (ngx_http_ssl_module)
ssl_trusted_certificate (ngx_http_acme_module)
ssl_trusted_certificate (ngx_mail_ssl_module)
ssl_trusted_certificate (ngx_stream_ssl_module)
ssl_trusted_certificate (ngx_mgmt_module)
ssl_verify (ngx_http_acme_module)
ssl_verify (ngx_mgmt_module)
ssl_verify_client (ngx_http_ssl_module)
ssl_verify_client (ngx_mail_ssl_module)
ssl_verify_client (ngx_stream_ssl_module)
ssl_verify_depth (ngx_http_ssl_module)
ssl_verify_depth (ngx_mail_ssl_module)
ssl_verify_depth (ngx_stream_ssl_module)
stall_threshold
starttls
state (ngx_http_upstream_module)
state (ngx_stream_upstream_module)
state_path (ngx_http_acme_module)
state_path (ngx_mgmt_module)
status
status_format
status_zone (ngx_http_api_module)
status_zone (ngx_http_status_module)
sticky
stream
stub_status
sub_filter
sub_filter_last_modified
sub_filter_once
sub_filter_types
subrequest_output_buffer_size
tcp_nodelay (ngx_http_core_module)
tcp_nodelay (ngx_stream_core_module)
tcp_nopush
thread_pool
timeout
timer_resolution
try_files
tunnel_allow_upstream
tunnel_bind
tunnel_bind_dynamic
tunnel_buffer_size
tunnel_connect_timeout
tunnel_next_upstream
tunnel_next_upstream_timeout
tunnel_next_upstream_tries
tunnel_pass
tunnel_read_timeout
tunnel_send_lowat
tunnel_send_timeout
tunnel_socket_keepalive
types
types_hash_bucket_size
types_hash_max_size
underscores_in_headers
uninitialized_variable_warn
upstream (ngx_http_upstream_module)
upstream (ngx_stream_upstream_module)
upstream_conf
uri
usage_report
use
user
userid
userid_domain
userid_expires
userid_flags
userid_mark
userid_name
userid_p3p
userid_path
userid_service
userinfo
uwsgi_allow_upstream
uwsgi_bind
uwsgi_bind_dynamic
uwsgi_buffer_size
uwsgi_buffering
uwsgi_buffers
uwsgi_busy_buffers_size
uwsgi_cache
uwsgi_cache_background_update
uwsgi_cache_bypass
uwsgi_cache_key
uwsgi_cache_lock
uwsgi_cache_lock_age
uwsgi_cache_lock_timeout
uwsgi_cache_max_range_offset
uwsgi_cache_methods
uwsgi_cache_min_uses
uwsgi_cache_path
uwsgi_cache_purge
uwsgi_cache_revalidate
uwsgi_cache_use_stale
uwsgi_cache_valid
uwsgi_connect_timeout
uwsgi_force_ranges
uwsgi_hide_header
uwsgi_ignore_client_abort
uwsgi_ignore_headers
uwsgi_intercept_errors
uwsgi_limit_rate
uwsgi_max_temp_file_size
uwsgi_modifier1
uwsgi_modifier2
uwsgi_next_upstream
uwsgi_next_upstream_timeout
uwsgi_next_upstream_tries
uwsgi_no_cache
uwsgi_param
uwsgi_pass
uwsgi_pass_header
uwsgi_pass_request_body
uwsgi_pass_request_headers
uwsgi_read_timeout
uwsgi_request_buffering
uwsgi_request_dynamic
uwsgi_send_timeout
uwsgi_socket_keepalive
uwsgi_ssl_certificate
uwsgi_ssl_certificate_cache
uwsgi_ssl_certificate_key
uwsgi_ssl_ciphers
uwsgi_ssl_conf_command
uwsgi_ssl_crl
uwsgi_ssl_key_log
uwsgi_ssl_name
uwsgi_ssl_password_file
uwsgi_ssl_protocols
uwsgi_ssl_server_name
uwsgi_ssl_session_reuse
uwsgi_ssl_trusted_certificate
uwsgi_ssl_verify
uwsgi_ssl_verify_depth
uwsgi_store
uwsgi_store_access
uwsgi_temp_file_write_size
uwsgi_temp_path
valid_referers
variables_hash_bucket_size (ngx_http_core_module)
variables_hash_bucket_size (ngx_stream_core_module)
variables_hash_max_size (ngx_http_core_module)
variables_hash_max_size (ngx_stream_core_module)
worker_aio_requests
worker_connections
worker_cpu_affinity
worker_priority
worker_processes
worker_rlimit_core
worker_rlimit_nofile
worker_shutdown_timeout
working_directory
xclient
xml_entities
xslt_last_modified
xslt_param
xslt_string_param
xslt_stylesheet
xslt_types
zone (ngx_http_upstream_module)
zone (ngx_stream_upstream_module)
zone_sync
zone_sync_buffers
zone_sync_connect_retry_interval
zone_sync_connect_timeout
zone_sync_interval
zone_sync_recv_buffer_size
zone_sync_server
zone_sync_ssl
zone_sync_ssl_certificate
zone_sync_ssl_certificate_key
zone_sync_ssl_ciphers
zone_sync_ssl_conf_command
zone_sync_ssl_crl
zone_sync_ssl_name
zone_sync_ssl_password_file
zone_sync_ssl_protocols
zone_sync_ssl_server_name
zone_sync_ssl_trusted_certificate
zone_sync_ssl_verify
zone_sync_ssl_verify_depth
zone_sync_timeout
\n

\n", "encoding": "utf-8"} +{"path": "en\\docs\\events.html", "extension": ".html", "size_bytes": 4294, "content": "\nConnection processing methods
\n\nPlanning your ingress-nginx migration? Start here:\nkubernetes.nginx.org.\n\n

Connection processing methods

\nnginx supports a variety of connection processing methods.\nThe availability of a particular method depends on the platform used.\nOn platforms that support several methods nginx will normally\nselect the most efficient method automatically.\nHowever, if needed, a connection processing method can be selected\nexplicitly with the\nuse directive.\n

\nThe following connection processing methods are supported:\n

\n

\n", "encoding": "utf-8"} +{"path": "en\\docs\\faq.html", "extension": ".html", "size_bytes": 3621, "content": "\nFAQ
\n\nPlanning your ingress-nginx migration? Start here:\nkubernetes.nginx.org.\n\n

FAQ

\n

\n

\n", "encoding": "utf-8"} +{"path": "en\\docs\\hash.html", "extension": ".html", "size_bytes": 3716, "content": "\nSetting up hashes
\n\nPlanning your ingress-nginx migration? Start here:\nkubernetes.nginx.org.\n\n

Setting up hashes

\nTo quickly process static sets of data such as server names,\nmap directive’s values,\nMIME types, names of request header strings,\nnginx uses hash tables.\nDuring the start and each re-configuration nginx selects the\nminimum possible sizes of hash tables such that the bucket size\nthat stores keys with identical hash values does not exceed the\nconfigured parameter (hash bucket size).\nThe size of a table is expressed in buckets.\nThe adjustment is continued until the table size exceeds the\nhash max size parameter.\nMost hashes have the corresponding directives that allow changing\nthese parameters, for example, for the server names hash they are\nserver_names_hash_max_size\nand server_names_hash_bucket_size.\n

\nThe hash bucket size parameter is aligned to the size that is a\nmultiple of the processor’s cache line size. This speeds up\nkey search in a hash on modern processors by reducing the number\nof memory accesses.\nIf hash bucket size is equal to one processor’s cache line size\nthen the number of memory accesses during the key search will be\ntwo in the worst case — first to compute the bucket address,\nand second during the key search inside the bucket.\nTherefore, if nginx emits the message requesting to increase\neither hash max size or hash bucket size then the first parameter\nshould first be increased.\n

\n", "encoding": "utf-8"} +{"path": "en\\docs\\howto_build_on_win32.html", "extension": ".html", "size_bytes": 5105, "content": "\nBuilding nginx on the Win32 platform with Visual C
\n\nPlanning your ingress-nginx migration? Start here:\nkubernetes.nginx.org.\n\n

Building nginx on the Win32 platform with Visual C

Build steps
See also

Prerequisites

\nTo build nginx on the Microsoft Win32® platform you need:\n\n

\n\n

Build steps

\nEnsure that paths to Perl, Git and MSYS bin directories are added to\nPATH environment variable before you start build. To set Visual C environment\nrun vcvarsall.bat script from Visual C directory.\n

\n\nTo build nginx:\n

\n\n

See also

\n

\n

\n", "encoding": "utf-8"} +{"path": "en\\docs\\index.html", "extension": ".html", "size_bytes": 13891, "content": "\nnginx documentation
\n\nPlanning your ingress-nginx migration? Start here:\nkubernetes.nginx.org.\n\n

nginx documentation

Introduction

\n

\n\n

\n\n

\n\n

\n\n

\n

How-To

\n

\n\n

\n

Development

\n

\n

Modules reference

\n

\n

\n

\n

\n

\n

\n

\n

\n

\n

\n

\n

\n

\n

\n", "encoding": "utf-8"} +{"path": "en\\docs\\install.html", "extension": ".html", "size_bytes": 3295, "content": "\nInstalling nginx
\n\nPlanning your ingress-nginx migration? Start here:\nkubernetes.nginx.org.\n\n

Installing nginx

\nnginx can be installed differently, depending on the operating system.\n

Installation on Linux

\nFor Linux, nginx packages\nfrom nginx.org can be used.\n

Installation on FreeBSD

\nOn FreeBSD, nginx can be installed either from the packages\nor through the\nports\nsystem.\nThe ports system provides greater flexibility, allowing selection among\na wide range of options.\nThe port will compile nginx with the specified options and install it.\n

Building from Sources

\nIf some special functionality is required, not available with packages and\nports, nginx can also be compiled from source files.\nWhile more flexible, this approach may be complex for a beginner.\nFor more information, see Building nginx from Sources.\n

\n", "encoding": "utf-8"} +{"path": "en\\docs\\nginx_dtrace_pid_provider.html", "extension": ".html", "size_bytes": 7860, "content": "\nDebugging nginx with DTrace pid provider
\n\nPlanning your ingress-nginx migration? Start here:\nkubernetes.nginx.org.\n\n

Debugging nginx with DTrace pid provider

\nThis article assumes the reader has a general knowledge of nginx internals and\nDTrace.\n

\nAlthough nginx built with the --with-debug\noption already provides a lot of information about request processing,\nit is sometimes desirable to trace particular parts of code path more\nthoroughly and at the same time omit the rest of debugging output.\nDTrace pid provider (available on Solaris, macOS) is a useful tool to\nexplore userland program’s internals, since it doesn’t require any code\nchanges and it can help with the task.\nA simple DTrace script to trace and print nginx function calls\nmay look like this:\n\n

\n#pragma D option flowindent\n\npid$target:nginx::entry {\n}\n\npid$target:nginx::return {\n}\n

\n\n

\nDTrace capabilities for function calls tracing provide only a limited amount\nof useful information, though.\nReal-time inspection of function arguments is typically more interesting,\nbut also a bit more complicated.\nExamples below are intended to help the reader become more familiar with\nDTrace and the process of analyzing nginx behavior using DTrace.\n

\nOne of the common scenarios for using DTrace with nginx is the following:\nattach to the nginx worker process to log request lines and request start times.\nThe corresponding function to attach is\nngx_http_process_request(), and the argument in question\nis a pointer to the ngx_http_request_t structure.\nDTrace script for such request logging can be as simple as:\n\n

\npid$target::*ngx_http_process_request:entry\n{\n    this->request = (ngx_http_request_t *)copyin(arg0, sizeof(ngx_http_request_t));\n    this->request_line = stringof(copyin((uintptr_t)this->request->request_line.data,\n                                         this->request->request_line.len));\n    printf(\"request line = %s\\n\", this->request_line);\n    printf(\"request start sec = %d\\n\", this->request->start_sec);\n}\n

\n\n

\nIt should be noted that in the example above DTrace requires some knowledge\nabout the ngx_http_request_t structure.\nUnfortunately while it is possible to use a specific #include\ndirective in the DTrace script and then pass it to a C preprocessor\n(with the -C flag), that doesn’t really work.\nDue to a lot of cross dependencies, almost all nginx header files\nhave to be included.\nIn turn, based on configure script settings,\nnginx headers will include PCRE,\nOpenSSL and a variety of system header files.\nWhile in theory all those header files related to a specific nginx build\nmight be included in DTrace script preprocessing and compilation, in reality\nDTrace script most probably will fail to compile because of unknown syntax in\nsome header files.\n

\nThe problem above can be solved by including only the relevant and\nnecessary structure and type definitions in the DTrace script.\nDTrace has to know sizes of structures, types, and fields offsets.\nThus dependencies can be further reduced by manually optimizing\nstructure definitions for use with DTrace.\n

\nLet’s use DTrace script example above and see what structure definitions\nit needs to work properly.\n

\nFirst of all objs/ngx_auto_config.h file generated by\nconfigure should be included, because it defines a number of constants\naffecting various #ifdef’s.\nAfter that, some basic types and definitions\nlike ngx_str_t, ngx_table_elt_t,\nngx_uint_t etc. should be put at the beginning of the\nDTrace script.\nThese definitions are compact, commonly used and unlikely to be\nfrequently changed.\n

\nThen there’s the ngx_http_request_t structure that\ncontains a lot of pointers to other structures.\nBecause these pointers are really irrelevant to this script, and because they\nhave the same size, it is possible to just replace them with void pointers.\nInstead of changing definitions, it is better to add appropriate typedefs,\nthough:\n\n

\ntypedef ngx_http_upstream_t     void;\ntypedef ngx_http_request_body_t void;\n

\n\nLast but not least it is necessary to add definitions of two member structures\n(ngx_http_headers_in_t,\nngx_http_headers_out_t),\ndeclarations of callback functions and definitions of constants.\n

\nThe final DTrace script can be downloaded from\nhere.\n

\nThe following example shows the output of running this script:\n\n

\n# dtrace -C -I ./objs -s trace_process_request.d -p 4848\ndtrace: script 'trace_process_request.d' matched 1 probe\nCPU     ID                    FUNCTION:NAME\n  1      4 .XAbmO.ngx_http_process_request:entry request line = GET / HTTP/1.1\nrequest start sec = 1349162898\n\n  0      4 .XAbmO.ngx_http_process_request:entry request line = GET /en/docs/nginx_dtrace_pid_provider.html HTTP/1.1\nrequest start sec = 1349162899\n

\n\n

Using similar techniques the reader should be able to trace other\nnginx function calls.\n

See also

\n

\n

\n", "encoding": "utf-8"} +{"path": "en\\docs\\ngx_core_module.html", "extension": ".html", "size_bytes": 44580, "content": "\nCore functionality
\n\nPlanning your ingress-nginx migration? Start here:\nkubernetes.nginx.org.\n\n

Core functionality

Example Configuration
Directives
     accept_mutex
     accept_mutex_delay
     daemon
     debug_connection
     debug_points
     env
     error_log
     events
     include
     load_module
     lock_file
     master_process
     multi_accept
     pcre_jit
     pid
     ssl_engine
     ssl_object_cache_inheritable
     stall_threshold
     thread_pool
     timer_resolution
     use
     user
     worker_aio_requests
     worker_connections
     worker_cpu_affinity
     worker_priority
     worker_processes
     worker_rlimit_core
     worker_rlimit_nofile
     worker_shutdown_timeout
     working_directory
\n\n

Example Configuration

\n

\nuser www www;\nworker_processes 2;\n\nerror_log /var/log/nginx-error.log info;\n\nevents {\n    use kqueue;\n    worker_connections 2048;\n}\n\n...\n

\n

\n\n\n

Directives

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n accept_mutex on | off;
\n
\n Default:\n \n
accept_mutex off;
\n
\n Context:\n \n events
\n

\nIf accept_mutex is enabled,\nworker processes will accept new connections by turn.\nOtherwise, all worker processes will be notified about new connections,\nand if volume of new connections is low, some of the worker processes\nmay just waste system resources.\n

\nThere is no need to enable accept_mutex\non systems that support the\nEPOLLEXCLUSIVE flag (1.11.3) or\nwhen using reuseport.\n

\n

\nPrior to version 1.11.3, the default value was on.\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n accept_mutex_delay time;
\n
\n Default:\n \n
accept_mutex_delay 500ms;
\n
\n Context:\n \n events
\n

\nIf accept_mutex is enabled, specifies the maximum time\nduring which a worker process will try to restart accepting new\nconnections if another worker process is currently accepting\nnew connections.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n daemon on | off;
\n
\n Default:\n \n
daemon on;
\n
\n Context:\n \n main
\n

\nDetermines whether nginx should become a daemon.\nMainly used during development.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n debug_connection \n address |\n CIDR |\n unix:;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n events
\n

\nEnables debugging log for selected client connections.\nOther connections will use logging level set by the\nerror_log directive.\nDebugged connections are specified by IPv4 or IPv6 (1.3.0, 1.2.1)\naddress or network.\nA connection may also be specified using a hostname.\nFor connections using UNIX-domain sockets (1.3.0, 1.2.1),\ndebugging log is enabled by the “unix:” parameter.\n

\nevents {\n    debug_connection 127.0.0.1;\n    debug_connection localhost;\n    debug_connection 192.0.2.0/24;\n    debug_connection ::1;\n    debug_connection 2001:0db8::/32;\n    debug_connection unix:;\n    ...\n}\n

\n

\nFor this directive to work, nginx needs to\nbe built with --with-debug,\nsee “A debugging log”.\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n debug_points abort | stop;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n main
\n

\nThis directive is used for debugging.\n

\nWhen internal error is detected, e.g. the leak of sockets on\nrestart of working processes, enabling debug_points\nleads to a core file creation (abort)\nor to stopping of a process (stop) for further\nanalysis using a system debugger.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n env variable[=value];
\n
\n Default:\n \n
env TZ;
\n
\n Context:\n \n main
\n

\nBy default, nginx removes all environment variables inherited\nfrom its parent process except the TZ variable.\nThis directive allows preserving some of the inherited variables,\nchanging their values, or creating new environment variables.\nThese variables are then:\n

\n

\nThe TZ variable is always inherited and available to the\nngx_http_perl_module\nmodule, unless it is configured explicitly.\n

\nUsage example:\n

\nenv MALLOC_OPTIONS;\nenv PERL5LIB=/data/site/modules;\nenv OPENSSL_ALLOW_PROXY_CERTS=1;\n

\n

\n

\nThe NGINX environment variable is used internally by nginx\nand should not be set directly by the user.\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n error_log file [level]\n[json];
\n
\n Default:\n \n
error_log logs/error.log error;
\n
\n Context:\n \n main, http, mail, stream, server, location
\n

\nConfigures logging.\nSeveral logs can be specified on the same configuration level (1.5.2).\nIf on the main configuration level writing a log to a file\nis not explicitly defined, the default file will be used.\n

\nThe first parameter defines a file that will store the log.\n\nThe special value stderr selects the standard error file.\nLogging to syslog can be configured by specifying\nthe “syslog:” prefix.\nLogging to a\ncyclic memory buffer\ncan be configured by specifying the “memory:” prefix and\nbuffer size, and is generally used for debugging (1.7.11).\n

\nThe second parameter determines the level of logging,\nand can be one of the following:\ndebug, info, notice,\nwarn, error, crit,\nalert, or emerg.\nLog levels above are listed in the order of increasing severity.\nSetting a certain log level will cause all messages of\nthe specified and more severe log levels to be logged.\nFor example, the default level error will\ncause error, crit,\nalert, and emerg messages\nto be logged.\nIf this parameter is omitted then error is used.\n

\nFor debug logging to work, nginx needs to\nbe built with --with-debug,\nsee “A debugging log”.\n

\n

\nThe json parameter (1.29.8)\nenables writing a log in the JSON format,\nwith support for\ncontext tags:\n

\n{\n  \"level\": \"error\",\n  \"timestamp\": \"2026-05-13T10:30:15.042+00:00\",\n  \"pid\": 12345,  \"tid\": 12345,  \"cnum\": 3,\n  \"msg\": \"connect() failed\",\n  \"client\": \"192.168.1.10\",  \"server\": \"example.com\",\n  \"request\": \"GET /api HTTP/1.1\",\n  \"upstream\": \"http://127.0.0.1:8080/api\",\n  \"errno\": 111,\n  \"errtext\": \"Connection refused\"\n}\n

\nA log entry cannot exceed 2 KB,\ndata beyond this limit is truncated to “truncated”:1.\nDebug logging is not supported for JSON. \n

\nThis parameter is available as part of our\ncommercial subscription.\n

\n

\n

\nThe directive can be specified on the\nstream level\nstarting from version 1.7.11,\nand on the mail level\nstarting from version 1.9.0.\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n events { ... }
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n main
\n

\nProvides the configuration file context in which the directives that\naffect connection processing are specified.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n include file | mask;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n any
\n

\nIncludes another file, or files matching the\nspecified mask, into configuration.\nIncluded files should consist of\nsyntactically correct directives and blocks.\n

\nUsage example:\n

\ninclude mime.types;\ninclude vhosts/*.conf;\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n load_module file;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n main
\n

This directive appeared in version 1.9.11.\n

\nLoads a dynamic module.\n

\nExample:\n

\nload_module modules/ngx_mail_module.so;\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n lock_file file;
\n
\n Default:\n \n
lock_file logs/nginx.lock;
\n
\n Context:\n \n main
\n

\nnginx uses the locking mechanism to implement accept_mutex\nand serialize access to shared memory.\nOn most systems the locks are implemented using atomic operations,\nand this directive is ignored.\nOn other systems the “lock file” mechanism is used.\nThis directive specifies a prefix for the names of lock files.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n master_process on | off;
\n
\n Default:\n \n
master_process on;
\n
\n Context:\n \n main
\n

\nDetermines whether worker processes are started.\nThis directive is intended for nginx developers.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n multi_accept on | off;
\n
\n Default:\n \n
multi_accept off;
\n
\n Context:\n \n events
\n

\nIf multi_accept is disabled, a worker process\nwill accept one new connection at a time.\nOtherwise, a worker process\nwill accept all new connections at a time.\n

\nThe directive is ignored if kqueue\nconnection processing method is used, because it reports\nthe number of new connections waiting to be accepted.\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n pcre_jit on | off;
\n
\n Default:\n \n
pcre_jit off;
\n
\n Context:\n \n main
\n

This directive appeared in version 1.1.12.\n

\nEnables or disables the use of “just-in-time compilation” (PCRE JIT)\nfor the regular expressions known by the time of configuration parsing.\n

\nPCRE JIT can speed up processing of regular expressions significantly.\n

\nThe JIT is available in PCRE libraries starting from version 8.20\nbuilt with the --enable-jit configuration parameter.\nWhen the PCRE library is built with nginx (--with-pcre=),\nthe JIT support is enabled via the\n--with-pcre-jit configuration parameter.\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n pid file;
\n
\n Default:\n \n
pid logs/nginx.pid;
\n
\n Context:\n \n main
\n

\nDefines a file that will store the process ID of the main process.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n ssl_engine device;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n main
\n

\nDefines the name of the hardware SSL accelerator.\n

\n

\nThe module may be dynamically loaded by OpenSSL during configuration testing.\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n ssl_object_cache_inheritable on | off;
\n
\n Default:\n \n
ssl_object_cache_inheritable on;
\n
\n Context:\n \n main
\n

This directive appeared in version 1.27.4.\n

\nIf enabled, SSL objects\n(SSL certificates, secret keys, trusted CA certificates, CRL lists)\nwill be inherited across configuration reloads.\n

\nSSL objects loaded from a file are inherited\nif the modification time and file index has not been changed\nsince the previous configuration load.\nSecret keys specified as\nengine:name:id are never inherited.\nSecret keys specified as\ndata:value are always inherited.\n

\n

\nSSL objects loaded from variables cannot be inherited.\n

\n

\nExample:\n

\nssl_object_cache_inheritable on;\n\nhttp {\n    ...\n    server {\n        ...\n        ssl_certificate     example.com.crt;\n        ssl_certificate_key example.com.key;\n    }\n}\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n stall_threshold time;
\n
\n Default:\n \n
stall_threshold 1000ms;
\n
\n Context:\n \n events
\n

This directive appeared in version 1.29.0.\n

\nAllows overriding the default time threshold for the event loop iteration\nbefore a stall is reported.\nBy default, a stall is reported\nwhen an event loop iteration exceeds 1000ms.\nIf the timer_resolution directive is enabled,\nthe time threshold will be ignored.\n

\n

\nThis directive is available as part of our\ncommercial subscription.\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n thread_pool \n name\n threads=number\n [max_queue=number];
\n
\n Default:\n \n
thread_pool default threads=32 max_queue=65536;
\n
\n Context:\n \n main
\n

This directive appeared in version 1.7.11.\n

\nDefines the name and parameters of a thread pool\nused for multi-threaded reading and sending of files\nwithout blocking\nworker processes.\n

\nThe threads parameter\ndefines the number of threads in the pool.\n

\nIn the event that all threads in the pool are busy,\na new task will wait in the queue.\nThe max_queue parameter limits the number\nof tasks allowed to be waiting in the queue.\nBy default, up to 65536 tasks can wait in the queue.\nWhen the queue overflows, the task is completed with an error.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n timer_resolution interval;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n main
\n

\nReduces timer resolution in worker processes, thus reducing the\nnumber of gettimeofday() system calls made.\nBy default, gettimeofday() is called each time\na kernel event is received.\nWith reduced resolution, gettimeofday() is only\ncalled once per specified interval.\n

\nExample:\n

\ntimer_resolution 100ms;\n

\n

\nInternal implementation of the interval depends on the method used:\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n use method;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n events
\n

\nSpecifies the connection processing\nmethod to use.\nThere is normally no need to specify it explicitly, because nginx will\nby default use the most efficient method.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n user user [group];
\n
\n Default:\n \n
user nobody nobody;
\n
\n Context:\n \n main
\n

\nDefines user and group\ncredentials used by worker processes.\nIf group is omitted, a group whose name equals\nthat of user is used.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n worker_aio_requests number;
\n
\n Default:\n \n
worker_aio_requests 32;
\n
\n Context:\n \n events
\n
\n

\n This directive appeared in versions 1.1.4 and 1.0.7.\n \n

\n

\nWhen using aio\nwith the epoll\nconnection processing method, sets the maximum number of\noutstanding asynchronous I/O operations\nfor a single worker process.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n worker_connections number;
\n
\n Default:\n \n
worker_connections 512;
\n
\n Context:\n \n events
\n

\nSets the maximum number of simultaneous connections that\ncan be opened by a worker process.\n

\nIt should be kept in mind that this number includes all connections\n(e.g. connections with proxied servers, among others),\nnot only connections with clients.\nAnother consideration is that the actual number of simultaneous\nconnections cannot exceed the current limit on\nthe maximum number of open files, which can be changed by\nworker_rlimit_nofile.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n worker_cpu_affinity cpumask ...;
worker_cpu_affinity auto [cpumask];
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n main
\n

\nBinds worker processes to the sets of CPUs.\nEach CPU set is represented by a bitmask of allowed CPUs.\nThere should be a separate set defined for each of the worker processes.\nBy default, worker processes are not bound to any specific CPUs.\n

\nFor example,\n

\nworker_processes    4;\nworker_cpu_affinity 0001 0010 0100 1000;\n

\nbinds each worker process to a separate CPU, while\n

\nworker_processes    2;\nworker_cpu_affinity 0101 1010;\n

\nbinds the first worker process to CPU0/CPU2,\nand the second worker process to CPU1/CPU3.\nThe second example is suitable for hyper-threading.\n

\nThe special value auto (1.9.10) allows\nbinding worker processes automatically to available CPUs:\n

\nworker_processes auto;\nworker_cpu_affinity auto;\n

\nThe optional mask parameter can be used to limit the CPUs\navailable for automatic binding:\n

\nworker_cpu_affinity auto 01010101;\n

\n

\n

\nThe directive is only available on FreeBSD and Linux.\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n worker_priority number;
\n
\n Default:\n \n
worker_priority 0;
\n
\n Context:\n \n main
\n

\nDefines the scheduling priority for worker processes like it is\ndone by the nice command: a negative\nnumber\nmeans higher priority.\nAllowed range normally varies from -20 to 20.\n

\nExample:\n

\nworker_priority -10;\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n worker_processes number | auto;
\n
\n Default:\n \n
worker_processes 1;
\n
\n Context:\n \n main
\n

\nDefines the number of worker processes.\n

\nThe optimal value depends on many factors including (but not\nlimited to) the number of CPU cores, the number of hard disk\ndrives that store data, and load pattern.\nWhen one is in doubt, setting it to the number of available CPU cores\nwould be a good start (the value “auto”\nwill try to autodetect it).\n

\nThe auto parameter is supported starting from\nversions 1.3.8 and 1.2.5.\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n worker_rlimit_core size;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n main
\n

\nChanges the limit on the largest size of a core file\n(RLIMIT_CORE) for worker processes.\nUsed to increase the limit without restarting the main process.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n worker_rlimit_nofile number;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n main
\n

\nChanges the limit on the maximum number of open files\n(RLIMIT_NOFILE) for worker processes.\nUsed to increase the limit without restarting the main process.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n worker_shutdown_timeout time;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n main
\n

This directive appeared in version 1.11.11.\n

\nConfigures a timeout for a graceful shutdown of worker processes.\nWhen the time expires,\nnginx will try to close all the connections currently open\nto facilitate shutdown.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n working_directory directory;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n main
\n

\nDefines the current working directory for a worker process.\nIt is primarily used when writing a core-file, in which case\na worker process should have write permission for the\nspecified directory.\n

\n\n
\n", "encoding": "utf-8"} +{"path": "en\\docs\\ngx_google_perftools_module.html", "extension": ".html", "size_bytes": 4415, "content": "\nModule ngx_google_perftools_module
\n\nPlanning your ingress-nginx migration? Start here:\nkubernetes.nginx.org.\n\n

Module ngx_google_perftools_module

Example Configuration
Directives
     google_perftools_profiles
\n\n

\nThe ngx_google_perftools_module module (0.6.29) enables\nprofiling of nginx worker processes using\nGoogle Performance Tools.\nThe module is intended for nginx developers.\n

\nThis module is not built by default, it should be enabled with the\n--with-google_perftools_module\nconfiguration parameter.\n

\nThis module requires the\ngperftools library.\n

\n

\n\n\n

Example Configuration

\n

\ngoogle_perftools_profiles /path/to/profile;\n

\nProfiles will be stored as\n/path/to/profile.<worker_pid>.\n

\n\n\n

Directives

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n google_perftools_profiles file;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n main
\n

\nSets a file name that keeps profiling information of\nnginx worker process.\nThe ID of the worker process is always a part of the file name\nand is appended to the end of the file name, after a dot.\n

\n\n
\n", "encoding": "utf-8"} +{"path": "en\\docs\\ngx_mgmt_module.html", "extension": ".html", "size_bytes": 18434, "content": "\nModule ngx_mgmt_module
\n\nPlanning your ingress-nginx migration? Start here:\nkubernetes.nginx.org.\n\n

Module ngx_mgmt_module

Example Configuration
Directives
     mgmt
     enforce_initial_report
     license_token
     proxy
     proxy_username
     proxy_password
     resolver
     ssl_crl
     ssl_trusted_certificate
     ssl_verify
     state_path
     usage_report
\n\n

\nThe ngx_mgmt_module module enables\nNGINX Plus license verification and usage reporting.\nThis is mandatory for each NGINX Plus instance since 1.27.2 (\nNGINX Plus R33).\n

\nA JWT license file named license.jwt\nshould be located at\n/etc/nginx/ for Linux or\n/usr/local/etc/nginx/ for FreeBSD\nor at the path specified by the license_token directive.\nThe license file is available from\nMyF5.\n

\nUsage report is sent directly or via proxy\nto F5 licensing endpoint\nevery hour using the\nsecure connection.\nOptionally, in network-restricted environments\nreporting can be configured to\nF5 NGINX\nInstance Manager from which the report can be sent\nto F5 licensing endpoint.\n

\nBy default, if the initial usage report\nis not received by F5 licensing endpoint, nginx will stop processing traffic.\n

\nAutomatic license renewal is supported since 1.29.0\n(NGINX Plus R35)\nfor instances that report directly to the F5 licensing endpoint.\nOn renewal, NGINX downloads the updated JWT from F5 licensing endpoint\nand applies it without\nconfiguration reload.\nThe updated license is stored\nin the state_path directory.\n

\n

\nThis module is available as part of our\ncommercial subscription.\n

\n

\n\n\n

Example Configuration

\n

\nmgmt {\n    # in case if custom path is required\n    license_token custom/file/path/license.jwt;\n\n    # in case of reporting to NGINX Instance Manager\n    usage_report endpoint=NIM_FQDN;\n}\n

\n

\n\n\n

Directives

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n mgmt { ... }
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n main
\n

\nProvides the configuration file context in which\nusage reporting and license management directives\nare specified.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n enforce_initial_report on | off;
\n
\n Default:\n \n
enforce_initial_report on;
\n
\n Context:\n \n mgmt
\n

This directive appeared in version 1.27.2.\n

\nEnables or disables the 180-day grace period\nfor sending the initial usage report.\n

\nThe initial usage report is sent immediately\nupon nginx first start after installation.\nBy default, if the initial report is not received by F5 licensing endpoint,\nnginx stops processing traffic until the report is successfully delivered.\nSetting the directive value to off enables\nthe 180-day grace period during which\nthe initial usage report must be received by F5 licensing endpoint.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n license_token file;
\n
\n Default:\n \n
license_token license.jwt;
\n
\n Context:\n \n mgmt
\n

This directive appeared in version 1.27.2.\n

\nSpecifies a JWT license file.\nBy default, the license.jwt file is expected to be at\n/etc/nginx/ for Linux or at\n/usr/local/etc/nginx/ for FreeBSD.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n proxy host:port;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n mgmt
\n

This directive appeared in version 1.27.4.\n

\nSets the HTTP CONNECT proxy\nused for sending the usage report.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n proxy_username string;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n mgmt
\n

This directive appeared in version 1.27.4.\n

\nSets the user name used for authentication on\nthe proxy.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n proxy_password string;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n mgmt
\n

This directive appeared in version 1.27.4.\n

\nSets the password used for authentication on\nthe proxy.\n

\nThe password is sent unencrypted by default.\nIf the proxy supports TLS, the connection to the proxy can be\nprotected with the stream\nmodule:\n

\nmgmt {\n    proxy          127.0.0.1:8080;\n    proxy_username <name>;\n    proxy_password <password>;\n}\n\nstream {\n    server {\n        listen 127.0.0.1:8080;\n        \n        proxy_ssl                     on;\n        proxy_ssl_verify              on;\n        proxy_ssl_trusted_certificate <proxy_ca_file>;\n\n        proxy_pass <proxy_host>:<proxy_port>;\n    }\n}\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n resolver \n address ...\n [valid=time]\n [ipv4=on|off]\n [ipv6=on|off]\n [status_zone=zone];
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n mgmt
\n

\nConfigures name servers used to resolve usage reporting endpoint name.\nBy default, the system resolver is used.\n

\nSee resolver for details.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n ssl_crl file;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n mgmt
\n

\nSpecifies a file with revoked certificates (CRL)\nin the PEM format used to verify\nthe certificate of the usage reporting endpoint.\nWhen using intermediate certificates, their CRLs should be\nspecified in the same file.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n ssl_trusted_certificate file;
\n
\n Default:\n \n
ssl_trusted_certificate system CA bundle;
\n
\n Context:\n \n mgmt
\n

\nSpecifies a file with trusted CA certificates in the PEM format\nused to verify\nthe certificate of the usage reporting endpoint.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n ssl_verify on | off;
\n
\n Default:\n \n
ssl_verify on;
\n
\n Context:\n \n mgmt
\n

\nEnables or disables verification of the usage reporting endpoint certificate.\n

\n

\nBefore 1.27.2, the default value was off.\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n state_path path;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n mgmt
\n

This directive appeared in version 1.27.2.\n

\nDefines a directory for storing state files\n(nginx-mgmt-*)\ncreated by the ngx_mgmt_module module.\nThe default directory\nfor Linux is /var/lib/nginx/state,\nfor FreeBSD is /var/db/nginx/state.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n usage_report [endpoint=address]\n [interval=time];
\n
\n Default:\n \n
usage_report endpoint=product.connect.nginx.com interval=1h;
\n
\n Context:\n \n mgmt
\n

\nSets the address and port\nof the usage reporting endpoint.\nThe interval parameter sets an interval between\ntwo consecutive reports.\n

\nBefore 1.27.2, the default values were\nnginx-mgmt.local and\n30m.\n

\n

\n\n
\n", "encoding": "utf-8"} +{"path": "en\\docs\\ngx_otel_module.html", "extension": ".html", "size_bytes": 14766, "content": "\nModule ngx_otel_module
\n\nPlanning your ingress-nginx migration? Start here:\nkubernetes.nginx.org.\n\n

Module ngx_otel_module

Example Configuration
Directives
     otel_exporter
     otel_service_name
     otel_resource_attr
     otel_trace
     otel_trace_context
     otel_span_name
     otel_span_attr
Default span attributes
Embedded Variables
\n\n

\nThe ngx_otel_module module provides\nOpenTelemetry\ndistributed tracing support.\nThe module supports\nW3C\ncontext propagation and OTLP/gRPC export protocol.\n

\nThe source code of the module is available\nhere.\nDownload and install instructions are available\nhere.\n

\nThe module is also available in a prebuilt\nnginx-module-otel\npackage\nsince 1.25.3\nand in nginx-plus-module-otel package\nas part of our\ncommercial subscription since 1.23.4.\n

\n\n\n

Example Configuration

\n

\nload_module modules/ngx_otel_module.so;\n\nevents {\n}\n\nhttp {\n\n    otel_exporter {\n        endpoint localhost:4317;\n    }\n\n    server {\n        listen 127.0.0.1:8080;\n\n        location / {\n            otel_trace         on;\n            otel_trace_context inject;\n\n            proxy_pass http://backend;\n        }\n    }\n}\n

\n

\n\n\n

Directives

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n otel_exporter { ... }
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n http
\n

\nSpecifies OTel data export parameters:\n\n

\n\n
\n endpoint [(http|https)://]host:port;
\n
\nOTLP/gRPC endpoint that will accept telemetry data.\nTLS is supported since 0.1.2.\n
\n\n
\n trusted_certificate path;
\n
\nthe CA certificates file in PEM format used to verify TLS endpoint\n(since 0.1.2).\nDefaults to OS provided CA bundle.\n
\n\n
header name value;
\n
\na custom HTTP header to add to telemetry export request (since 0.1.2).\n
\n\n
interval time;
\n
\nthe maximum interval between two exports,\nby default is 5 seconds.\n
\n\n
batch_size number;
\n
\nthe maximum number of spans to be sent in one batch per worker,\nby default is 512.\n
\n\n
batch_count number;
\n
\nthe number of pending batches per worker,\nspans exceeding the limit are dropped,\nby default is 4.\n
\n\n

\nExample:\n

\notel_exporter {\n    endpoint https://otel-example.nginx.com:4317;\n\n    header X-API-Token \"my-token-value\";\n}\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n otel_service_name name;
\n
\n Default:\n \n
otel_service_name unknown_service:nginx;
\n
\n Context:\n \n http
\n

\nSets the\n“service.name”\nattribute of the OTel resource.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n otel_resource_attr name value;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n http
\n

This directive appeared in version 0.1.2.\n

\nSets a custom OTel resource attribute.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n otel_trace on |\n off |\n $variable;
\n
\n Default:\n \n
otel_trace off;
\n
\n Context:\n \n http, server, location
\n

\nEnables or disables OpenTelemetry tracing.\nThe directive can also be enabled by specifying a variable:\n

\nsplit_clients \"$otel_trace_id\" $ratio_sampler {\n              10%              on;\n              *                off;\n}\n\nserver {\n    location / {\n        otel_trace         $ratio_sampler;\n        otel_trace_context inject;\n        proxy_pass         http://backend;\n    }\n}\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n otel_trace_context extract |\n inject |\n propagate |\n ignore;
\n
\n Default:\n \n
otel_trace_context ignore;
\n
\n Context:\n \n http, server, location
\n

\nSpecifies how to propagate\ntraceparent/tracestate headers:\n\n

\n\n
extract
\n
\nuses an existing trace context from the request,\nso that the identifiers of\na trace and\nthe parent span\nare inherited from the incoming request.\n
\n\n
inject
\n
\nadds a new context to the request, overwriting existing headers, if any.\n
\n\n
propagate
\n
\nupdates the existing context\n(combines extract and inject).\n
\n\n
ignore
\n
\nskips context headers processing.\n
\n\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n otel_span_name name;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n http, server, location
\n

\nDefines the name of the OTel\nspan.\nBy default, it is a name of the location for a request.\nThe name can contain variables.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n otel_span_attr name value;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n http, server, location
\n

\nAdds a custom OTel span attribute.\nThe value can contain variables.\n

\n\n\n

Default span attributes

\nThe following\nspan\nattributes\nare added automatically:\n\n

\n

\n\n\n

Embedded Variables

\n

\n\n
$otel_trace_id
\n
\nthe identifier of the trace the current span belongs to,\nfor example, 56552bc4daa3bf39c08362527e1dd6c4\n
\n\n
$otel_span_id
\n
\nthe identifier of the current span,\nfor example, 4c0b8531ec38ca59\n
\n\n
$otel_parent_id
\n
\nthe identifier of the parent span,\nfor example, dc94d281b0f884ea\n
\n\n
$otel_parent_sampled
\n
\nthe “sampled” flag of the parent span,\ncan be “1” or “0”\n
\n\n

\n

\n\n
\n", "encoding": "utf-8"} +{"path": "en\\docs\\quic.html", "extension": ".html", "size_bytes": 7690, "content": "\nSupport for QUIC and HTTP/3
\n\nPlanning your ingress-nginx migration? Start here:\nkubernetes.nginx.org.\n\n

Support for QUIC and HTTP/3

Building from sources
Configuration tips
Troubleshooting

\nSupport for\nQUIC\nand\nHTTP/3\nprotocols is available since 1.25.0, it is included in\nLinux binary packages.\nPlease refer to the\nngx_http_v3_module\ndocumentation.\n

Building from sources

\nThe build is configured using the configure command.\nPlease refer to Building nginx from Sources for details.\n

\nThe OpenSSL library\nversion 3.5.1 or higher is recommended to build nginx with QUIC support.\nOtherwise, the OpenSSL\ncompatibility layer will be used that does not support\nearly data.\nAlternatively,\nBoringSSL,\nLibreSSL, or\nQuicTLS\nprebuilt libraries can be used.\n

\nUse the following command to configure nginx with\nBoringSSL:\n

\n./configure\n    --with-debug\n    --with-http_v3_module\n    --with-cc-opt=\"-I../boringssl/include\"\n    --with-ld-opt=\"-L../boringssl/build -lstdc++\"\n

\n

\nAlternatively, nginx can be configured with\nQuicTLS:\n

\n./configure\n    --with-debug\n    --with-http_v3_module\n    --with-cc-opt=\"-I../quictls/build/include\"\n    --with-ld-opt=\"-L../quictls/build/lib\"\n

\n

\nAlternatively, nginx can be configured with\nLibreSSL:\n

\n./configure\n    --with-debug\n    --with-http_v3_module\n    --with-cc-opt=\"-I../libressl/build/include\"\n    --with-ld-opt=\"-L../libressl/build/lib\"\n

\n

\nAfter configuration,\nnginx is compiled and installed using make.\n

Configuration tips

\nThe listen directive in\nngx_http_core_module\nmodule got a new parameter\nquic\nwhich enables HTTP/3 over QUIC on the specified port.\n

\nAlong with the quic parameter\nit is also possible to specify the\nreuseport\nparameter to make it work properly with multiple workers.\n

\nTo enable\naddress validation:\n

\nquic_retry on;\n

\n\nTo enable\n0-RTT:\n

\nssl_early_data on;\n

\n\nTo enable\nGSO (Generic Segmentation Offloading):\n

\nquic_gso on;\n

\n\nTo set\nhost key for various tokens:\n

\nquic_host_key <filename>;\n

\n

\nQUIC requires TLSv1.3 protocol version which is enabled by default\nin the ssl_protocols directive.\n

\nBy default,\nGSO Linux-specific optimization\nis disabled.\nEnable it in case a corresponding network interface is configured\nto support GSO.\n

Troubleshooting

\nTips that may help to identify problems:\n

\n

\n", "encoding": "utf-8"} +{"path": "en\\docs\\switches.html", "extension": ".html", "size_bytes": 4704, "content": "\nCommand-line parameters
\n\nPlanning your ingress-nginx migration? Start here:\nkubernetes.nginx.org.\n\n

Command-line parameters

\nnginx supports the following command-line parameters:\n

\n

\n", "encoding": "utf-8"} +{"path": "en\\docs\\syntax.html", "extension": ".html", "size_bytes": 4219, "content": "\nConfiguration file measurement units
\n\nPlanning your ingress-nginx migration? Start here:\nkubernetes.nginx.org.\n\n

Configuration file measurement units

Sizes and offsets
Time intervals

\nnginx supports several measurement units for specifying\nsizes, offsets, and time intervals within configuration files.\n

Sizes and offsets

\nSizes can be specified in bytes, kilobytes, or megabytes\nusing the following suffixes:\n\n

\n

\nFor example,\n“1024”, “8k”, “1m”.\n

\nOffsets can be also specified in gigabytes using the\ng or G suffixes.\n

Time intervals

\nTime intervals can be specified in milliseconds, seconds,\nminutes, hours, days and so on, using the following suffixes:\n\n\n\n\n\n\n\n\n\n
msmilliseconds
sseconds (default)
mminutes
hhours
ddays
wweeks
Mmonths, 30 days
yyears, 365 days
\n

\nMultiple units can be combined in a single value\nby specifying them in the order from the most to the least significant,\nand optionally separated by whitespace.\nFor example, “1h 30m” specifies the same time\nas “90m” or “5400s”.\n

\n

\n

\n", "encoding": "utf-8"} +{"path": "en\\docs\\syslog.html", "extension": ".html", "size_bytes": 5004, "content": "\nLogging to syslog
\n\nPlanning your ingress-nginx migration? Start here:\nkubernetes.nginx.org.\n\n

Logging to syslog

\nThe\nerror_log\nand\naccess_log\ndirectives support logging to syslog.\nThe following parameters configure logging to syslog:\n

\n\n
server=address
\n
\nDefines the address of a syslog server.\nThe address can be specified as a domain name or IP address,\nwith an optional port, or as a UNIX-domain socket path\nspecified after the “unix:” prefix.\nIf port is not specified, the UDP port 514 is used.\nIf a domain name resolves to several IP addresses, the first resolved\naddress is used.\n
\n\n
facility=string
\n
\nSets facility of syslog messages, as defined in\nRFC 3164.\nFacility can be one of “kern”, “user”,\n“mail”, “daemon”,\n“auth”, “intern”,\n“lpr”, “news”, “uucp”,\n“clock”, “authpriv”,\n“ftp”, “ntp”, “audit”,\n“alert”, “cron”,\n“local0”..“local7”.\nDefault is “local7”.\n
\n\n
severity=string
\n
\nSets severity of syslog messages for\naccess_log,\nas defined in\nRFC 3164.\nPossible values are the same as for the second parameter (level) of the\nerror_log directive.\nDefault is “info”.\n
\nSeverity of error messages is determined by nginx, thus the parameter\nis ignored in the error_log directive.\n
\n
\n\n
tag=string
\n
\nSets the tag of syslog messages.\nDefault is “nginx”.\n
\n\n
nohostname
\n
\nDisables adding the “hostname” field into the syslog message header (1.9.7).\n
\n\n\n\n

\nExample syslog configuration:\n

\nerror_log syslog:server=192.168.1.1 debug;\n\naccess_log syslog:server=unix:/var/log/nginx.sock,nohostname;\naccess_log syslog:server=[2001:db8::1]:12345,facility=local7,tag=nginx,severity=info combined;\n

\n

\n

\nLogging to syslog is available since version 1.7.1.\nAs part of our\ncommercial subscription\nlogging to syslog is available since version 1.5.3.\n

\n

\n", "encoding": "utf-8"} +{"path": "en\\docs\\sys_errlist.html", "extension": ".html", "size_bytes": 3039, "content": "\nA message “ ‘sys_errlist’ is deprecated; use ‘strerror’ or ‘strerror_r’ instead ”
\n\nPlanning your ingress-nginx migration? Start here:\nkubernetes.nginx.org.\n\n

A message “ ‘sys_errlist’ is deprecated; use ‘strerror’ or ‘strerror_r’ instead ”

\nQ:\nWhile building nginx version 0.7.66, 0.8.35 or higher on Linux\nthe following warning messages are issued:\n\n

\nwarning: `sys_errlist' is deprecated;\n    use `strerror' or `strerror_r' instead\nwarning: `sys_nerr' is deprecated;\n    use `strerror' or `strerror_r' instead\n

\n\n

\nA:\nThis is normal: nginx has to use the deprecated sys_errlist[] and sys_nerr\nin signal handlers because strerror() and strerror_r() functions\nare not Async-Signal-Safe.\n

\n", "encoding": "utf-8"} +{"path": "en\\docs\\varindex.html", "extension": ".html", "size_bytes": 28367, "content": "\nAlphabetical index of variables
\n\nPlanning your ingress-nginx migration? Start here:\nkubernetes.nginx.org.\n\n

Alphabetical index of variables

\n $acme_certificate
$acme_certificate_key
$ancient_browser
$arg_
$args
$binary_remote_addr (ngx_http_core_module)
$binary_remote_addr (ngx_stream_core_module)
$body_bytes_sent
$bytes_received
$bytes_sent (ngx_http_core_module)
$bytes_sent (ngx_http_log_module)
$bytes_sent (ngx_stream_core_module)
$connection (ngx_http_core_module)
$connection (ngx_http_log_module)
$connection (ngx_stream_core_module)
$connection_requests (ngx_http_core_module)
$connection_requests (ngx_http_log_module)
$connection_time
$connections_active
$connections_reading
$connections_waiting
$connections_writing
$content_length
$content_type
$cookie_
$date_gmt
$date_local
$document_root
$document_uri
$fastcgi_path_info
$fastcgi_script_name
$geoip_area_code (ngx_http_geoip_module)
$geoip_area_code (ngx_stream_geoip_module)
$geoip_city (ngx_http_geoip_module)
$geoip_city (ngx_stream_geoip_module)
$geoip_city_continent_code (ngx_http_geoip_module)
$geoip_city_continent_code (ngx_stream_geoip_module)
$geoip_city_country_code (ngx_http_geoip_module)
$geoip_city_country_code (ngx_stream_geoip_module)
$geoip_city_country_code3 (ngx_http_geoip_module)
$geoip_city_country_code3 (ngx_stream_geoip_module)
$geoip_city_country_name (ngx_http_geoip_module)
$geoip_city_country_name (ngx_stream_geoip_module)
$geoip_country_code (ngx_http_geoip_module)
$geoip_country_code (ngx_stream_geoip_module)
$geoip_country_code3 (ngx_http_geoip_module)
$geoip_country_code3 (ngx_stream_geoip_module)
$geoip_country_name (ngx_http_geoip_module)
$geoip_country_name (ngx_stream_geoip_module)
$geoip_dma_code (ngx_http_geoip_module)
$geoip_dma_code (ngx_stream_geoip_module)
$geoip_latitude (ngx_http_geoip_module)
$geoip_latitude (ngx_stream_geoip_module)
$geoip_longitude (ngx_http_geoip_module)
$geoip_longitude (ngx_stream_geoip_module)
$geoip_org (ngx_http_geoip_module)
$geoip_org (ngx_stream_geoip_module)
$geoip_postal_code (ngx_http_geoip_module)
$geoip_postal_code (ngx_stream_geoip_module)
$geoip_region (ngx_http_geoip_module)
$geoip_region (ngx_stream_geoip_module)
$geoip_region_name (ngx_http_geoip_module)
$geoip_region_name (ngx_stream_geoip_module)
$gzip_ratio
$host
$hostname (ngx_http_core_module)
$hostname (ngx_stream_core_module)
$http2
$http3
$http_
$https
$invalid_referer
$is_args
$is_request_port
$jwt_claim_
$jwt_header_
$jwt_payload
$limit_conn_status (ngx_http_limit_conn_module)
$limit_conn_status (ngx_stream_limit_conn_module)
$limit_rate
$limit_req_status
$memcached_key
$modern_browser
$mqtt_preread_clientid
$mqtt_preread_username
$msec (ngx_http_core_module)
$msec (ngx_http_log_module)
$msec (ngx_stream_core_module)
$msie
$nginx_version (ngx_http_core_module)
$nginx_version (ngx_stream_core_module)
$oidc_access_token
$oidc_claim_
$oidc_id_token
$oidc_userinfo
$otel_parent_id
$otel_parent_sampled
$otel_span_id
$otel_trace_id
$pid (ngx_http_core_module)
$pid (ngx_stream_core_module)
$pipe (ngx_http_core_module)
$pipe (ngx_http_log_module)
$protocol
$proxy_add_x_forwarded_for
$proxy_host
$proxy_port
$proxy_protocol_addr (ngx_http_core_module)
$proxy_protocol_addr (ngx_stream_core_module)
$proxy_protocol_port (ngx_http_core_module)
$proxy_protocol_port (ngx_stream_core_module)
$proxy_protocol_server_addr (ngx_http_core_module)
$proxy_protocol_server_addr (ngx_stream_core_module)
$proxy_protocol_server_port (ngx_http_core_module)
$proxy_protocol_server_port (ngx_stream_core_module)
$proxy_protocol_tlv_ (ngx_http_core_module)
$proxy_protocol_tlv_ (ngx_stream_core_module)
$proxy_protocol_tlv_aws_vpce_id (ngx_http_proxy_protocol_vendor_module)
$proxy_protocol_tlv_aws_vpce_id (ngx_stream_proxy_protocol_vendor_module)
$proxy_protocol_tlv_azure_pel_id (ngx_http_proxy_protocol_vendor_module)
$proxy_protocol_tlv_azure_pel_id (ngx_stream_proxy_protocol_vendor_module)
$proxy_protocol_tlv_gcp_conn_id (ngx_http_proxy_protocol_vendor_module)
$proxy_protocol_tlv_gcp_conn_id (ngx_stream_proxy_protocol_vendor_module)
$query_string
$realip_remote_addr (ngx_http_realip_module)
$realip_remote_addr (ngx_stream_realip_module)
$realip_remote_port (ngx_http_realip_module)
$realip_remote_port (ngx_stream_realip_module)
$realpath_root
$remote_addr (ngx_http_core_module)
$remote_addr (ngx_stream_core_module)
$remote_port (ngx_http_core_module)
$remote_port (ngx_stream_core_module)
$remote_user
$request
$request_body
$request_body_file
$request_completion
$request_filename
$request_id
$request_length (ngx_http_core_module)
$request_length (ngx_http_log_module)
$request_method
$request_port
$request_time (ngx_http_core_module)
$request_time (ngx_http_log_module)
$request_uri
$scheme
$secure_link
$secure_link_expires
$sent_http_
$sent_trailer_
$server_addr (ngx_http_core_module)
$server_addr (ngx_stream_core_module)
$server_name
$server_port (ngx_http_core_module)
$server_port (ngx_stream_core_module)
$server_protocol
$session_log_binary_id
$session_log_id
$session_time
$slice_range
$ssl_alpn_protocol (ngx_http_ssl_module)
$ssl_alpn_protocol (ngx_stream_ssl_module)
$ssl_cipher (ngx_http_ssl_module)
$ssl_cipher (ngx_stream_ssl_module)
$ssl_ciphers (ngx_http_ssl_module)
$ssl_ciphers (ngx_stream_ssl_module)
$ssl_client_cert (ngx_http_ssl_module)
$ssl_client_cert (ngx_stream_ssl_module)
$ssl_client_escaped_cert
$ssl_client_fingerprint (ngx_http_ssl_module)
$ssl_client_fingerprint (ngx_stream_ssl_module)
$ssl_client_i_dn (ngx_http_ssl_module)
$ssl_client_i_dn (ngx_stream_ssl_module)
$ssl_client_i_dn_legacy
$ssl_client_raw_cert (ngx_http_ssl_module)
$ssl_client_raw_cert (ngx_stream_ssl_module)
$ssl_client_s_dn (ngx_http_ssl_module)
$ssl_client_s_dn (ngx_stream_ssl_module)
$ssl_client_s_dn_legacy
$ssl_client_serial (ngx_http_ssl_module)
$ssl_client_serial (ngx_stream_ssl_module)
$ssl_client_sigalg (ngx_http_ssl_module)
$ssl_client_sigalg (ngx_stream_ssl_module)
$ssl_client_v_end (ngx_http_ssl_module)
$ssl_client_v_end (ngx_stream_ssl_module)
$ssl_client_v_remain (ngx_http_ssl_module)
$ssl_client_v_remain (ngx_stream_ssl_module)
$ssl_client_v_start (ngx_http_ssl_module)
$ssl_client_v_start (ngx_stream_ssl_module)
$ssl_client_verify (ngx_http_ssl_module)
$ssl_client_verify (ngx_stream_ssl_module)
$ssl_curve (ngx_http_ssl_module)
$ssl_curve (ngx_stream_ssl_module)
$ssl_curves (ngx_http_ssl_module)
$ssl_curves (ngx_stream_ssl_module)
$ssl_early_data
$ssl_ech_outer_server_name (ngx_http_ssl_module)
$ssl_ech_outer_server_name (ngx_stream_ssl_module)
$ssl_ech_status (ngx_http_ssl_module)
$ssl_ech_status (ngx_stream_ssl_module)
$ssl_preread_alpn_protocols
$ssl_preread_protocol
$ssl_preread_server_name
$ssl_protocol (ngx_http_ssl_module)
$ssl_protocol (ngx_stream_ssl_module)
$ssl_server_name (ngx_http_ssl_module)
$ssl_server_name (ngx_stream_ssl_module)
$ssl_session_id (ngx_http_ssl_module)
$ssl_session_id (ngx_stream_ssl_module)
$ssl_session_reused (ngx_http_ssl_module)
$ssl_session_reused (ngx_stream_ssl_module)
$ssl_sigalg (ngx_http_ssl_module)
$ssl_sigalg (ngx_stream_ssl_module)
$status (ngx_http_core_module)
$status (ngx_http_log_module)
$status (ngx_stream_core_module)
$tcpinfo_rtt
$tcpinfo_rttvar
$tcpinfo_snd_cwnd
$tcpinfo_rcv_space
$time_iso8601 (ngx_http_core_module)
$time_iso8601 (ngx_http_log_module)
$time_iso8601 (ngx_stream_core_module)
$time_iso8601_ms (ngx_http_core_module)
$time_iso8601_ms (ngx_stream_core_module)
$time_local (ngx_http_core_module)
$time_local (ngx_http_log_module)
$time_local (ngx_stream_core_module)
$uid_got
$uid_reset
$uid_set
$upstream_addr (ngx_http_upstream_module)
$upstream_addr (ngx_stream_upstream_module)
$upstream_bytes_received (ngx_http_upstream_module)
$upstream_bytes_received (ngx_stream_upstream_module)
$upstream_bytes_sent (ngx_http_upstream_module)
$upstream_bytes_sent (ngx_stream_upstream_module)
$upstream_cache_status
$upstream_connect_time (ngx_http_upstream_module)
$upstream_connect_time (ngx_stream_upstream_module)
$upstream_cookie_
$upstream_first_byte_time
$upstream_header_time
$upstream_http_
$upstream_last_addr (ngx_http_upstream_module)
$upstream_last_addr (ngx_stream_upstream_module)
$upstream_last_server_name
$upstream_queue_time
$upstream_response_length
$upstream_response_time
$upstream_session_time
$upstream_status
$upstream_trailer_
$uri
\n

\n", "encoding": "utf-8"} +{"path": "en\\docs\\welcome_nginx_facebook.html", "extension": ".html", "size_bytes": 8297, "content": "\nI am trying to open Facebook, Yahoo!, Yandex, Tumblr, Google etc., and instead I am getting “Welcome to nginx!” page
\n\nPlanning your ingress-nginx migration? Start here:\nkubernetes.nginx.org.\n\n

I am trying to open Facebook, Yahoo!, Yandex, Tumblr, Google etc., and instead I am getting “Welcome to nginx!” page

\nQ:\nI am trying to open Facebook, Yahoo!, Yandex, Google, or some\nother well known web site and instead I am getting a blank web page\nwith a message referring to nginx: “Welcome to nginx!” or\n“404 Not Found / nginx”.\n

\nI suspect something is wrong and there is probably a malicious attempt\nto direct me to a rogue web page (to break into my computer, do\nphishing etc.). Why is that, and what has nginx to do with my attempts\nto connect to Facebook (Yahoo!, Google, etc.) ?\n

\n \n

\nA:\nFirst of all, the “Welcome to nginx!” page you see is\nNOT our website. At nginx, we write and distribute a free\n\nopen source web server software. A web page saying\n“Welcome to nginx!” is just a diagnostics response that\ncan be produced by any of the websites out there, running nginx\nweb server. Currently, nginx is the 2nd most popular open source\nweb server in the world, it’s being used by over 126,000,000 (or\n14% of the Internet) websites. Most of these websites are\nlegitimate, but some aren’t. Our software was created with a good\nreason of enabling performance and scalability on the Internet,\nit is licensed under \npopular open source license, and has nothing to do with any\nkind of threatening or malicious activity per se —\nnginx is NOT a malware, and it is NOT on your computer. But someone’s\nmalware could have indeed tampered with your computer or router,\nredirecting you to a fraudulent Internet server.\n

\nWe recommend running an anti-virus check on your computer, and\nwe recommend to check and verify your entire system setup with the\nhelp of your ISP, or another support personnel:\n

\n(Disclaimer: at nginx we are not responsible for any negative\nimpact or effects that the actions below might cause. Use the\nfollowing recommendations at your own risk, especially if\nyou aren’t an experienced user of your operating system and/or\nInternet applications. In no event shall nginx be liable for\nany direct, indirect, incidental, special, exemplary, or\nconsequential damages, including, but not limited to loss of\nuse, data, or profits; or business interruption).\n

\n

\n

\nSomething must be wrong with your operating\nsystem settings, home router setup, or browser\nconfiguration, if you are trying to access a well known web site\nand what you get instead is “Welcome to nginx!”.\nThis should NOT happen if your computers and network are\nclean and safe.\n

\nIf changing DNS servers to Google Public DNS, flushing DNS resolver\ncache, fixing your browser configuration, or cleaning \"hosts\" file\n(when applicable) have helped, it might be that there’s a malware\nsomewhere on your PC or around. Find and clean it using\nyour preferred anti-virus and anti-malware tools.\n

\nAdditional articles that might be helpful:\n

\nDCWG.org:\n

\n\nHow can you detect if your computer has been violated and infected\nwith DNS Changer?\n

\n\nHow to clean up or fix malicious software (“malware”)\nassociated with DNS Changer\n

\nMicrosoft:\n

\n\nMalicious Software Removal Tool\n

\n\nHow can I reset the Hosts file back to the default?\n

\n\nHow to reset Internet Protocol (TCP/IP)\n

\nFirefox Help:\n

\n\nDisable or remove Add-ons\n

\nTech-Recipes:\n

\n\nDNS Cache Flush, Clear, or Reset in Vista,\nWindows 7, and Windows 8\n

\n", "encoding": "utf-8"} +{"path": "en\\docs\\windows.html", "extension": ".html", "size_bytes": 5779, "content": "\nnginx for Windows
\n\nPlanning your ingress-nginx migration? Start here:\nkubernetes.nginx.org.\n\n

nginx for Windows

Known issues
Possible future enhancements

\nVersion of nginx for Windows uses the native Win32 API (not the Cygwin emulation\nlayer).\nOnly the select() and poll() (1.15.9)\nconnection processing methods are currently used,\nso high performance and scalability should not be expected.\nDue to this and some other known issues version of nginx for Windows\nis considered to be a beta version.\nAt this time, it provides almost the same functionality as a UNIX version\nof nginx except for\nXSLT filter, image filter, GeoIP module, and embedded Perl language.\n

\nTo install nginx/Windows, download\nthe latest mainline version distribution (1.31.0),\nsince the mainline branch of nginx contains all known fixes.\nThen unpack the distribution, go to the\nnginx-1.31.0\ndirectory, and run nginx.\nHere is an example for the drive C: root directory:\n\n

\ncd c:\\\nunzip nginx-1.31.0.zip\ncd nginx-1.31.0\nstart nginx\n

\n\nRun the tasklist command-line utility\nto see nginx processes:\n\n

\nC:\\nginx-1.31.0>tasklist /fi \"imagename eq nginx.exe\"\n\nImage Name           PID Session Name     Session#    Mem Usage\n=============== ======== ============== ========== ============\nnginx.exe            652 Console                 0      2 780 K\nnginx.exe           1332 Console                 0      3 112 K\n

\n\nOne of the processes is the master process and another is the worker process.\nIf nginx does not start, look for the reason in\nthe error log file logs\\error.log.\nIf the log file has not been created, the reason for this should be reported\nin the Windows Event Log.\nIf an error page is displayed instead of the expected page, also look\nfor the reason in the logs\\error.log file.\n

\nnginx/Windows uses the directory where it has been run as the prefix\nfor relative paths in the configuration.\nIn the example above, the prefix is\nC:\\nginx-1.31.0\\.\nPaths in a configuration file must be specified in UNIX-style using\nforward slashes:\n\n

\naccess_log   logs/site.log;\nroot         C:/web/html;\n

\n

\nnginx/Windows runs as a standard console application (not a service),\nand it can be managed using the following commands:\n\n

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
nginx -s stopfast shutdown
nginx -s quitgraceful shutdown
nginx -s reload\nchanging configuration,\nstarting new worker processes with a new configuration,\ngraceful shutdown of old worker processes\n
nginx -s reopenre-opening log files
\n

Known issues

Possible future enhancements

\n", "encoding": "utf-8"} +{"path": "en\\docs\\dev\\development_guide.html", "extension": ".html", "size_bytes": 217674, "content": "\nDevelopment guide
\n\nPlanning your ingress-nginx migration? Start here:\nkubernetes.nginx.org.\n\n

Development guide

Introduction
     Code layout
     Include files
     Integers
     Common return codes
     Error handling
Strings
     Overview
     Formatting
     Numeric conversion
     Regular expressions
Time
Containers
     Array
     List
     Queue
     Red-Black tree
     Hash
Memory management
     Heap
     Pool
     Shared memory
Logging
Cycle
Buffer
Networking
     Connection
Events
     Event
     I/O events
     Timer events
     Posted events
     Event loop
Processes
Threads
Modules
     Adding new modules
     Core Modules
     Configuration Directives
HTTP
     Connection
     Request
     Configuration
     Phases
     Variables
     Complex values
     Request redirection
     Subrequests
     Request finalization
     Request body
     Request body filters
     Response
     Response body
     Response body filters
     Building filter modules
     Buffer reuse
     Load balancing
Examples
Code style
     General rules
     Files
     Comments
     Preprocessor
     Types
     Variables
     Functions
     Expressions
     Conditionals and Loops
     Labels
Debugging memory issues
Common Pitfalls
     Writing a C module
     C Strings
     Global Variables
     Manual Memory Management
     Threads
     Blocking Libraries
     HTTP Requests to External Services

Introduction

Code layout

Include files

\nThe following two #include statements must appear at the\nbeginning of every nginx file:\n

\n#include <ngx_config.h>\n#include <ngx_core.h>\n

\nIn addition to that, HTTP code should include\n

\n#include <ngx_http.h>\n

\nMail code should include\n

\n#include <ngx_mail.h>\n

\nStream code should include\n

\n#include <ngx_stream.h>\n

Integers

\nFor general purposes, nginx code uses two integer types,\nngx_int_t and ngx_uint_t, which are\ntypedefs for intptr_t and uintptr_t\nrespectively.\n

Common return codes

\nMost functions in nginx return the following codes:\n

Error handling

\nThe ngx_errno macro returns the last system error code.\nIt's mapped to errno on POSIX platforms and to\nGetLastError() call in Windows.\nThe ngx_socket_errno macro returns the last socket error\nnumber.\nLike the ngx_errno macro, it's mapped to\nerrno on POSIX platforms.\nIt's mapped to the WSAGetLastError() call on Windows.\nAccessing the values of ngx_errno or\nngx_socket_errno more than once in a row can cause\nperformance issues.\nIf the error value might be used multiple times, store it in a local variable\nof type ngx_err_t.\nTo set errors, use the ngx_set_errno(errno) and\nngx_set_socket_errno(errno) macros.\n

\nThe values of ngx_errno and\nngx_socket_errno can be passed to the logging functions\nngx_log_error() and ngx_log_debugX(), in\nwhich case system error text is added to the log message.\n

\nExample using ngx_errno:\n

\nngx_int_t\nngx_my_kill(ngx_pid_t pid, ngx_log_t *log, int signo)\n{\n    ngx_err_t  err;\n\n    if (kill(pid, signo) == -1) {\n        err = ngx_errno;\n\n        ngx_log_error(NGX_LOG_ALERT, log, err, \"kill(%P, %d) failed\", pid, signo);\n\n        if (err == NGX_ESRCH) {\n            return 2;\n        }\n\n        return 1;\n    }\n\n    return 0;\n}\n

Strings

Overview

\nFor C strings, nginx uses the unsigned character type pointer\nu_char *.\n

\nThe nginx string type ngx_str_t is defined as follows:\n

\ntypedef struct {\n    size_t      len;\n    u_char     *data;\n} ngx_str_t;\n

\nThe len field holds the string length and\ndata holds the string data.\nThe string, held in ngx_str_t, may or may not be\nnull-terminated after the len bytes.\nIn most cases it’s not.\nHowever, in certain parts of the code (for example, when parsing configuration),\nngx_str_t objects are known to be null-terminated, which\nsimplifies string comparison and makes it easier to pass the strings to\nsyscalls.\n

\nThe string operations in nginx are declared in\nsrc/core/ngx_string.h\nSome of them are wrappers around standard C functions:\n

\n

\n\n

\nOther string functions are nginx-specific\n

\n

\n

\nThe following functions perform case conversion and comparison:\n

\n

\n

\nThe following macros simplify string initialization:\n

Formatting

\nThe following formatting functions support nginx-specific types:\n

\n

\n

\nThe full list of formatting options, supported by these functions is\nin src/core/ngx_string.c. Some of them are:\n

\nYou can prepend u on most types to make them unsigned.\nTo convert output to hex, use X or x.\n

\nFor example:\n\n

\nu_char      buf[NGX_INT_T_LEN];\nsize_t      len;\nngx_uint_t  n;\n\n/* set n here */\n\nlen = ngx_sprintf(buf, \"%ui\", n) — buf;\n

\n\n

Numeric conversion

\nSeveral functions for numeric conversion are implemented in nginx.\nThe first four each convert a string of given length to a positive integer of\nthe indicated type.\nThey return NGX_ERROR on error.\n\n

\n

\nThere are two additional numeric conversion functions.\nLike the first four, they return NGX_ERROR on error.\n\n

\n

Regular expressions

\nThe regular expressions interface in nginx is a wrapper around\nthe PCRE\nlibrary.\nThe corresponding header file is src/core/ngx_regex.h.\n

\nTo use a regular expression for string matching, it first needs to be\ncompiled, which is usually done at the configuration phase.\nNote that since PCRE support is optional, all code using the interface must\nbe protected by the surrounding NGX_PCRE macro:\n\n

\n#if (NGX_PCRE)\nngx_regex_t          *re;\nngx_regex_compile_t   rc;\n\nu_char                errstr[NGX_MAX_CONF_ERRSTR];\n\nngx_str_t  value = ngx_string(\"message (\\\\d\\\\d\\\\d).*Codeword is '(?<cw>\\\\w+)'\");\n\nngx_memzero(&rc, sizeof(ngx_regex_compile_t));\n\nrc.pattern = value;\nrc.pool = cf->pool;\nrc.err.len = NGX_MAX_CONF_ERRSTR;\nrc.err.data = errstr;\n/* rc.options can be set to NGX_REGEX_CASELESS */\n\nif (ngx_regex_compile(&rc) != NGX_OK) {\n    ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, \"%V\", &rc.err);\n    return NGX_CONF_ERROR;\n}\n\nre = rc.regex;\n#endif\n

\nAfter successful compilation, the captures and\nnamed_captures fields in the\nngx_regex_compile_t structure contain the count of all\ncaptures and named captures, respectively, found in the regular expression.\n

\nThe compiled regular expression can then be used for matching against strings:\n

\nngx_int_t  n;\nint        captures[(1 + rc.captures) * 3];\n\nngx_str_t input = ngx_string(\"This is message 123. Codeword is 'foobar'.\");\n\nn = ngx_regex_exec(re, &input, captures, (1 + rc.captures) * 3);\nif (n >= 0) {\n    /* string matches expression */\n\n} else if (n == NGX_REGEX_NO_MATCHED) {\n    /* no match was found */\n\n} else {\n    /* some error */\n    ngx_log_error(NGX_LOG_ALERT, log, 0, ngx_regex_exec_n \" failed: %i\", n);\n}\n

\nThe arguments to ngx_regex_exec() are the compiled regular\nexpression re, the string to match input,\nan optional array of integers to hold any captures that are\nfound, and the array's size.\nThe size of the captures array must be a multiple of three,\nas required by the\nPCRE API.\nIn the example, the size is calculated from the total number of captures plus\none for the matched string itself.\n

\nIf there are matches, captures can be accessed as follows:\n

\nu_char     *p;\nsize_t      size;\nngx_str_t   name, value;\n\n/* all captures */\nfor (i = 0; i < n * 2; i += 2) {\n    value.data = input.data + captures[i];\n    value.len = captures[i + 1] — captures[i];\n}\n\n/* accessing named captures */\n\nsize = rc.name_size;\np = rc.names;\n\nfor (i = 0; i < rc.named_captures; i++, p += size) {\n\n    /* capture name */\n    name.data = &p[2];\n    name.len = ngx_strlen(name.data);\n\n    n = 2 * ((p[0] << 8) + p[1]);\n\n    /* captured value */\n    value.data = &input.data[captures[n]];\n    value.len = captures[n + 1] — captures[n];\n}\n

\n

\nThe ngx_regex_exec_array() function accepts the array of\nngx_regex_elt_t elements (which are just compiled regular\nexpressions with associated names), a string to match, and a log.\nThe function applies expressions from the array to the string until\neither a match is found or no more expressions are left.\nThe return value is NGX_OK when there is a match and\nNGX_DECLINED otherwise, or NGX_ERROR\nin case of error.\n

Time

\nThe ngx_time_t structure represents time with three separate\ntypes for seconds, milliseconds, and the GMT offset:\n

\ntypedef struct {\n    time_t      sec;\n    ngx_uint_t  msec;\n    ngx_int_t   gmtoff;\n} ngx_time_t;\n

\nThe ngx_tm_t structure is an alias for\nstruct tm on UNIX platforms and SYSTEMTIME\non Windows.\n

\nTo obtain the current time, it is usually sufficient to access one of the\navailable global variables, representing the cached time value in the desired\nformat.\n

\nThe available string representations are:\n\n

\n

\nThe ngx_time() and ngx_timeofday() macros\nreturn the current time value in seconds and are the preferred way to access\nthe cached time value.\n

\nTo obtain the time explicitly, use ngx_gettimeofday(),\nwhich updates its argument (pointer to\nstruct timeval).\nThe time is always updated when nginx returns to the event loop from system\ncalls.\nTo update the time immediately, call ngx_time_update(),\nor ngx_time_sigsafe_update() if updating the time in the\nsignal handler context.\n

\nThe following functions convert time_t into the indicated\nbroken-down time representation.\nThe first function in each pair converts time_t to\nngx_tm_t and the second (with the _libc_\ninfix) to struct tm:\n\n

\n\nThe ngx_http_time(buf, time) function returns a string\nrepresentation suitable for use in HTTP headers (for example,\n\"Mon, 28 Sep 1970 06:00:00 GMT\").\nThe ngx_http_cookie_time(buf, time) returns a string\nrepresentation function returns a string representation suitable\nfor HTTP cookies (\"Thu, 31-Dec-37 23:55:55 GMT\").\n

Containers

Array

\nThe nginx array type ngx_array_t is defined as follows\n

\ntypedef struct {\n    void        *elts;\n    ngx_uint_t   nelts;\n    size_t       size;\n    ngx_uint_t   nalloc;\n    ngx_pool_t  *pool;\n} ngx_array_t;\n

\nThe elements of the array are available in the elts field.\nThe nelts field holds the number of elements.\nThe size field holds the size of a single element and is set\nwhen the array is initialized.\n

\nUse the ngx_array_create(pool, n, size) call to create an\narray in a pool, and the ngx_array_init(array, pool, n, size)\ncall to initialize an array object that has already been allocated.\n

\nngx_array_t  *a, b;\n\n/* create an array of strings with preallocated memory for 10 elements */\na = ngx_array_create(pool, 10, sizeof(ngx_str_t));\n\n/* initialize string array for 10 elements */\nngx_array_init(&b, pool, 10, sizeof(ngx_str_t));\n

\nUse the following functions to add elements to an array:\n

\n

\n

\nIf the currently allocated amount of memory is not large enough to accommodate\nthe new elements, a new block of memory is allocated and the existing elements\nare copied to it.\nThe new memory block is normally twice as large as the existing one.\n

\ns = ngx_array_push(a);\nss = ngx_array_push_n(&b, 3);\n

List

\nIn nginx a list is a sequence of arrays, optimized for inserting a potentially\nlarge number of items.\nThe ngx_list_t list type is defined as follows:\n

\ntypedef struct {\n    ngx_list_part_t  *last;\n    ngx_list_part_t   part;\n    size_t            size;\n    ngx_uint_t        nalloc;\n    ngx_pool_t       *pool;\n} ngx_list_t;\n

\nThe actual items are stored in list parts, which are defined as follows:\n

\ntypedef struct ngx_list_part_s  ngx_list_part_t;\n\nstruct ngx_list_part_s {\n    void             *elts;\n    ngx_uint_t        nelts;\n    ngx_list_part_t  *next;\n};\n

\nBefore use, a list must be initialized by calling\nngx_list_init(list, pool, n, size) or created by calling\nngx_list_create(pool, n, size).\nBoth functions take as arguments the size of a single item and a number of\nitems per list part.\nTo add an item to a list, use the ngx_list_push(list)\nfunction.\nTo iterate over the items, directly access the list fields as shown in the\nexample:\n

\nngx_str_t        *v;\nngx_uint_t        i;\nngx_list_t       *list;\nngx_list_part_t  *part;\n\nlist = ngx_list_create(pool, 100, sizeof(ngx_str_t));\nif (list == NULL) { /* error */ }\n\n/* add items to the list */\n\nv = ngx_list_push(list);\nif (v == NULL) { /* error */ }\nngx_str_set(v, \"foo\");\n\nv = ngx_list_push(list);\nif (v == NULL) { /* error */ }\nngx_str_set(v, \"bar\");\n\n/* iterate over the list */\n\npart = &list->part;\nv = part->elts;\n\nfor (i = 0; /* void */; i++) {\n\n    if (i >= part->nelts) {\n        if (part->next == NULL) {\n            break;\n        }\n\n        part = part->next;\n        v = part->elts;\n        i = 0;\n    }\n\n    ngx_do_smth(&v[i]);\n}\n

\nLists are primarily used for HTTP input and output headers.\n

\nLists do not support item removal.\nHowever, when needed, items can internally be marked as missing without actually\nbeing removed from the list.\nFor example, to mark HTTP output headers (which are stored as\nngx_table_elt_t objects) as missing, set the\nhash field in ngx_table_elt_t to\nzero.\nItems marked in this way are explicitly skipped when the headers are iterated\nover.\n

Queue

\nIn nginx a queue is an intrusive doubly linked list, with each node defined as\nfollows:\n

\ntypedef struct ngx_queue_s  ngx_queue_t;\n\nstruct ngx_queue_s {\n    ngx_queue_t  *prev;\n    ngx_queue_t  *next;\n};\n

\nThe head queue node is not linked with any data.\nUse the ngx_queue_init(q) call to initialize the list head\nbefore use.\nQueues support the following operations:\n

\n

\n

\nAn example:\n

\ntypedef struct {\n    ngx_str_t    value;\n    ngx_queue_t  queue;\n} ngx_foo_t;\n\nngx_foo_t    *f;\nngx_queue_t   values, *q;\n\nngx_queue_init(&values);\n\nf = ngx_palloc(pool, sizeof(ngx_foo_t));\nif (f == NULL) { /* error */ }\nngx_str_set(&f->value, \"foo\");\n\nngx_queue_insert_tail(&values, &f->queue);\n\n/* insert more nodes here */\n\nfor (q = ngx_queue_head(&values);\n     q != ngx_queue_sentinel(&values);\n     q = ngx_queue_next(q))\n{\n    f = ngx_queue_data(q, ngx_foo_t, queue);\n\n    ngx_do_smth(&f->value);\n}\n

Red-Black tree

\nThe src/core/ngx_rbtree.h header file provides access to the\neffective implementation of red-black trees.\n

\ntypedef struct {\n    ngx_rbtree_t       rbtree;\n    ngx_rbtree_node_t  sentinel;\n\n    /* custom per-tree data here */\n} my_tree_t;\n\ntypedef struct {\n    ngx_rbtree_node_t  rbnode;\n\n    /* custom per-node data */\n    foo_t              val;\n} my_node_t;\n

\nTo deal with a tree as a whole, you need two nodes: root and sentinel.\nTypically, they are added to a custom structure, allowing you to\norganize your data into a tree in which the leaves contain a link to or embed\nyour data.\n

\nTo initialize a tree:\n

\nmy_tree_t  root;\n\nngx_rbtree_init(&root.rbtree, &root.sentinel, insert_value_function);\n

\nTo traverse a tree and insert new values, use the\n\"insert_value\" functions.\nFor example, the ngx_str_rbtree_insert_value function deals\nwith the ngx_str_t type.\nIts arguments are pointers to a root node of an insertion, the newly created\nnode to be added, and a tree sentinel.\n

\nvoid ngx_str_rbtree_insert_value(ngx_rbtree_node_t *temp,\n                                 ngx_rbtree_node_t *node,\n                                 ngx_rbtree_node_t *sentinel)\n

\nThe traversal is pretty straightforward and can be demonstrated with the\nfollowing lookup function pattern:\n

\nmy_node_t *\nmy_rbtree_lookup(ngx_rbtree_t *rbtree, foo_t *val, uint32_t hash)\n{\n    ngx_int_t           rc;\n    my_node_t          *n;\n    ngx_rbtree_node_t  *node, *sentinel;\n\n    node = rbtree->root;\n    sentinel = rbtree->sentinel;\n\n    while (node != sentinel) {\n\n        n = (my_node_t *) node;\n\n        if (hash != node->key) {\n            node = (hash < node->key) ? node->left : node->right;\n            continue;\n        }\n\n        rc = compare(val, node->val);\n\n        if (rc < 0) {\n            node = node->left;\n            continue;\n        }\n\n        if (rc > 0) {\n            node = node->right;\n            continue;\n        }\n\n        return n;\n    }\n\n    return NULL;\n}\n

\nThe compare() function is a classic comparator function that\nreturns a value less than, equal to, or greater than zero.\nTo speed up lookups and avoid comparing user objects that can be big, an integer\nhash field is used.\n

\nTo add a node to a tree, allocate a new node, initialize it and call\nngx_rbtree_insert():\n

\n    my_node_t          *my_node;\n    ngx_rbtree_node_t  *node;\n\n    my_node = ngx_palloc(...);\n    init_custom_data(&my_node->val);\n\n    node = &my_node->rbnode;\n    node->key = create_key(my_node->val);\n\n    ngx_rbtree_insert(&root->rbtree, node);\n

\nTo remove a node, call the ngx_rbtree_delete() function:\n

\nngx_rbtree_delete(&root->rbtree, node);\n

Hash

\nHash table functions are declared in src/core/ngx_hash.h.\nBoth exact and wildcard matching are supported.\nThe latter requires extra setup and is described in a separate section below.\n

\nBefore initializing a hash, you need to know the number of elements it will\nhold so that nginx can build it optimally.\nTwo parameters that need to be configured are max_size\nand bucket_size, as detailed in a separate\ndocument.\nThey are usually configurable by the user.\nHash initialization settings are stored with the\nngx_hash_init_t type, and the hash itself is\nngx_hash_t:\n

\nngx_hash_t       foo_hash;\nngx_hash_init_t  hash;\n\nhash.hash = &foo_hash;\nhash.key = ngx_hash_key;\nhash.max_size = 512;\nhash.bucket_size = ngx_align(64, ngx_cacheline_size);\nhash.name = \"foo_hash\";\nhash.pool = cf->pool;\nhash.temp_pool = cf->temp_pool;\n

\nThe key is a pointer to a function that creates the hash\ninteger key from a string.\nThere are two generic key-creation functions:\nngx_hash_key(data, len) and\nngx_hash_key_lc(data, len).\nThe latter converts a string to all lowercase characters, so the passed string\nmust be writable.\nIf that is not true, pass the NGX_HASH_READONLY_KEY flag\nto the function, initializing the key array (see below).\n

\nThe hash keys are stored in ngx_hash_keys_arrays_t and\nare initialized with ngx_hash_keys_array_init(arr, type):\nThe second parameter (type) controls the amount of resources\npreallocated for the hash and can be either NGX_HASH_SMALL or\nNGX_HASH_LARGE.\nThe latter is appropriate if you expect the hash to contain thousands of\nelements.\n\n

\nngx_hash_keys_arrays_t  foo_keys;\n\nfoo_keys.pool = cf->pool;\nfoo_keys.temp_pool = cf->temp_pool;\n\nngx_hash_keys_array_init(&foo_keys, NGX_HASH_SMALL);\n

\n

\nTo insert keys into a hash keys array, use the\nngx_hash_add_key(keys_array, key, value, flags) function:\n

\nngx_str_t k1 = ngx_string(\"key1\");\nngx_str_t k2 = ngx_string(\"key2\");\n\nngx_hash_add_key(&foo_keys, &k1, &my_data_ptr_1, NGX_HASH_READONLY_KEY);\nngx_hash_add_key(&foo_keys, &k2, &my_data_ptr_2, NGX_HASH_READONLY_KEY);\n

\n

\nTo build the hash table, call the\nngx_hash_init(hinit, key_names, nelts) function:\n\n

\nngx_hash_init(&hash, foo_keys.keys.elts, foo_keys.keys.nelts);\n

\n\nThe function fails if max_size or\nbucket_size parameters are not big enough.\n

\nWhen the hash is built, use the\nngx_hash_find(hash, key, name, len) function to look up\nelements:\n

\nmy_data_t   *data;\nngx_uint_t   key;\n\nkey = ngx_hash_key(k1.data, k1.len);\n\ndata = ngx_hash_find(&foo_hash, key, k1.data, k1.len);\nif (data == NULL) {\n    /* key not found */\n}\n

\n\n

Wildcard matching

\nTo create a hash that works with wildcards, use the\nngx_hash_combined_t type.\nIt includes the hash type described above and has two additional keys arrays:\ndns_wc_head and dns_wc_tail.\nThe initialization of basic properties is similar to a regular hash:\n

\nngx_hash_init_t      hash\nngx_hash_combined_t  foo_hash;\n\nhash.hash = &foo_hash.hash;\nhash.key = ...;\n

\n

\nIt is possible to add wildcard keys using the\nNGX_HASH_WILDCARD_KEY flag:\n

\n/* k1 = \".example.org\"; */\n/* k2 = \"foo.*\";        */\nngx_hash_add_key(&foo_keys, &k1, &data1, NGX_HASH_WILDCARD_KEY);\nngx_hash_add_key(&foo_keys, &k2, &data2, NGX_HASH_WILDCARD_KEY);\n

\nThe function recognizes wildcards and adds keys into the corresponding arrays.\nPlease refer to the\nmap module\ndocumentation for the description of the wildcard syntax and the\nmatching algorithm.\n

\nDepending on the contents of added keys, you may need to initialize up to three\nkey arrays: one for exact matching (described above), and two more to enable\nmatching starting from the head or tail of a string:\n

\nif (foo_keys.dns_wc_head.nelts) {\n\n    ngx_qsort(foo_keys.dns_wc_head.elts,\n              (size_t) foo_keys.dns_wc_head.nelts,\n              sizeof(ngx_hash_key_t),\n              cmp_dns_wildcards);\n\n    hash.hash = NULL;\n    hash.temp_pool = pool;\n\n    if (ngx_hash_wildcard_init(&hash, foo_keys.dns_wc_head.elts,\n                               foo_keys.dns_wc_head.nelts)\n        != NGX_OK)\n    {\n        return NGX_ERROR;\n    }\n\n    foo_hash.wc_head = (ngx_hash_wildcard_t *) hash.hash;\n}\n

\nThe keys array needs to be sorted, and initialization results must be added\nto the combined hash.\nThe initialization of dns_wc_tail array is done similarly.\n

\nThe lookup in a combined hash is handled by the\nngx_hash_find_combined(chash, key, name, len):\n

\n/* key = \"bar.example.org\"; — will match \".example.org\" */\n/* key = \"foo.example.com\"; — will match \"foo.*\"        */\n\nhkey = ngx_hash_key(key.data, key.len);\nres = ngx_hash_find_combined(&foo_hash, hkey, key.data, key.len);\n

\n

Memory management

Heap

\nTo allocate memory from system heap, use the following functions:\n

\n

\n

Pool

\nMost nginx allocations are done in pools.\nMemory allocated in an nginx pool is freed automatically when the pool is\ndestroyed.\nThis provides good allocation performance and makes memory control easy.\n

\nA pool internally allocates objects in continuous blocks of memory.\nOnce a block is full, a new one is allocated and added to the pool memory\nblock list.\nWhen the requested allocation is too large to fit into a block, the request\nis forwarded to the system allocator and the\nreturned pointer is stored in the pool for further deallocation.\n

\nThe type for nginx pools is ngx_pool_t.\nThe following operations are supported:\n

\n

\n

\nu_char      *p;\nngx_str_t   *s;\nngx_pool_t  *pool;\n\npool = ngx_create_pool(1024, log);\nif (pool == NULL) { /* error */ }\n\ns = ngx_palloc(pool, sizeof(ngx_str_t));\nif (s == NULL) { /* error */ }\nngx_str_set(s, \"foo\");\n\np = ngx_pnalloc(pool, 3);\nif (p == NULL) { /* error */ }\nngx_memcpy(p, \"foo\", 3);\n

\nChain links (ngx_chain_t) are actively used in nginx,\nso the nginx pool implementation provides a way to reuse them.\nThe chain field of ngx_pool_t keeps a\nlist of previously allocated links ready for reuse.\nFor efficient allocation of a chain link in a pool, use the\nngx_alloc_chain_link(pool) function.\nThis function looks up a free chain link in the pool list and allocates a new\nchain link if the pool list is empty.\nTo free a link, call the ngx_free_chain(pool, cl) function.\n

\nCleanup handlers can be registered in a pool.\nA cleanup handler is a callback with an argument which is called when pool is\ndestroyed.\nA pool is usually tied to a specific nginx object (like an HTTP request) and is\ndestroyed when the object reaches the end of its lifetime.\nRegistering a pool cleanup is a convenient way to release resources, close\nfile descriptors or make final adjustments to the shared data associated with\nthe main object.\n

\nTo register a pool cleanup, call\nngx_pool_cleanup_add(pool, size), which returns a\nngx_pool_cleanup_t pointer to\nbe filled in by the caller.\nUse the size argument to allocate context for the cleanup\nhandler.\n

\nngx_pool_cleanup_t  *cln;\n\ncln = ngx_pool_cleanup_add(pool, 0);\nif (cln == NULL) { /* error */ }\n\ncln->handler = ngx_my_cleanup;\ncln->data = \"foo\";\n\n...\n\nstatic void\nngx_my_cleanup(void *data)\n{\n    u_char  *msg = data;\n\n    ngx_do_smth(msg);\n}\n

Shared memory

\nShared memory is used by nginx to share common data between processes.\nThe ngx_shared_memory_add(cf, name, size, tag) function adds\na new shared memory entry ngx_shm_zone_t to a cycle.\nThe function receives the name and size\nof the zone.\nEach shared zone must have a unique name.\nIf a shared zone entry with the provided name and\ntag already exists, the existing zone entry is reused.\nThe function fails with an error if an existing entry with the same name has a\ndifferent tag.\nUsually, the address of the module structure is passed as\ntag, making it possible to reuse shared zones by name within\none nginx module.\n

\nThe shared memory entry structure ngx_shm_zone_t has the\nfollowing fields:\n

\n

\n

\nShared zone entries are mapped to actual memory in\nngx_init_cycle() after the configuration is parsed.\nOn POSIX systems, the mmap() syscall is used to create the\nshared anonymous mapping.\nOn Windows, the CreateFileMapping()/\nMapViewOfFileEx() pair is used.\n

\nFor allocating in shared memory, nginx provides the slab pool\nngx_slab_pool_t type.\nA slab pool for allocating memory is automatically created in each nginx shared\nzone.\nThe pool is located in the beginning of the shared zone and can be accessed by\nthe expression (ngx_slab_pool_t *) shm_zone->shm.addr.\nTo allocate memory in a shared zone, call either\nngx_slab_alloc(pool, size) or\nngx_slab_calloc(pool, size).\nTo free memory, call ngx_slab_free(pool, p).\n

\nSlab pool divides all shared zone into pages.\nEach page is used for allocating objects of the same size.\nThe specified size must be a power of 2, and greater than the minimum size of\n8 bytes.\nNonconforming values are rounded up.\nA bitmask for each page tracks which blocks are in use and which are free for\nallocation.\nFor sizes greater than a half page (which is usually 2048 bytes), allocation is\ndone an entire page at a time\n

\nTo protect data in shared memory from concurrent access, use the mutex\navailable in the mutex field of\nngx_slab_pool_t.\nA mutex is most commonly used by the slab pool while allocating and freeing\nmemory, but it can be used to protect any other user data structures allocated\nin the shared zone.\nTo lock or unlock a mutex, call\nngx_shmtx_lock(&shpool->mutex) or\nngx_shmtx_unlock(&shpool->mutex) respectively.\n

\nngx_str_t        name;\nngx_foo_ctx_t   *ctx;\nngx_shm_zone_t  *shm_zone;\n\nngx_str_set(&name, \"foo\");\n\n/* allocate shared zone context */\nctx = ngx_pcalloc(cf->pool, sizeof(ngx_foo_ctx_t));\nif (ctx == NULL) {\n    /* error */\n}\n\n/* add an entry for 64k shared zone */\nshm_zone = ngx_shared_memory_add(cf, &name, 65536, &ngx_foo_module);\nif (shm_zone == NULL) {\n    /* error */\n}\n\n/* register init callback and context */\nshm_zone->init = ngx_foo_init_zone;\nshm_zone->data = ctx;\n\n\n...\n\n\nstatic ngx_int_t\nngx_foo_init_zone(ngx_shm_zone_t *shm_zone, void *data)\n{\n    ngx_foo_ctx_t  *octx = data;\n\n    size_t            len;\n    ngx_foo_ctx_t    *ctx;\n    ngx_slab_pool_t  *shpool;\n\n    value = shm_zone->data;\n\n    if (octx) {\n        /* reusing a shared zone from old cycle */\n        ctx->value = octx->value;\n        return NGX_OK;\n    }\n\n    shpool = (ngx_slab_pool_t *) shm_zone->shm.addr;\n\n    if (shm_zone->shm.exists) {\n        /* initialize shared zone context in Windows nginx worker */\n        ctx->value = shpool->data;\n        return NGX_OK;\n    }\n\n    /* initialize shared zone */\n\n    ctx->value = ngx_slab_alloc(shpool, sizeof(ngx_uint_t));\n    if (ctx->value == NULL) {\n        return NGX_ERROR;\n    }\n\n    shpool->data = ctx->value;\n\n    return NGX_OK;\n}\n

Logging

\nFor logging nginx uses ngx_log_t objects.\nThe nginx logger supports several types of output:\n\n

\n

\nA logger instance can be a chain of loggers, linked to each other with\nthe next field.\nIn this case, each message is written to all loggers in the chain.\n

\nFor each logger, a severity level controls which messages are written to the\nlog (only events assigned that level or higher are logged).\nThe following severity levels are supported:\n

\n

\n

\nFor debug logging, the debug mask is checked as well.\nThe debug masks are:\n

\n

\n

\nNormally, loggers are created by existing nginx code from\nerror_log directives and are available at nearly every stage\nof processing in cycle, configuration, client connection and other objects.\n

\nNginx provides the following logging macros:\n

\n

\n

\nA log message is formatted in a buffer of size\nNGX_MAX_ERROR_STR (currently, 2048 bytes) on stack.\nThe message is prepended with the severity level, process ID (PID), connection\nID (stored in log->connection), and the system error text.\nFor non-debug messages log->handler is called as well to\nprepend more specific information to the log message.\nHTTP module sets ngx_http_log_error() function as log\nhandler to log client and server addresses, current action (stored in\nlog->action), client request line, server name etc.\n

\n/* specify what is currently done */\nlog->action = \"sending mp4 to client\";\n\n/* error and debug log */\nngx_log_error(NGX_LOG_INFO, c->log, 0, \"client prematurely\n              closed connection\");\n\nngx_log_debug2(NGX_LOG_DEBUG_HTTP, mp4->file.log, 0,\n               \"mp4 start:%ui, length:%ui\", mp4->start, mp4->length);\n

\nThe example above results in log entries like these:\n

\n2016/09/16 22:08:52 [info] 17445#0: *1 client prematurely closed connection while\nsending mp4 to client, client: 127.0.0.1, server: , request: \"GET /file.mp4 HTTP/1.1\"\n2016/09/16 23:28:33 [debug] 22140#0: *1 mp4 start:0, length:10000\n

Cycle

\nA cycle object stores the nginx runtime context created from a specific\nconfiguration.\nIts type is ngx_cycle_t.\nThe current cycle is referenced by the ngx_cycle global\nvariable and inherited by nginx workers as they start.\nEach time the nginx configuration is reloaded, a new cycle is created from the\nnew nginx configuration; the old cycle is usually deleted after the new one is\nsuccessfully created.\n

\nA cycle is created by the ngx_init_cycle() function, which\ntakes the previous cycle as its argument.\nThe function locates the previous cycle's configuration file and inherits as\nmany resources as possible from the previous cycle.\nA placeholder cycle called \"init cycle\" is created as nginx start, then is\nreplaced by an actual cycle built from configuration.\n

\nMembers of the cycle include:\n

\n

\n

Buffer

\nFor input/output operations, nginx provides the buffer type\nngx_buf_t.\nNormally, it's used to hold data to be written to a destination or read from a\nsource.\nA buffer can reference data in memory or in a file and it's technically\npossible for a buffer to reference both at the same time.\nMemory for the buffer is allocated separately and is not related to the buffer\nstructure ngx_buf_t.\n

\nThe ngx_buf_t structure has the following fields:\n

\n

\n

\nFor input and output operations buffers are linked in chains.\nA chain is a sequence of chain links of type ngx_chain_t,\ndefined as follows:\n

\ntypedef struct ngx_chain_s  ngx_chain_t;\n\nstruct ngx_chain_s {\n    ngx_buf_t    *buf;\n    ngx_chain_t  *next;\n};\n

\nEach chain link keeps a reference to its buffer and a reference to the next\nchain link.\n

\nAn example of using buffers and chains:\n

\nngx_chain_t *\nngx_get_my_chain(ngx_pool_t *pool)\n{\n    ngx_buf_t    *b;\n    ngx_chain_t  *out, *cl, **ll;\n\n    /* first buf */\n    cl = ngx_alloc_chain_link(pool);\n    if (cl == NULL) { /* error */ }\n\n    b = ngx_calloc_buf(pool);\n    if (b == NULL) { /* error */ }\n\n    b->start = (u_char *) \"foo\";\n    b->pos = b->start;\n    b->end = b->start + 3;\n    b->last = b->end;\n    b->memory = 1; /* read-only memory */\n\n    cl->buf = b;\n    out = cl;\n    ll = &cl->next;\n\n    /* second buf */\n    cl = ngx_alloc_chain_link(pool);\n    if (cl == NULL) { /* error */ }\n\n    b = ngx_create_temp_buf(pool, 3);\n    if (b == NULL) { /* error */ }\n\n    b->last = ngx_cpymem(b->last, \"foo\", 3);\n\n    cl->buf = b;\n    cl->next = NULL;\n    *ll = cl;\n\n    return out;\n}\n

Networking

Connection

\nThe connection type ngx_connection_t is a wrapper around a\nsocket descriptor.\nIt includes the following fields:\n

\n

\n

\nAn nginx connection can transparently encapsulate the SSL layer.\nIn this case the connection's ssl field holds a pointer to an\nngx_ssl_connection_t structure, keeping all SSL-related data\nfor the connection, including SSL_CTX and\nSSL.\nThe recv, send,\nrecv_chain, and send_chain handlers are\nset to SSL-enabled functions as well.\n

\nThe worker_connections directive in the nginx configuration\nlimits the number of connections per nginx worker.\nAll connection structures are precreated when a worker starts and stored in\nthe connections field of the cycle object.\nTo retrieve a connection structure, use the\nngx_get_connection(s, log) function.\nIt takes as its s argument a socket descriptor, which needs\nto be wrapped in a connection structure.\n

\nBecause the number of connections per worker is limited, nginx provides a\nway to grab connections that are currently in use.\nTo enable or disable reuse of a connection, call the\nngx_reusable_connection(c, reusable) function.\nCalling ngx_reusable_connection(c, 1) sets the\nreuse flag in the connection structure and inserts the\nconnection into the reusable_connections_queue of the cycle.\nWhenever ngx_get_connection() finds out there are no\navailable connections in the cycle's free_connections list,\nit calls ngx_drain_connections() to release a\nspecific number of reusable connections.\nFor each such connection, the close flag is set and its read\nhandler is called which is supposed to free the connection by calling\nngx_close_connection(c) and make it available for reuse.\nTo exit the state when a connection can be reused\nngx_reusable_connection(c, 0) is called.\nHTTP client connections are an example of reusable connections in nginx; they\nare marked as reusable until the first request byte is received from the client.\n

Events

Event

\nEvent object ngx_event_t in nginx provides a mechanism\nfor notification that a specific event has occurred.\n

\nFields in ngx_event_t include:\n

\n

\n

I/O events

\nEach connection obtained by calling the ngx_get_connection()\nfunction has two attached events, c->read and\nc->write, which are used for receiving notification that the\nsocket is ready for reading or writing.\nAll such events operate in Edge-Triggered mode, meaning that they only trigger\nnotifications when the state of the socket changes.\nFor example, doing a partial read on a socket does not make nginx deliver a\nrepeated read notification until more data arrives on the socket.\nEven when the underlying I/O notification mechanism is essentially\nLevel-Triggered (poll, select etc), nginx\nconverts the notifications to Edge-Triggered.\nTo make nginx event notifications consistent across all notifications systems\non different platforms, the functions\nngx_handle_read_event(rev, flags) and\nngx_handle_write_event(wev, lowat) must be called after\nhandling an I/O socket notification or calling any I/O functions on that socket.\nNormally, the functions are called once at the end of each read or write\nevent handler.\n

Timer events

\nAn event can be set to send a notification when a timeout expires.\nThe timer used by events counts milliseconds since some unspecified point\nin the past truncated to ngx_msec_t type.\nIts current value can be obtained from the ngx_current_msec\nvariable.\n

\nThe function ngx_add_timer(ev, timer) sets a timeout for an\nevent, ngx_del_timer(ev) deletes a previously set timeout.\nThe global timeout red-black tree ngx_event_timer_rbtree\nstores all timeouts currently set.\nThe key in the tree is of type ngx_msec_t and is the time\nwhen the event occurs.\nThe tree structure enables fast insertion and deletion operations, as well as\naccess to the nearest timeouts, which nginx uses to find out how long to wait\nfor I/O events and for expiring timeout events.\n

Posted events

\nAn event can be posted which means that its handler will be called at some\npoint later within the current event loop iteration.\nPosting events is a good practice for simplifying code and escaping stack\noverflows.\nPosted events are held in a post queue.\nThe ngx_post_event(ev, q) macro posts the event\nev to the post queue q.\nThe ngx_delete_posted_event(ev) macro deletes the event\nev from the queue it's currently posted in.\nNormally, events are posted to the ngx_posted_events queue,\nwhich is processed late in the event loop — after all I/O and timer\nevents are already handled.\nThe function ngx_event_process_posted() is called to process\nan event queue.\nIt calls event handlers until the queue is empty.\nThis means that a posted event handler can post more events to be processed\nwithin the current event loop iteration.\n

\nAn example:\n

\nvoid\nngx_my_connection_read(ngx_connection_t *c)\n{\n    ngx_event_t  *rev;\n\n    rev = c->read;\n\n    ngx_add_timer(rev, 1000);\n\n    rev->handler = ngx_my_read_handler;\n\n    ngx_my_read(rev);\n}\n\n\nvoid\nngx_my_read_handler(ngx_event_t *rev)\n{\n    ssize_t            n;\n    ngx_connection_t  *c;\n    u_char             buf[256];\n\n    if (rev->timedout) { /* timeout expired */ }\n\n    c = rev->data;\n\n    while (rev->ready) {\n        n = c->recv(c, buf, sizeof(buf));\n\n        if (n == NGX_AGAIN) {\n            break;\n        }\n\n        if (n == NGX_ERROR) { /* error */ }\n\n        /* process buf */\n    }\n\n    if (ngx_handle_read_event(rev, 0) != NGX_OK) { /* error */ }\n}\n

Event loop

\nExcept for the nginx master process, all nginx processes do I/O and so have an\nevent loop.\n(The nginx master process instead spends most of its time in the\n sigsuspend() call waiting for signals to arrive.)\nThe nginx event loop is implemented in the\nngx_process_events_and_timers() function, which is called\nrepeatedly until the process exits.\n

\nThe event loop has the following stages:\n\n

\n

\nAll nginx processes handle signals as well.\nSignal handlers only set global variables which are checked after the\nngx_process_events_and_timers() call.\n

Processes

\nThere are several types of processes in nginx.\nThe type of a process is kept in the ngx_process\nglobal variable, and is one of the following:\n

\nThe nginx processes handle the following signals:\n

\nWhile all nginx worker processes are able to receive and properly handle POSIX\nsignals, the master process does not use the standard kill()\nsyscall to pass signals to workers and helpers.\nInstead, nginx uses inter-process socket pairs which allow sending messages\nbetween all nginx processes.\nCurrently, however, messages are only sent from the master to its children.\nThe messages carry the standard signals.\n

Threads

\nIt is possible to offload into a separate thread tasks that would otherwise\nblock the nginx worker process.\nFor example, nginx can be configured to use threads to perform\nfile I/O.\nAnother use case is a library that doesn't have asynchronous interface\nand thus cannot be normally used with nginx.\nKeep in mind that the threads interface is a helper for the existing\nasynchronous approach to processing client connections, and by no means\nintended as a replacement.\n

\nTo deal with synchronization, the following wrappers over\npthreads primitives are available:\n\n

\n\n

\nInstead of creating a new thread for each task, nginx implements\na thread_pool strategy.\nMultiple thread pools may be configured for different purposes\n(for example, performing I/O on different sets of disks).\nEach thread pool is created at startup and contains a limited number of threads\nthat process a queue of tasks.\nWhen a task is completed, a predefined completion handler is called.\n

\nThe src/core/ngx_thread_pool.h header file contains\nrelevant definitions:\n

\nstruct ngx_thread_task_s {\n    ngx_thread_task_t   *next;\n    ngx_uint_t           id;\n    void                *ctx;\n    void               (*handler)(void *data, ngx_log_t *log);\n    ngx_event_t          event;\n};\n\ntypedef struct ngx_thread_pool_s  ngx_thread_pool_t;\n\nngx_thread_pool_t *ngx_thread_pool_add(ngx_conf_t *cf, ngx_str_t *name);\nngx_thread_pool_t *ngx_thread_pool_get(ngx_cycle_t *cycle, ngx_str_t *name);\n\nngx_thread_task_t *ngx_thread_task_alloc(ngx_pool_t *pool, size_t size);\nngx_int_t ngx_thread_task_post(ngx_thread_pool_t *tp, ngx_thread_task_t *task);\n\n

\nAt configuration time, a module willing to use threads has to obtain a\nreference to a thread pool by calling\nngx_thread_pool_add(cf, name), which either creates a\nnew thread pool with the given name or returns a reference\nto the pool with that name if it already exists.\n

\nTo add a task into a queue of a specified thread pool\ntp at runtime, use the\nngx_thread_task_post(tp, task) function.\n\nTo execute a function in a thread, pass parameters and setup a completion\nhandler using the ngx_thread_task_t structure:\n

\ntypedef struct {\n    int    foo;\n} my_thread_ctx_t;\n\n\nstatic void\nmy_thread_func(void *data, ngx_log_t *log)\n{\n    my_thread_ctx_t *ctx = data;\n\n    /* this function is executed in a separate thread */\n}\n\n\nstatic void\nmy_thread_completion(ngx_event_t *ev)\n{\n    my_thread_ctx_t *ctx = ev->data;\n\n    /* executed in nginx event loop */\n}\n\n\nngx_int_t\nmy_task_offload(my_conf_t *conf)\n{\n    my_thread_ctx_t    *ctx;\n    ngx_thread_task_t  *task;\n\n    task = ngx_thread_task_alloc(conf->pool, sizeof(my_thread_ctx_t));\n    if (task == NULL) {\n        return NGX_ERROR;\n    }\n\n    ctx = task->ctx;\n\n    ctx->foo = 42;\n\n    task->handler = my_thread_func;\n    task->event.handler = my_thread_completion;\n    task->event.data = ctx;\n\n    if (ngx_thread_task_post(conf->thread_pool, task) != NGX_OK) {\n        return NGX_ERROR;\n    }\n\n    return NGX_OK;\n}\n

\n\n

Modules

Adding new modules

\nEach standalone nginx module resides in a separate directory that contains\nat least two files:\nconfig and a file with the module source code.\nThe config file contains all information needed for nginx to\nintegrate the module, for example:\n

\nngx_module_type=CORE\nngx_module_name=ngx_foo_module\nngx_module_srcs=\"$ngx_addon_dir/ngx_foo_module.c\"\n\n. auto/module\n\nngx_addon_name=$ngx_module_name\n

\nThe config file is a POSIX shell script that can set\nand access the following variables:\n

\n\nTo compile a module into nginx statically, use the\n--add-module=/path/to/module argument to the configure\nscript.\nTo compile a module for later dynamic loading into nginx, use the\n--add-dynamic-module=/path/to/module argument.\n

Core Modules

\nModules are the building blocks of nginx, and most of its functionality is\nimplemented as modules.\nThe module source file must contain a global variable of type\nngx_module_t, which is defined as follows:\n

\nstruct ngx_module_s {\n\n    /* private part is omitted */\n\n    void                 *ctx;\n    ngx_command_t        *commands;\n    ngx_uint_t            type;\n\n    ngx_int_t           (*init_master)(ngx_log_t *log);\n\n    ngx_int_t           (*init_module)(ngx_cycle_t *cycle);\n\n    ngx_int_t           (*init_process)(ngx_cycle_t *cycle);\n    ngx_int_t           (*init_thread)(ngx_cycle_t *cycle);\n    void                (*exit_thread)(ngx_cycle_t *cycle);\n    void                (*exit_process)(ngx_cycle_t *cycle);\n\n    void                (*exit_master)(ngx_cycle_t *cycle);\n\n    /* stubs for future extensions are omitted */\n};\n

\nThe omitted private part includes the module version and a signature and is\nfilled using the predefined macro NGX_MODULE_V1.\n

\nEach module keeps its private data in the ctx field,\nrecognizes the configuration directives, specified in the\ncommands array, and can be invoked at certain stages of\nnginx lifecycle.\nThe module lifecycle consists of the following events:\n\n

\n\nBecause threads are used in nginx only as a supplementary I/O facility with its\nown API, init_thread and exit_thread\nhandlers are not currently called.\nThere is also no init_master handler, because it would be\nunnecessary overhead.\n

\nThe module type defines exactly what is stored in the\nctx field.\nIts value is one of the following types:\n

\nThe NGX_CORE_MODULE is the most basic and thus the most\ngeneric and most low-level type of module.\nThe other module types are implemented on top of it and provide a more\nconvenient way to deal with corresponding domains, like handling events or HTTP\nrequests.\n

\nThe set of core modules includes ngx_core_module,\nngx_errlog_module, ngx_regex_module,\nngx_thread_pool_module and\nngx_openssl_module modules.\nThe HTTP module, the stream module, the mail module and event modules are core\nmodules too.\nThe context of a core module is defined as:\n

\ntypedef struct {\n    ngx_str_t             name;\n    void               *(*create_conf)(ngx_cycle_t *cycle);\n    char               *(*init_conf)(ngx_cycle_t *cycle, void *conf);\n} ngx_core_module_t;\n

\nwhere the name is a module name string,\ncreate_conf and init_conf\nare pointers to functions that create and initialize module configuration\nrespectively.\nFor core modules, nginx calls create_conf before parsing\na new configuration and init_conf after all configuration\nis parsed successfully.\nThe typical create_conf function allocates memory for the\nconfiguration and sets default values.\n

\nFor example, a simplistic module called ngx_foo_module might\nlook like this:\n

\n/*\n * Copyright (C) Author.\n */\n\n\n#include <ngx_config.h>\n#include <ngx_core.h>\n\n\ntypedef struct {\n    ngx_flag_t  enable;\n} ngx_foo_conf_t;\n\n\nstatic void *ngx_foo_create_conf(ngx_cycle_t *cycle);\nstatic char *ngx_foo_init_conf(ngx_cycle_t *cycle, void *conf);\n\nstatic char *ngx_foo_enable(ngx_conf_t *cf, void *post, void *data);\nstatic ngx_conf_post_t  ngx_foo_enable_post = { ngx_foo_enable };\n\n\nstatic ngx_command_t  ngx_foo_commands[] = {\n\n    { ngx_string(\"foo_enabled\"),\n      NGX_MAIN_CONF|NGX_DIRECT_CONF|NGX_CONF_FLAG,\n      ngx_conf_set_flag_slot,\n      0,\n      offsetof(ngx_foo_conf_t, enable),\n      &ngx_foo_enable_post },\n\n      ngx_null_command\n};\n\n\nstatic ngx_core_module_t  ngx_foo_module_ctx = {\n    ngx_string(\"foo\"),\n    ngx_foo_create_conf,\n    ngx_foo_init_conf\n};\n\n\nngx_module_t  ngx_foo_module = {\n    NGX_MODULE_V1,\n    &ngx_foo_module_ctx,                   /* module context */\n    ngx_foo_commands,                      /* module directives */\n    NGX_CORE_MODULE,                       /* module type */\n    NULL,                                  /* init master */\n    NULL,                                  /* init module */\n    NULL,                                  /* init process */\n    NULL,                                  /* init thread */\n    NULL,                                  /* exit thread */\n    NULL,                                  /* exit process */\n    NULL,                                  /* exit master */\n    NGX_MODULE_V1_PADDING\n};\n\n\nstatic void *\nngx_foo_create_conf(ngx_cycle_t *cycle)\n{\n    ngx_foo_conf_t  *fcf;\n\n    fcf = ngx_pcalloc(cycle->pool, sizeof(ngx_foo_conf_t));\n    if (fcf == NULL) {\n        return NULL;\n    }\n\n    fcf->enable = NGX_CONF_UNSET;\n\n    return fcf;\n}\n\n\nstatic char *\nngx_foo_init_conf(ngx_cycle_t *cycle, void *conf)\n{\n    ngx_foo_conf_t *fcf = conf;\n\n    ngx_conf_init_value(fcf->enable, 0);\n\n    return NGX_CONF_OK;\n}\n\n\nstatic char *\nngx_foo_enable(ngx_conf_t *cf, void *post, void *data)\n{\n    ngx_flag_t  *fp = data;\n\n    if (*fp == 0) {\n        return NGX_CONF_OK;\n    }\n\n    ngx_log_error(NGX_LOG_NOTICE, cf->log, 0, \"Foo Module is enabled\");\n\n    return NGX_CONF_OK;\n}\n

\n

Configuration Directives

\nThe ngx_command_t type defines a single configuration\ndirective.\nEach module that supports configuration provides an array of such structures\nthat describe how to process arguments and what handlers to call:\n

\ntypedef struct ngx_command_s  ngx_command_t;\n\nstruct ngx_command_s {\n    ngx_str_t             name;\n    ngx_uint_t            type;\n    char               *(*set)(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);\n    ngx_uint_t            conf;\n    ngx_uint_t            offset;\n    void                 *post;\n};\n

\nTerminate the array with the special value ngx_null_command.\nThe name is the name of a directive as it appears\nin the configuration file, for example \"worker_processes\" or \"listen\".\nThe type is a bit-field of flags that specify the number of\narguments the directive takes, its type, and the context in which it appears.\nThe flags are:\n\n

\n\nThe flags for directive types are:\n\n

\n\nA directive's context defines where it may appear in the configuration:\n\n

\n\nThe configuration parser uses these flags to throw an error in case of\na misplaced directive and calls directive handlers supplied with a proper\nconfiguration pointer, so that the same directives in different locations can\nstore their values in distinct places.\n

\nThe set field defines a handler that processes a directive\nand stores parsed values into the corresponding configuration.\nThere's a number of functions that perform common conversions:\n\n

\n\n

\nThe conf field defines which configuration structure is\npassed to the directory handler.\nCore modules only have the global configuration and set\nNGX_DIRECT_CONF flag to access it.\nModules like HTTP, Stream or Mail create hierarchies of configurations.\nFor example, a module's configuration is created for server,\nlocation and if scopes.\n\n

\n\n

\nThe offset defines the offset of a field in a module\nconfiguration structure that holds values for this particular directive.\nThe typical use is to employ the offsetof() macro.\n

\nThe post field has two purposes: it may be used to define\na handler to be called after the main handler has completed, or to pass\nadditional data to the main handler.\nIn the first case, the ngx_conf_post_t structure needs to\nbe initialized with a pointer to the handler, for example:\n

\nstatic char *ngx_do_foo(ngx_conf_t *cf, void *post, void *data);\nstatic ngx_conf_post_t  ngx_foo_post = { ngx_do_foo };\n

\nThe post argument is the ngx_conf_post_t\nobject itself, and the data is a pointer to the value,\nconverted from arguments by the main handler with the appropriate type.\n

HTTP

Connection

\nEach HTTP client connection runs through the following stages:\n

Request

\nFor each client HTTP request the ngx_http_request_t object is\ncreated. Some of the fields of this object are:\n

Configuration

\nEach HTTP module can have three types of configuration:\n

\nConfiguration structures are created at the nginx configuration stage by\ncalling functions, which allocate the structures, initialize them\nand merge them.\nThe following example shows how to create a simple location\nconfiguration for a module.\nThe configuration has one setting, foo, of type\nunsigned integer.\n

\ntypedef struct {\n    ngx_uint_t  foo;\n} ngx_http_foo_loc_conf_t;\n\n\nstatic ngx_http_module_t  ngx_http_foo_module_ctx = {\n    NULL,                                  /* preconfiguration */\n    NULL,                                  /* postconfiguration */\n\n    NULL,                                  /* create main configuration */\n    NULL,                                  /* init main configuration */\n\n    NULL,                                  /* create server configuration */\n    NULL,                                  /* merge server configuration */\n\n    ngx_http_foo_create_loc_conf,          /* create location configuration */\n    ngx_http_foo_merge_loc_conf            /* merge location configuration */\n};\n\n\nstatic void *\nngx_http_foo_create_loc_conf(ngx_conf_t *cf)\n{\n    ngx_http_foo_loc_conf_t  *conf;\n\n    conf = ngx_pcalloc(cf->pool, sizeof(ngx_http_foo_loc_conf_t));\n    if (conf == NULL) {\n        return NULL;\n    }\n\n    conf->foo = NGX_CONF_UNSET_UINT;\n\n    return conf;\n}\n\n\nstatic char *\nngx_http_foo_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)\n{\n    ngx_http_foo_loc_conf_t *prev = parent;\n    ngx_http_foo_loc_conf_t *conf = child;\n\n    ngx_conf_merge_uint_value(conf->foo, prev->foo, 1);\n}\n

\nAs seen in the example, the ngx_http_foo_create_loc_conf()\nfunction creates a new configuration structure, and\nngx_http_foo_merge_loc_conf() merges a configuration with\nconfiguration from a higher level.\nIn fact, server and location configuration do not exist only at the server and\nlocation levels, but are also created for all levels above them.\nSpecifically, a server configuration is also created at the main level and\nlocation configurations are created at the main, server, and location levels.\nThese configurations make it possible to specify server- and location-specific\nsettings at any level of an nginx configuration file.\nEventually configurations are merged down.\nA number of macros like NGX_CONF_UNSET and\nNGX_CONF_UNSET_UINT are provided\nfor indicating a missing setting and ignoring it while merging.\nStandard nginx merge macros like ngx_conf_merge_value() and\nngx_conf_merge_uint_value() provide a convenient way to\nmerge a setting and set the default value if none of the configurations\nprovided an explicit value.\nFor complete list of macros for different types, see\nsrc/core/ngx_conf_file.h.\n

\nThe following macros are available.\nfor accessing configuration for HTTP modules at configuration time.\nThey all take ngx_conf_t reference as the first argument.\n

\nThe following example gets a pointer to a location configuration of\nstandard nginx core module\nngx_http_core_module\nand replaces the location content handler kept\nin the handler field of the structure.\n

\nstatic ngx_int_t ngx_http_foo_handler(ngx_http_request_t *r);\n\n\nstatic ngx_command_t  ngx_http_foo_commands[] = {\n\n    { ngx_string(\"foo\"),\n      NGX_HTTP_LOC_CONF|NGX_CONF_NOARGS,\n      ngx_http_foo,\n      0,\n      0,\n      NULL },\n\n      ngx_null_command\n};\n\n\nstatic char *\nngx_http_foo(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)\n{\n    ngx_http_core_loc_conf_t  *clcf;\n\n    clcf = ngx_http_conf_get_module_loc_conf(cf, ngx_http_core_module);\n    clcf->handler = ngx_http_bar_handler;\n\n    return NGX_CONF_OK;\n}\n

\nThe following macros are available for accessing configuration for HTTP\nmodules at runtime.\n

\nThese macros receive a reference to an HTTP request\nngx_http_request_t.\nThe main configuration of a request never changes.\nServer configuration can change from the default after\nthe virtual server for the request is chosen.\nLocation configuration selected for processing a request can change multiple\ntimes as a result of a rewrite operation or internal redirect.\nThe following example shows how to access a module's HTTP configuration at\nruntime.\n

\nstatic ngx_int_t\nngx_http_foo_handler(ngx_http_request_t *r)\n{\n    ngx_http_foo_loc_conf_t  *flcf;\n\n    flcf = ngx_http_get_module_loc_conf(r, ngx_http_foo_module);\n\n    ...\n}\n

Phases

\nEach HTTP request passes through a sequence of phases.\nIn each phase a distinct type of processing is performed on the request.\nModule-specific handlers can be registered in most phases,\nand many standard nginx modules register their phase handlers as a way\nto get called at a specific stage of request processing.\nPhases are processed successively and the phase handlers are called\nonce the request reaches the phase.\nFollowing is the list of nginx HTTP phases.\n

\nFollowing is the example of a preaccess phase handler.\n

\nstatic ngx_http_module_t  ngx_http_foo_module_ctx = {\n    NULL,                                  /* preconfiguration */\n    ngx_http_foo_init,                     /* postconfiguration */\n\n    NULL,                                  /* create main configuration */\n    NULL,                                  /* init main configuration */\n\n    NULL,                                  /* create server configuration */\n    NULL,                                  /* merge server configuration */\n\n    NULL,                                  /* create location configuration */\n    NULL                                   /* merge location configuration */\n};\n\n\nstatic ngx_int_t\nngx_http_foo_handler(ngx_http_request_t *r)\n{\n    ngx_table_elt_t  *ua;\n\n    ua = r->headers_in.user_agent;\n\n    if (ua == NULL) {\n        return NGX_DECLINED;\n    }\n\n    /* reject requests with \"User-Agent: foo\" */\n    if (ua->value.len == 3 && ngx_strncmp(ua->value.data, \"foo\", 3) == 0) {\n        return NGX_HTTP_FORBIDDEN;\n    }\n\n    return NGX_DECLINED;\n}\n\n\nstatic ngx_int_t\nngx_http_foo_init(ngx_conf_t *cf)\n{\n    ngx_http_handler_pt        *h;\n    ngx_http_core_main_conf_t  *cmcf;\n\n    cmcf = ngx_http_conf_get_module_main_conf(cf, ngx_http_core_module);\n\n    h = ngx_array_push(&cmcf->phases[NGX_HTTP_PREACCESS_PHASE].handlers);\n    if (h == NULL) {\n        return NGX_ERROR;\n    }\n\n    *h = ngx_http_foo_handler;\n\n    return NGX_OK;\n}\n

\nPhase handlers are expected to return specific codes:\n

\nFor some phases, return codes are treated in a slightly different way.\nAt the content phase, any return code other that\nNGX_DECLINED is considered a finalization code.\nAny return code from the location content handlers is considered a\nfinalization code.\nAt the access phase, in\nsatisfy any\nmode,\nany return code other than NGX_OK,\nNGX_DECLINED, NGX_AGAIN,\nNGX_DONE is considered a denial.\nIf no subsequent access handlers allow or deny access with a different\ncode, the denial code will become the finalization code.\n

Variables

Accessing existing variables

\nVariables can be referenced by index (this is the most common method)\nor name (see below).\nThe index is created at configuration stage, when a variable is added\nto the configuration.\nTo obtain the variable index, use\nngx_http_get_variable_index():\n

\nngx_str_t  name;  /* ngx_string(\"foo\") */\nngx_int_t  index;\n\nindex = ngx_http_get_variable_index(cf, &name);\n

\nHere, cf is a pointer to nginx configuration and\nname points to a string containing the variable name.\nThe function returns NGX_ERROR on error or a valid index\notherwise, which is typically stored somewhere in the module's\nconfiguration for future use.\n

\nAll HTTP variables are evaluated in the context of a given HTTP request,\nand results are specific to and cached in that HTTP request.\nAll functions that evaluate variables return the\nngx_http_variable_value_t type, representing\nthe variable value:\n

\ntypedef ngx_variable_value_t  ngx_http_variable_value_t;\n\ntypedef struct {\n    unsigned    len:28;\n\n    unsigned    valid:1;\n    unsigned    no_cacheable:1;\n    unsigned    not_found:1;\n    unsigned    escape:1;\n\n    u_char     *data;\n} ngx_variable_value_t;\n

\nwhere:\n

\n

\nThe ngx_http_get_flushed_variable()\nand ngx_http_get_indexed_variable() functions\nare used to obtain the value of a variable.\nThey have the same interface - accepting an HTTP request r\nas a context for evaluating the variable and an index\nthat identifies it.\nAn example of typical usage:\n

\nngx_http_variable_value_t  *v;\n\nv = ngx_http_get_flushed_variable(r, index);\n\nif (v == NULL || v->not_found) {\n    /* we failed to get value or there is no such variable, handle it */\n    return NGX_ERROR;\n}\n\n/* some meaningful value is found */\n

\nThe difference between functions is that the\nngx_http_get_indexed_variable() returns a cached value\nand ngx_http_get_flushed_variable() flushes the cache for\nnon-cacheable variables.\n

\nSome modules, such as SSI and Perl, need to deal with variables for which the\nname is not known at configuration time.\nAn index therefore cannot be used to access them, but the\nngx_http_get_variable(r, name, key) function\nis available.\nIt searches for a variable with a given\nname and its hash key derived\nfrom the name.\n

Creating variables

\nTo create a variable, use the ngx_http_add_variable()\nfunction.\nIt takes as arguments a configuration (where the variable is registered),\nthe variable name and flags that control the function's behaviour:\n\n

\n\nThe function returns NULL in case of error or a pointer to\nngx_http_variable_t otherwise:\n

\nstruct ngx_http_variable_s {\n    ngx_str_t                     name;\n    ngx_http_set_variable_pt      set_handler;\n    ngx_http_get_variable_pt      get_handler;\n    uintptr_t                     data;\n    ngx_uint_t                    flags;\n    ngx_uint_t                    index;\n};\n

\n\nThe get and set handlers\nare called to obtain or set the variable value,\ndata is passed to variable handlers, and\nindex holds assigned variable index used to reference\nthe variable.\n

\nUsually, a null-terminated static array of\nngx_http_variable_t structures is created\nby a module and processed at the preconfiguration stage to add variables\ninto the configuration, for example:\n

\nstatic ngx_http_variable_t  ngx_http_foo_vars[] = {\n\n    { ngx_string(\"foo_v1\"), NULL, ngx_http_foo_v1_variable, 0, 0, 0 },\n\n      ngx_http_null_variable\n};\n\nstatic ngx_int_t\nngx_http_foo_add_variables(ngx_conf_t *cf)\n{\n    ngx_http_variable_t  *var, *v;\n\n    for (v = ngx_http_foo_vars; v->name.len; v++) {\n        var = ngx_http_add_variable(cf, &v->name, v->flags);\n        if (var == NULL) {\n            return NGX_ERROR;\n        }\n\n        var->get_handler = v->get_handler;\n        var->data = v->data;\n    }\n\n    return NGX_OK;\n}\n

\nThis function in the example is used to initialize\nthe preconfiguration\nfield of the HTTP module context and is called before the parsing of HTTP\nconfiguration, so that the parser can refer to these variables.\n

\nThe get handler is responsible for evaluating a variable\nin the context of a specific request, for example:\n

\nstatic ngx_int_t\nngx_http_variable_connection(ngx_http_request_t *r,\n    ngx_http_variable_value_t *v, uintptr_t data)\n{\n    u_char  *p;\n\n    p = ngx_pnalloc(r->pool, NGX_ATOMIC_T_LEN);\n    if (p == NULL) {\n        return NGX_ERROR;\n    }\n\n    v->len = ngx_sprintf(p, \"%uA\", r->connection->number) - p;\n    v->valid = 1;\n    v->no_cacheable = 0;\n    v->not_found = 0;\n    v->data = p;\n\n    return NGX_OK;\n}\n

\nIt returns NGX_ERROR in case of internal error\n(for example, failed memory allocation) or NGX_OK otherwise.\nTo learn the status of variable evaluation, inspect the flags\nin ngx_http_variable_value_t (see the description\nabove).\n

\nThe set handler allows setting the property\nreferenced by the variable.\nFor example, the set handler of the $limit_rate variable\nmodifies the request's limit_rate field:\n

\n...\n{ ngx_string(\"limit_rate\"), ngx_http_variable_request_set_size,\n  ngx_http_variable_request_get_size,\n  offsetof(ngx_http_request_t, limit_rate),\n  NGX_HTTP_VAR_CHANGEABLE|NGX_HTTP_VAR_NOCACHEABLE, 0 },\n...\n\nstatic void\nngx_http_variable_request_set_size(ngx_http_request_t *r,\n    ngx_http_variable_value_t *v, uintptr_t data)\n{\n    ssize_t    s, *sp;\n    ngx_str_t  val;\n\n    val.len = v->len;\n    val.data = v->data;\n\n    s = ngx_parse_size(&val);\n\n    if (s == NGX_ERROR) {\n        ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,\n                      \"invalid size \\\"%V\\\"\", &val);\n        return;\n    }\n\n    sp = (ssize_t *) ((char *) r + data);\n\n    *sp = s;\n\n    return;\n}\n

\n\n

Complex values

\nA complex value, despite its name, provides an easy way to evaluate\nexpressions which can contain text, variables, and their combination.\n

\nThe complex value description in\nngx_http_compile_complex_value is compiled at the\nconfiguration stage into ngx_http_complex_value_t\nwhich is used at runtime to obtain results of expression evaluation.\n\n

\nngx_str_t                         *value;\nngx_http_complex_value_t           cv;\nngx_http_compile_complex_value_t   ccv;\n\nvalue = cf->args->elts; /* directive arguments */\n\nngx_memzero(&ccv, sizeof(ngx_http_compile_complex_value_t));\n\nccv.cf = cf;\nccv.value = &value[1];\nccv.complex_value = &cv;\nccv.zero = 1;\nccv.conf_prefix = 1;\n\nif (ngx_http_compile_complex_value(&ccv) != NGX_OK) {\n    return NGX_CONF_ERROR;\n}\n

\n\nHere, ccv holds all parameters that are required to\ninitialize the complex value cv:\n\n

\nThe zero flag is useful when results are to be passed to\nlibraries that require zero-terminated strings, and prefixes are handy when\ndealing with filenames.\n

\nUpon successful compilation, cv.lengths\ncontains information about the presence of variables\nin the expression.\nThe NULL value means that the expression contained static text only,\nand so can be stored in a simple string rather than as a complex value.\n

\nThe ngx_http_set_complex_value_slot() is a convenient\nfunction used to initialize a complex value completely in the directive\ndeclaration itself.\n

\nAt runtime, a complex value can be calculated using the\nngx_http_complex_value() function:\n

\nngx_str_t  res;\n\nif (ngx_http_complex_value(r, &cv, &res) != NGX_OK) {\n    return NGX_ERROR;\n}\n

\nGiven the request r and previously compiled\nvalue cv, the function evaluates the\nexpression and writes the result to res.\n

Request redirection

\nAn HTTP request is always connected to a location via the\nloc_conf field of the ngx_http_request_t\nstructure.\nThis means that at any point the location configuration of any module can be\nretrieved from the request by calling\nngx_http_get_module_loc_conf(r, module).\nRequest location can change several times during the request's lifetime.\nInitially, a default server location of the default server is assigned to a\nrequest.\nIf the request switches to a different server (chosen by the HTTP\n“Host” header or SSL SNI extension), the request switches to the\ndefault location of that server as well.\nThe next change of the location takes place at the\nNGX_HTTP_FIND_CONFIG_PHASE request phase.\nAt this phase a location is chosen by request URI among all non-named locations\nconfigured for the server.\nThe\nngx_http_rewrite_module\ncan change the request URI at the\nNGX_HTTP_REWRITE_PHASE request phase as a result of\nthe rewrite\ndirective and send the request back\nto the NGX_HTTP_FIND_CONFIG_PHASE phase for selection of a\nnew location based on the new URI.\n

\nIt is also possible to redirect a request to a new location at any point by\ncalling one of\nngx_http_internal_redirect(r, uri, args) or\nngx_http_named_location(r, name).\n

\nThe ngx_http_internal_redirect(r, uri, args) function changes\nthe request URI and returns the request to the\nNGX_HTTP_SERVER_REWRITE_PHASE phase.\nThe request proceeds with a server default location.\nLater at NGX_HTTP_FIND_CONFIG_PHASE a new location is chosen\nbased on the new request URI.\n

\nThe following example performs an internal redirect with the new request\narguments.\n

\nngx_int_t\nngx_http_foo_redirect(ngx_http_request_t *r)\n{\n    ngx_str_t  uri, args;\n\n    ngx_str_set(&uri, \"/foo\");\n    ngx_str_set(&args, \"bar=1\");\n\n    return ngx_http_internal_redirect(r, &uri, &args);\n}\n

\nThe function ngx_http_named_location(r, name) redirects\na request to a named location. The name of the location is passed as the\nargument.\nThe location is looked up among all named locations of the current\nserver, after which the requests switches to the\nNGX_HTTP_REWRITE_PHASE phase.\n

\nThe following example performs a redirect to a named location @foo.\n

\nngx_int_t\nngx_http_foo_named_redirect(ngx_http_request_t *r)\n{\n    ngx_str_t  name;\n\n    ngx_str_set(&name, \"foo\");\n\n    return ngx_http_named_location(r, &name);\n}\n

\nBoth functions - ngx_http_internal_redirect(r, uri, args)\nand ngx_http_named_location(r, name) can be called when\nnginx modules have already stored some contexts in a request's\nctx field.\nIt's possible for these contexts to become inconsistent with the new\nlocation configuration.\nTo prevent inconsistency, all request contexts are\nerased by both redirect functions.\n

\nCalling ngx_http_internal_redirect(r, uri, args)\nor ngx_http_named_location(r, name) increases the request\ncount.\nFor consistent request reference counting, call\nngx_http_finalize_request(r, NGX_DONE) after redirecting the\nrequest.\nThis will finalize current request code path and decrease the counter.\n

\nRedirected and rewritten requests become internal and can access the\ninternal\nlocations.\nInternal requests have the internal flag set.\n

Subrequests

\nSubrequests are primarily used to insert output of one request into another,\npossibly mixed with other data.\nA subrequest looks like a normal request, but shares some data with its parent.\nIn particular, all fields related to client input are shared\nbecause a subrequest does not receive any other input from the client.\nThe request field parent for a subrequest contains a link\nto its parent request and is NULL for the main request.\nThe field main contains a link to the main request in\na group of requests.\n

\nA subrequest starts in the NGX_HTTP_SERVER_REWRITE_PHASE\nphase.\nIt passes through the same subsequent phases as a normal request and is\nassigned a location based on its own URI.\n

\nThe output header in a subrequest is always ignored.\nThe ngx_http_postpone_filter places the subrequest's\noutput body in the right position relative to other data produced\nby the parent request.\n

\nSubrequests are related to the concept of active requests.\nA request r is considered active if\nc->data == r, where c is the client\nconnection object.\nAt any given point, only the active request in a request group is allowed\nto output its buffers to the client.\nAn inactive request can still send its output to the filter chain, but it\ndoes not pass beyond the ngx_http_postpone_filter and\nremains buffered by that filter until the request becomes active.\nHere are some rules of request activation:\n

\nCreate a subrequest by calling the function\nngx_http_subrequest(r, uri, args, psr, ps, flags), where\nr is the parent request, uri and\nargs are the URI and arguments of the\nsubrequest, psr is the output parameter, which receives the\nnewly created subrequest reference, ps is a callback object\nfor notifying the parent request that the subrequest is being finalized, and\nflags is bitmask of flags.\nThe following flags are available:\n

\nThe following example creates a subrequest with the URI\nof /foo.\n

\nngx_int_t            rc;\nngx_str_t            uri;\nngx_http_request_t  *sr;\n\n...\n\nngx_str_set(&uri, \"/foo\");\n\nrc = ngx_http_subrequest(r, &uri, NULL, &sr, NULL, 0);\nif (rc == NGX_ERROR) {\n    /* error */\n}\n

\nThis example clones the current request and sets a finalization callback for the\nsubrequest.\n

\nngx_int_t\nngx_http_foo_clone(ngx_http_request_t *r)\n{\n    ngx_http_request_t          *sr;\n    ngx_http_post_subrequest_t  *ps;\n\n    ps = ngx_palloc(r->pool, sizeof(ngx_http_post_subrequest_t));\n    if (ps == NULL) {\n        return NGX_ERROR;\n    }\n\n    ps->handler = ngx_http_foo_subrequest_done;\n    ps->data = \"foo\";\n\n    return ngx_http_subrequest(r, &r->uri, &r->args, &sr, ps,\n                               NGX_HTTP_SUBREQUEST_CLONE);\n}\n\n\nngx_int_t\nngx_http_foo_subrequest_done(ngx_http_request_t *r, void *data, ngx_int_t rc)\n{\n    char  *msg = (char *) data;\n\n    ngx_log_error(NGX_LOG_INFO, r->connection->log, 0,\n                  \"done subrequest r:%p msg:%s rc:%i\", r, msg, rc);\n\n    return rc;\n}\n

\nSubrequests are normally created in a body filter, in which case their output\ncan be treated like the output from any explicit request.\nThis means that eventually the output of a subrequest is sent to the client,\nafter all explicit buffers that are passed before subrequest creation and\nbefore any buffers that are passed after creation.\nThis ordering is preserved even for large hierarchies of subrequests.\nThe following example inserts output from a subrequest after all request data\nbuffers, but before the final buffer with the last_buf flag.\n

\nngx_int_t\nngx_http_foo_body_filter(ngx_http_request_t *r, ngx_chain_t *in)\n{\n    ngx_int_t                   rc;\n    ngx_buf_t                  *b;\n    ngx_uint_t                  last;\n    ngx_chain_t                *cl, out;\n    ngx_http_request_t         *sr;\n    ngx_http_foo_filter_ctx_t  *ctx;\n\n    ctx = ngx_http_get_module_ctx(r, ngx_http_foo_filter_module);\n    if (ctx == NULL) {\n        return ngx_http_next_body_filter(r, in);\n    }\n\n    last = 0;\n\n    for (cl = in; cl; cl = cl->next) {\n        if (cl->buf->last_buf) {\n            cl->buf->last_buf = 0;\n            cl->buf->last_in_chain = 1;\n            cl->buf->sync = 1;\n            last = 1;\n        }\n    }\n\n    /* Output explicit output buffers */\n\n    rc = ngx_http_next_body_filter(r, in);\n\n    if (rc == NGX_ERROR || !last) {\n        return rc;\n    }\n\n    /*\n     * Create the subrequest.  The output of the subrequest\n     * will automatically be sent after all preceding buffers,\n     * but before the last_buf buffer passed later in this function.\n     */\n\n    if (ngx_http_subrequest(r, ctx->uri, NULL, &sr, NULL, 0) != NGX_OK) {\n        return NGX_ERROR;\n    }\n\n    ngx_http_set_ctx(r, NULL, ngx_http_foo_filter_module);\n\n    /* Output the final buffer with the last_buf flag */\n\n    b = ngx_calloc_buf(r->pool);\n    if (b == NULL) {\n        return NGX_ERROR;\n    }\n\n    b->last_buf = 1;\n\n    out.buf = b;\n    out.next = NULL;\n\n    return ngx_http_output_filter(r, &out);\n}\n

\nA subrequest can also be created for other purposes than data output.\nFor example, the \nngx_http_auth_request_module module\ncreates a subrequest at the NGX_HTTP_ACCESS_PHASE phase.\nTo disable output at this point, the\nheader_only flag is set on the subrequest.\nThis prevents the subrequest body from being sent to the client.\nNote that the subrequest's header is never sent to the client.\nThe result of the subrequest can be analyzed in the callback handler.\n

Request finalization

\nAn HTTP request is finalized by calling the function\nngx_http_finalize_request(r, rc).\nIt is usually finalized by the content handler after all output buffers\nare sent to the filter chain.\nAt this point all of the output might not be sent to the client,\nwith some of it remaining buffered somewhere along the filter chain.\nIf it is, the ngx_http_finalize_request(r, rc) function\nautomatically installs a special handler ngx_http_writer(r)\nto finish sending the output.\nA request is also finalized in case of an error or if a standard HTTP response\ncode needs to be returned to the client.\n

\nThe function ngx_http_finalize_request(r, rc) expects the\nfollowing rc values:\n

Request body

\nFor dealing with the body of a client request, nginx provides the\nngx_http_read_client_request_body(r, post_handler) and\nngx_http_discard_request_body(r) functions.\nThe first function reads the request body and makes it available via the\nrequest_body request field.\nThe second function instructs nginx to discard (read and ignore) the request\nbody.\nOne of these functions must be called for every request.\nNormally, the content handler makes the call.\n

\nReading or discarding the client request body from a subrequest is not allowed.\nIt must always be done in the main request.\nWhen a subrequest is created, it inherits the parent's\nrequest_body object which can be used by the subrequest if\nthe main request has previously read the request body.\n

\nThe function\nngx_http_read_client_request_body(r, post_handler) starts\nthe process of reading the request body.\nWhen the body is completely read, the post_handler callback\nis called to continue processing the request.\nIf the request body is missing or has already been read, the callback is called\nimmediately.\nIn unbuffered mode, the callback can be called before the whole body is read.\nThe function\nngx_http_read_client_request_body(r, post_handler)\nallocates the request_body request field of type\nngx_http_request_body_t.\nThe field bufs of this object keeps the result as a buffer\nchain.\nThe body can be saved in memory buffers or file buffers, if the capacity\nspecified by the\nclient_body_buffer_size\ndirective is not enough to fit the entire body in memory.\n

\nThe following example reads a client request body and returns its size.\n

\nngx_int_t\nngx_http_foo_content_handler(ngx_http_request_t *r)\n{\n    ngx_int_t  rc;\n\n    rc = ngx_http_read_client_request_body(r, ngx_http_foo_init);\n\n    if (rc >= NGX_HTTP_SPECIAL_RESPONSE) {\n        /* error */\n        return rc;\n    }\n\n    return NGX_DONE;\n}\n\n\nvoid\nngx_http_foo_init(ngx_http_request_t *r)\n{\n    off_t         len;\n    ngx_buf_t    *b;\n    ngx_int_t     rc;\n    ngx_chain_t  *in, out;\n\n    if (r->request_body == NULL) {\n        ngx_http_finalize_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR);\n        return;\n    }\n\n    len = 0;\n\n    for (in = r->request_body->bufs; in; in = in->next) {\n        len += ngx_buf_size(in->buf);\n    }\n\n    b = ngx_create_temp_buf(r->pool, NGX_OFF_T_LEN);\n    if (b == NULL) {\n        ngx_http_finalize_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR);\n        return;\n    }\n\n    b->last = ngx_sprintf(b->pos, \"%O\", len);\n    b->last_buf = (r == r->main) ? 1 : 0;\n    b->last_in_chain = 1;\n\n    r->headers_out.status = NGX_HTTP_OK;\n    r->headers_out.content_length_n = b->last - b->pos;\n\n    rc = ngx_http_send_header(r);\n\n    if (rc == NGX_ERROR || rc > NGX_OK || r->header_only) {\n        ngx_http_finalize_request(r, rc);\n        return;\n    }\n\n    out.buf = b;\n    out.next = NULL;\n\n    rc = ngx_http_output_filter(r, &out);\n\n    ngx_http_finalize_request(r, rc);\n}\n

\nThe following fields of the request determine how the request body is read:\n

\nThe request_body_no_buffering flag enables the\nunbuffered mode of reading a request body.\nIn this mode, after calling\nngx_http_read_client_request_body(), the\nbufs chain might keep only a part of the body.\nThe request flag reading_body indicates that the request body\nreading is still in progress.\nTo read the next part, call the\nngx_http_read_unbuffered_request_body(r) function.\nThe return value NGX_AGAIN indicates that more body data\nor buffer space is needed.\nIf bufs is NULL after calling this function, no body data is\navailable at the moment.\nThe request callback read_event_handler will be called when\nmore client body data is available.\n

Request body filters

\nAfter a request body part is read, it's passed to the request\nbody filter chain by calling the first body filter handler stored in\nthe ngx_http_top_request_body_filter variable.\nIt's assumed that every body handler calls the next handler in the chain until\nthe final handler ngx_http_request_body_save_filter(r, cl)\nis called.\nThis handler collects the buffers in\nr->request_body->bufs\nand writes them to a file if necessary.\nThe last request body buffer has nonzero last_buf flag.\n

\nIf a filter is planning to delay data buffers, it should set the flag\nr->request_body->filter_need_buffering to\n1 when called for the first time.\n

\nFollowing is an example of a simple request body filter that delays request\nbody by one second.\n

\n#include <ngx_config.h>\n#include <ngx_core.h>\n#include <ngx_http.h>\n\n\n#define NGX_HTTP_DELAY_BODY  1000\n\n\ntypedef struct {\n    ngx_event_t   event;\n    ngx_chain_t  *out;\n} ngx_http_delay_body_ctx_t;\n\n\nstatic ngx_int_t ngx_http_delay_body_filter(ngx_http_request_t *r,\n    ngx_chain_t *in);\nstatic void ngx_http_delay_body_cleanup(void *data);\nstatic void ngx_http_delay_body_event_handler(ngx_event_t *ev);\nstatic ngx_int_t ngx_http_delay_body_init(ngx_conf_t *cf);\n\n\nstatic ngx_http_module_t  ngx_http_delay_body_module_ctx = {\n    NULL,                          /* preconfiguration */\n    ngx_http_delay_body_init,      /* postconfiguration */\n\n    NULL,                          /* create main configuration */\n    NULL,                          /* init main configuration */\n\n    NULL,                          /* create server configuration */\n    NULL,                          /* merge server configuration */\n\n    NULL,                          /* create location configuration */\n    NULL                           /* merge location configuration */\n};\n\n\nngx_module_t  ngx_http_delay_body_filter_module = {\n    NGX_MODULE_V1,\n    &ngx_http_delay_body_module_ctx, /* module context */\n    NULL,                          /* module directives */\n    NGX_HTTP_MODULE,               /* module type */\n    NULL,                          /* init master */\n    NULL,                          /* init module */\n    NULL,                          /* init process */\n    NULL,                          /* init thread */\n    NULL,                          /* exit thread */\n    NULL,                          /* exit process */\n    NULL,                          /* exit master */\n    NGX_MODULE_V1_PADDING\n};\n\n\nstatic ngx_http_request_body_filter_pt   ngx_http_next_request_body_filter;\n\n\nstatic ngx_int_t\nngx_http_delay_body_filter(ngx_http_request_t *r, ngx_chain_t *in)\n{\n    ngx_int_t                   rc;\n    ngx_chain_t                *cl, *ln;\n    ngx_http_cleanup_t         *cln;\n    ngx_http_delay_body_ctx_t  *ctx;\n\n    ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,\n                   \"delay request body filter\");\n\n    ctx = ngx_http_get_module_ctx(r, ngx_http_delay_body_filter_module);\n\n    if (ctx == NULL) {\n        ctx = ngx_pcalloc(r->pool, sizeof(ngx_http_delay_body_ctx_t));\n        if (ctx == NULL) {\n            return NGX_HTTP_INTERNAL_SERVER_ERROR;\n        }\n\n        ngx_http_set_ctx(r, ctx, ngx_http_delay_body_filter_module);\n\n        r->request_body->filter_need_buffering = 1;\n    }\n\n    if (ngx_chain_add_copy(r->pool, &ctx->out, in) != NGX_OK) {\n        return NGX_HTTP_INTERNAL_SERVER_ERROR;\n    }\n\n    if (!ctx->event.timedout) {\n        if (!ctx->event.timer_set) {\n\n            /* cleanup to remove the timer in case of abnormal termination */\n\n            cln = ngx_http_cleanup_add(r, 0);\n            if (cln == NULL) {\n                return NGX_HTTP_INTERNAL_SERVER_ERROR;\n            }\n\n            cln->handler = ngx_http_delay_body_cleanup;\n            cln->data = ctx;\n\n            /* add timer */\n\n            ctx->event.handler = ngx_http_delay_body_event_handler;\n            ctx->event.data = r;\n            ctx->event.log = r->connection->log;\n\n            ngx_add_timer(&ctx->event, NGX_HTTP_DELAY_BODY);\n        }\n\n        return ngx_http_next_request_body_filter(r, NULL);\n    }\n\n    rc = ngx_http_next_request_body_filter(r, ctx->out);\n\n    for (cl = ctx->out; cl; /* void */) {\n        ln = cl;\n        cl = cl->next;\n        ngx_free_chain(r->pool, ln);\n    }\n\n    ctx->out = NULL;\n\n    return rc;\n}\n\n\nstatic void\nngx_http_delay_body_cleanup(void *data)\n{\n    ngx_http_delay_body_ctx_t *ctx = data;\n\n    if (ctx->event.timer_set) {\n        ngx_del_timer(&ctx->event);\n    }\n}\n\n\nstatic void\nngx_http_delay_body_event_handler(ngx_event_t *ev)\n{\n    ngx_connection_t    *c;\n    ngx_http_request_t  *r;\n\n    r = ev->data;\n    c = r->connection;\n\n    ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0,\n                   \"delay request body event\");\n\n    ngx_post_event(c->read, &ngx_posted_events);\n}\n\n\nstatic ngx_int_t\nngx_http_delay_body_init(ngx_conf_t *cf)\n{\n    ngx_http_next_request_body_filter = ngx_http_top_request_body_filter;\n    ngx_http_top_request_body_filter = ngx_http_delay_body_filter;\n\n    return NGX_OK;\n}\n

Response

\nIn nginx an HTTP response is produced by sending the response header followed by\nthe optional response body.\nBoth header and body are passed through a chain of filters and eventually get\nwritten to the client socket.\nAn nginx module can install its handler into the header or body filter chain\nand process the output coming from the previous handler.\n

Response header

\nThe ngx_http_send_header(r)\nfunction sends the output header.\nDo not call this function until r->headers_out\ncontains all of the data required to produce the HTTP response header.\nThe status field in r->headers_out\nmust always be set.\nIf the response status indicates that a response body follows the header,\ncontent_length_n can be set as well.\nThe default value for this field is -1,\nwhich means that the body size is unknown.\nIn this case, chunked transfer encoding is used.\nTo output an arbitrary header, append the headers list.\n

\nstatic ngx_int_t\nngx_http_foo_content_handler(ngx_http_request_t *r)\n{\n    ngx_int_t         rc;\n    ngx_table_elt_t  *h;\n\n    /* send header */\n\n    r->headers_out.status = NGX_HTTP_OK;\n    r->headers_out.content_length_n = 3;\n\n    /* X-Foo: foo */\n\n    h = ngx_list_push(&r->headers_out.headers);\n    if (h == NULL) {\n        return NGX_ERROR;\n    }\n\n    h->hash = 1;\n    ngx_str_set(&h->key, \"X-Foo\");\n    ngx_str_set(&h->value, \"foo\");\n\n    rc = ngx_http_send_header(r);\n\n    if (rc == NGX_ERROR || rc > NGX_OK || r->header_only) {\n        return rc;\n    }\n\n    /* send body */\n\n    ...\n}\n

Header filters

\nThe ngx_http_send_header(r) function invokes the header\nfilter chain by calling the first header filter handler stored in\nthe ngx_http_top_header_filter variable.\nIt's assumed that every header handler calls the next handler in the chain\nuntil the final handler ngx_http_header_filter(r) is called.\nThe final header handler constructs the HTTP response based on\nr->headers_out and passes it to the\nngx_http_writer_filter for output.\n

\nTo add a handler to the header filter chain, store its address in\nthe global variable ngx_http_top_header_filter\nat configuration time.\nThe previous handler address is normally stored in a static variable in a module\nand is called by the newly added handler before exiting.\n

\nThe following example of a header filter module adds the HTTP header\n\"X-Foo: foo\" to every response with status\n200.\n

\n#include <ngx_config.h>\n#include <ngx_core.h>\n#include <ngx_http.h>\n\n\nstatic ngx_int_t ngx_http_foo_header_filter(ngx_http_request_t *r);\nstatic ngx_int_t ngx_http_foo_header_filter_init(ngx_conf_t *cf);\n\n\nstatic ngx_http_module_t  ngx_http_foo_header_filter_module_ctx = {\n    NULL,                                   /* preconfiguration */\n    ngx_http_foo_header_filter_init,        /* postconfiguration */\n\n    NULL,                                   /* create main configuration */\n    NULL,                                   /* init main configuration */\n\n    NULL,                                   /* create server configuration */\n    NULL,                                   /* merge server configuration */\n\n    NULL,                                   /* create location configuration */\n    NULL                                    /* merge location configuration */\n};\n\n\nngx_module_t  ngx_http_foo_header_filter_module = {\n    NGX_MODULE_V1,\n    &ngx_http_foo_header_filter_module_ctx, /* module context */\n    NULL,                                   /* module directives */\n    NGX_HTTP_MODULE,                        /* module type */\n    NULL,                                   /* init master */\n    NULL,                                   /* init module */\n    NULL,                                   /* init process */\n    NULL,                                   /* init thread */\n    NULL,                                   /* exit thread */\n    NULL,                                   /* exit process */\n    NULL,                                   /* exit master */\n    NGX_MODULE_V1_PADDING\n};\n\n\nstatic ngx_http_output_header_filter_pt  ngx_http_next_header_filter;\n\n\nstatic ngx_int_t\nngx_http_foo_header_filter(ngx_http_request_t *r)\n{\n    ngx_table_elt_t  *h;\n\n    /*\n     * The filter handler adds \"X-Foo: foo\" header\n     * to every HTTP 200 response\n     */\n\n    if (r->headers_out.status != NGX_HTTP_OK) {\n        return ngx_http_next_header_filter(r);\n    }\n\n    h = ngx_list_push(&r->headers_out.headers);\n    if (h == NULL) {\n        return NGX_ERROR;\n    }\n\n    h->hash = 1;\n    ngx_str_set(&h->key, \"X-Foo\");\n    ngx_str_set(&h->value, \"foo\");\n\n    return ngx_http_next_header_filter(r);\n}\n\n\nstatic ngx_int_t\nngx_http_foo_header_filter_init(ngx_conf_t *cf)\n{\n    ngx_http_next_header_filter = ngx_http_top_header_filter;\n    ngx_http_top_header_filter = ngx_http_foo_header_filter;\n\n    return NGX_OK;\n}\n

Response body

\nTo send the response body, call the\nngx_http_output_filter(r, cl) function.\nThe function can be called multiple times.\nEach time, it sends a part of the response body in the form of a buffer chain.\nSet the last_buf flag in the last body buffer.\n

\nThe following example produces a complete HTTP response with \"foo\" as its body.\nFor the example to work as subrequest as well as a main request,\nthe last_in_chain flag is set in the last buffer\nof the output.\nThe last_buf flag is set only for the main request because\nthe last buffer for a subrequest does not end the entire output.\n

\nstatic ngx_int_t\nngx_http_bar_content_handler(ngx_http_request_t *r)\n{\n    ngx_int_t     rc;\n    ngx_buf_t    *b;\n    ngx_chain_t   out;\n\n    /* send header */\n\n    r->headers_out.status = NGX_HTTP_OK;\n    r->headers_out.content_length_n = 3;\n\n    rc = ngx_http_send_header(r);\n\n    if (rc == NGX_ERROR || rc > NGX_OK || r->header_only) {\n        return rc;\n    }\n\n    /* send body */\n\n    b = ngx_calloc_buf(r->pool);\n    if (b == NULL) {\n        return NGX_ERROR;\n    }\n\n    b->last_buf = (r == r->main) ? 1 : 0;\n    b->last_in_chain = 1;\n\n    b->memory = 1;\n\n    b->pos = (u_char *) \"foo\";\n    b->last = b->pos + 3;\n\n    out.buf = b;\n    out.next = NULL;\n\n    return ngx_http_output_filter(r, &out);\n}\n

Response body filters

\nThe function ngx_http_output_filter(r, cl) invokes the\nbody filter chain by calling the first body filter handler stored in\nthe ngx_http_top_body_filter variable.\nIt's assumed that every body handler calls the next handler in the chain until\nthe final handler ngx_http_write_filter(r, cl) is called.\n

\nA body filter handler receives a chain of buffers.\nThe handler is supposed to process the buffers and pass a possibly new chain to\nthe next handler.\nIt's worth noting that the chain links ngx_chain_t of the\nincoming chain belong to the caller, and must not be reused or changed.\nRight after the handler completes, the caller can use its output chain links\nto keep track of the buffers it has sent.\nTo save the buffer chain or to substitute some buffers before passing to the\nnext filter, a handler needs to allocate its own chain links.\n

\nFollowing is an example of a simple body filter that counts the number of\nbytes in the body.\nThe result is available as the $counter variable which can be\nused in the access log.\n

\n#include <ngx_config.h>\n#include <ngx_core.h>\n#include <ngx_http.h>\n\n\ntypedef struct {\n    off_t  count;\n} ngx_http_counter_filter_ctx_t;\n\n\nstatic ngx_int_t ngx_http_counter_body_filter(ngx_http_request_t *r,\n    ngx_chain_t *in);\nstatic ngx_int_t ngx_http_counter_variable(ngx_http_request_t *r,\n    ngx_http_variable_value_t *v, uintptr_t data);\nstatic ngx_int_t ngx_http_counter_add_variables(ngx_conf_t *cf);\nstatic ngx_int_t ngx_http_counter_filter_init(ngx_conf_t *cf);\n\n\nstatic ngx_http_module_t  ngx_http_counter_filter_module_ctx = {\n    ngx_http_counter_add_variables,        /* preconfiguration */\n    ngx_http_counter_filter_init,          /* postconfiguration */\n\n    NULL,                                  /* create main configuration */\n    NULL,                                  /* init main configuration */\n\n    NULL,                                  /* create server configuration */\n    NULL,                                  /* merge server configuration */\n\n    NULL,                                  /* create location configuration */\n    NULL                                   /* merge location configuration */\n};\n\n\nngx_module_t  ngx_http_counter_filter_module = {\n    NGX_MODULE_V1,\n    &ngx_http_counter_filter_module_ctx,   /* module context */\n    NULL,                                  /* module directives */\n    NGX_HTTP_MODULE,                       /* module type */\n    NULL,                                  /* init master */\n    NULL,                                  /* init module */\n    NULL,                                  /* init process */\n    NULL,                                  /* init thread */\n    NULL,                                  /* exit thread */\n    NULL,                                  /* exit process */\n    NULL,                                  /* exit master */\n    NGX_MODULE_V1_PADDING\n};\n\n\nstatic ngx_http_output_body_filter_pt  ngx_http_next_body_filter;\n\nstatic ngx_str_t  ngx_http_counter_name = ngx_string(\"counter\");\n\n\nstatic ngx_int_t\nngx_http_counter_body_filter(ngx_http_request_t *r, ngx_chain_t *in)\n{\n    ngx_chain_t                    *cl;\n    ngx_http_counter_filter_ctx_t  *ctx;\n\n    ctx = ngx_http_get_module_ctx(r, ngx_http_counter_filter_module);\n    if (ctx == NULL) {\n        ctx = ngx_pcalloc(r->pool, sizeof(ngx_http_counter_filter_ctx_t));\n        if (ctx == NULL) {\n            return NGX_ERROR;\n        }\n\n        ngx_http_set_ctx(r, ctx, ngx_http_counter_filter_module);\n    }\n\n    for (cl = in; cl; cl = cl->next) {\n        ctx->count += ngx_buf_size(cl->buf);\n    }\n\n    return ngx_http_next_body_filter(r, in);\n}\n\n\nstatic ngx_int_t\nngx_http_counter_variable(ngx_http_request_t *r, ngx_http_variable_value_t *v,\n    uintptr_t data)\n{\n    u_char                         *p;\n    ngx_http_counter_filter_ctx_t  *ctx;\n\n    ctx = ngx_http_get_module_ctx(r, ngx_http_counter_filter_module);\n    if (ctx == NULL) {\n        v->not_found = 1;\n        return NGX_OK;\n    }\n\n    p = ngx_pnalloc(r->pool, NGX_OFF_T_LEN);\n    if (p == NULL) {\n        return NGX_ERROR;\n    }\n\n    v->data = p;\n    v->len = ngx_sprintf(p, \"%O\", ctx->count) - p;\n    v->valid = 1;\n    v->no_cacheable = 0;\n    v->not_found = 0;\n\n    return NGX_OK;\n}\n\n\nstatic ngx_int_t\nngx_http_counter_add_variables(ngx_conf_t *cf)\n{\n    ngx_http_variable_t  *var;\n\n    var = ngx_http_add_variable(cf, &ngx_http_counter_name, 0);\n    if (var == NULL) {\n        return NGX_ERROR;\n    }\n\n    var->get_handler = ngx_http_counter_variable;\n\n    return NGX_OK;\n}\n\n\nstatic ngx_int_t\nngx_http_counter_filter_init(ngx_conf_t *cf)\n{\n    ngx_http_next_body_filter = ngx_http_top_body_filter;\n    ngx_http_top_body_filter = ngx_http_counter_body_filter;\n\n    return NGX_OK;\n}\n

Building filter modules

\nWhen writing a body or header filter, pay special attention to the filter's\nposition in the filter order.\nThere's a number of header and body filters registered by nginx standard\nmodules.\nThe nginx standard modules register a number of head and body filters and it's\nimportant to register a new filter module in the right place with respect to\nthem.\nNormally, modules register filters in their postconfiguration handlers.\nThe order in which filters are called during processing is obviously the\nreverse of the order in which they are registered.\n

\nFor third-party filter modules nginx provides a special slot\nHTTP_AUX_FILTER_MODULES.\nTo register a filter module in this slot, set\nthe ngx_module_type variable to\nHTTP_AUX_FILTER in the module's configuration.\n

\nThe following example shows a filter module config file assuming\nfor a module with just\none source file, ngx_http_foo_filter_module.c.\n

\nngx_module_type=HTTP_AUX_FILTER\nngx_module_name=ngx_http_foo_filter_module\nngx_module_srcs=\"$ngx_addon_dir/ngx_http_foo_filter_module.c\"\n\n. auto/module\n

Buffer reuse

\nWhen issuing or altering a stream of buffers, it's often desirable to reuse the\nallocated buffers.\nA standard and widely adopted approach in nginx code is to keep\ntwo buffer chains for this purpose:\nfree and busy.\nThe free chain keeps all free buffers,\nwhich can be reused.\nThe busy chain keeps all buffers sent by the current\nmodule that are still in use by some other filter handler.\nA buffer is considered in use if its size is greater than zero.\nNormally, when a buffer is consumed by a filter, its pos\n(or file_pos for a file buffer) is moved towards\nlast (file_last for a file buffer).\nOnce a buffer is completely consumed, it's ready to be reused.\nTo add newly freed buffers to the free chain\nit's enough to iterate over the busy chain and move the zero\nsize buffers at the head of it to free.\nThis operation is so common that there is a special function for it,\nngx_chain_update_chains(free, busy, out, tag).\nThe function appends the output chain out to\nbusy and moves free buffers from the top of\nbusy to free.\nOnly the buffers with the specified tag are reused.\nThis lets a module reuse only the buffers that it allocated itself.\n

\nThe following example is a body filter that inserts the string “foo” before each\nincoming buffer.\nThe new buffers allocated by the module are reused if possible.\nNote that for this example to work properly, setting up a\nheader filter\nand resetting content_length_n to -1\nis also required, but the relevant code is not provided here.\n

\ntypedef struct {\n    ngx_chain_t  *free;\n    ngx_chain_t  *busy;\n}  ngx_http_foo_filter_ctx_t;\n\n\nngx_int_t\nngx_http_foo_body_filter(ngx_http_request_t *r, ngx_chain_t *in)\n{\n    ngx_int_t                   rc;\n    ngx_buf_t                  *b;\n    ngx_chain_t                *cl, *tl, *out, **ll;\n    ngx_http_foo_filter_ctx_t  *ctx;\n\n    ctx = ngx_http_get_module_ctx(r, ngx_http_foo_filter_module);\n    if (ctx == NULL) {\n        ctx = ngx_pcalloc(r->pool, sizeof(ngx_http_foo_filter_ctx_t));\n        if (ctx == NULL) {\n            return NGX_ERROR;\n        }\n\n        ngx_http_set_ctx(r, ctx, ngx_http_foo_filter_module);\n    }\n\n    /* create a new chain \"out\" from \"in\" with all the changes */\n\n    ll = &out;\n\n    for (cl = in; cl; cl = cl->next) {\n\n        /* append \"foo\" in a reused buffer if possible */\n\n        tl = ngx_chain_get_free_buf(r->pool, &ctx->free);\n        if (tl == NULL) {\n            return NGX_ERROR;\n        }\n\n        b = tl->buf;\n        b->tag = (ngx_buf_tag_t) &ngx_http_foo_filter_module;\n        b->memory = 1;\n        b->pos = (u_char *) \"foo\";\n        b->last = b->pos + 3;\n\n        *ll = tl;\n        ll = &tl->next;\n\n        /* append the next incoming buffer */\n\n        tl = ngx_alloc_chain_link(r->pool);\n        if (tl == NULL) {\n            return NGX_ERROR;\n        }\n\n        tl->buf = cl->buf;\n        *ll = tl;\n        ll = &tl->next;\n    }\n\n    *ll = NULL;\n\n    /* send the new chain */\n\n    rc = ngx_http_next_body_filter(r, out);\n\n    /* update \"busy\" and \"free\" chains for reuse */\n\n    ngx_chain_update_chains(r->pool, &ctx->free, &ctx->busy, &out,\n                            (ngx_buf_tag_t) &ngx_http_foo_filter_module);\n\n    return rc;\n}\n

Load balancing

\nThe\nngx_http_upstream_module\nprovides the basic functionality needed to pass requests to remote servers.\nModules that implement specific protocols, such as HTTP or FastCGI, use\nthis functionality.\nThe module also provides an interface for creating custom\nload-balancing modules and implements a default round-robin method.\n

\nThe least_conn\nand hash\nmodules implement alternative load-balancing methods, but\nare actually implemented as extensions of the upstream round-robin\nmodule and share a lot of code with it, such as the representation\nof a server group.\nThe keepalive module\nis an independent module that extends upstream functionality.\n

\nThe\nngx_http_upstream_module\ncan be configured explicitly by placing the corresponding\nupstream block into\nthe configuration file, or implicitly by using directives\nsuch as proxy_pass\nthat accept a URL that gets evaluated at some point into a list of servers.\nThe alternative load-balancing methods are available only with an explicit\nupstream configuration.\nThe upstream module configuration has its own directive context\nNGX_HTTP_UPS_CONF.\nThe structure is defined as follows:\n

\nstruct ngx_http_upstream_srv_conf_s {\n    ngx_http_upstream_peer_t         peer;\n    void                           **srv_conf;\n\n    ngx_array_t                     *servers;  /* ngx_http_upstream_server_t */\n\n    ngx_uint_t                       flags;\n    ngx_str_t                        host;\n    u_char                          *file_name;\n    ngx_uint_t                       line;\n    in_port_t                        port;\n    ngx_uint_t                       no_port;  /* unsigned no_port:1 */\n\n#if (NGX_HTTP_UPSTREAM_ZONE)\n    ngx_shm_zone_t                  *shm_zone;\n#endif\n};\n

\n\n

\n

\nWhen nginx has to pass a request to another host for processing, it uses\nthe configured load-balancing method to obtain an address to connect to.\nThe method is obtained from the\nngx_http_upstream_t.peer object\nof type ngx_peer_connection_t:\n

\nstruct ngx_peer_connection_s {\n    ...\n\n    struct sockaddr                 *sockaddr;\n    socklen_t                        socklen;\n    ngx_str_t                       *name;\n\n    ngx_uint_t                       tries;\n\n    ngx_event_get_peer_pt            get;\n    ngx_event_free_peer_pt           free;\n    ngx_event_notify_peer_pt         notify;\n    void                            *data;\n\n#if (NGX_SSL || NGX_COMPAT)\n    ngx_event_set_peer_session_pt    set_session;\n    ngx_event_save_peer_session_pt   save_session;\n#endif\n\n    ...\n};\n

\n\nThe structure has the following fields:\n\n

\n\n

\nAll methods accept at least two arguments: a peer connection object\npc and the data created by\nngx_http_upstream_srv_conf_t.peer.init().\nNote that it might differ from pc.data due\nto “chaining” of load-balancing modules.\n

\n\n

\n\n

Examples

\nThe\nnginx-dev-examples\nrepository provides nginx module examples.\n\n

Code style

General rules

\n

\n\n

\nsize_t\nngx_utf8_length(u_char *p, size_t n)\n{\n    u_char  c, *last;\n    size_t  len;\n\n    last = p + n;\n\n    for (len = 0; p < last; len++) {\n\n        c = *p;\n\n        if (c < 0x80) {\n            p++;\n            continue;\n        }\n\n        if (ngx_utf8_decode(&p, last - p) > 0x10ffff) {\n            /* invalid UTF-8 */\n            return n;\n        }\n    }\n\n    return len;\n}\n

\n\n

Files

\nA typical source file may contain the following sections separated by\ntwo empty lines:\n\n

\n

\nCopyright statements look like this:\n

\n/*\n * Copyright (C) Author Name\n * Copyright (C) Organization, Inc.\n */\n

\nIf the file is modified significantly, the list of authors should be updated,\nthe new author is added to the top.\n

\nThe ngx_config.h and ngx_core.h files\nare always included first, followed by one of\nngx_http.h, ngx_stream.h,\nor ngx_mail.h.\nThen follow optional external header files:\n

\n#include <ngx_config.h>\n#include <ngx_core.h>\n#include <ngx_http.h>\n\n#include <libxml/parser.h>\n#include <libxml/tree.h>\n#include <libxslt/xslt.h>\n\n#if (NGX_HAVE_EXSLT)\n#include <libexslt/exslt.h>\n#endif\n

\n\n

\nHeader files should include the so called \"header protection\":\n

\n#ifndef _NGX_PROCESS_CYCLE_H_INCLUDED_\n#define _NGX_PROCESS_CYCLE_H_INCLUDED_\n...\n#endif /* _NGX_PROCESS_CYCLE_H_INCLUDED_ */\n

\n

Comments

\n

\n

Preprocessor

\nMacro names start from ngx_ or NGX_\n(or more specific) prefix.\nMacro names for constants are uppercase.\nParameterized macros and macros for initializers are lowercase.\nThe macro name and value are separated by at least two spaces:\n

\n#define NGX_CONF_BUFFER  4096\n\n#define ngx_buf_in_memory(b)  (b->temporary || b->memory || b->mmap)\n\n#define ngx_buf_size(b)                                                      \\\n    (ngx_buf_in_memory(b) ? (off_t) (b->last - b->pos):                      \\\n                            (b->file_last - b->file_pos))\n\n#define ngx_null_string  { 0, NULL }\n

\nConditions are inside parentheses, negation is outside:\n

\n#if (NGX_HAVE_KQUEUE)\n...\n#elif ((NGX_HAVE_DEVPOLL && !(NGX_TEST_BUILD_DEVPOLL)) \\\n       || (NGX_HAVE_EVENTPORT && !(NGX_TEST_BUILD_EVENTPORT)))\n...\n#elif (NGX_HAVE_EPOLL && !(NGX_TEST_BUILD_EPOLL))\n...\n#elif (NGX_HAVE_POLL)\n...\n#else /* select */\n...\n#endif /* NGX_HAVE_KQUEUE */\n

\n

Types

\nType names end with the “_t” suffix.\nA defined type name is separated by at least two spaces:\n

\ntypedef ngx_uint_t  ngx_rbtree_key_t;\n

\n

\nStructure types are defined using typedef.\nInside structures, member types and names are aligned:\n

\ntypedef struct {\n    size_t      len;\n    u_char     *data;\n} ngx_str_t;\n

\nKeep alignment identical among different structures in the file.\nA structure that points to itself has the name, ending with\n“_s”.\nAdjacent structure definitions are separated with two empty lines:\n

\ntypedef struct ngx_list_part_s  ngx_list_part_t;\n\nstruct ngx_list_part_s {\n    void             *elts;\n    ngx_uint_t        nelts;\n    ngx_list_part_t  *next;\n};\n\n\ntypedef struct {\n    ngx_list_part_t  *last;\n    ngx_list_part_t   part;\n    size_t            size;\n    ngx_uint_t        nalloc;\n    ngx_pool_t       *pool;\n} ngx_list_t;\n

\nEach structure member is declared on its own line:\n

\ntypedef struct {\n    ngx_uint_t        hash;\n    ngx_str_t         key;\n    ngx_str_t         value;\n    u_char           *lowcase_key;\n} ngx_table_elt_t;\n

\n

\nFunction pointers inside structures have defined types ending\nwith “_pt”:\n

\ntypedef ssize_t (*ngx_recv_pt)(ngx_connection_t *c, u_char *buf, size_t size);\ntypedef ssize_t (*ngx_recv_chain_pt)(ngx_connection_t *c, ngx_chain_t *in,\n    off_t limit);\ntypedef ssize_t (*ngx_send_pt)(ngx_connection_t *c, u_char *buf, size_t size);\ntypedef ngx_chain_t *(*ngx_send_chain_pt)(ngx_connection_t *c, ngx_chain_t *in,\n    off_t limit);\n\ntypedef struct {\n    ngx_recv_pt        recv;\n    ngx_recv_chain_pt  recv_chain;\n    ngx_recv_pt        udp_recv;\n    ngx_send_pt        send;\n    ngx_send_pt        udp_send;\n    ngx_send_chain_pt  udp_send_chain;\n    ngx_send_chain_pt  send_chain;\n    ngx_uint_t         flags;\n} ngx_os_io_t;\n

\n

\nEnumerations have types ending with “_e”:\n

\ntypedef enum {\n    ngx_http_fastcgi_st_version = 0,\n    ngx_http_fastcgi_st_type,\n    ...\n    ngx_http_fastcgi_st_padding\n} ngx_http_fastcgi_state_e;\n

\n

Variables

\nVariables are declared sorted by length of a base type, then alphabetically.\nType names and variable names are aligned.\nThe type and name “columns” are separated with two spaces.\nLarge arrays are put at the end of a declaration block:\n

\nu_char                      |  | *rv, *p;\nngx_conf_t                  |  | *cf;\nngx_uint_t                  |  |  i, j, k;\nunsigned int                |  |  len;\nstruct sockaddr             |  | *sa;\nconst unsigned char         |  | *data;\nngx_peer_connection_t       |  | *pc;\nngx_http_core_srv_conf_t    |  |**cscfp;\nngx_http_upstream_srv_conf_t|  | *us, *uscf;\nu_char                      |  |  text[NGX_SOCKADDR_STRLEN];\n

\n

\nStatic and global variables may be initialized on declaration:\n

\nstatic ngx_str_t  ngx_http_memcached_key = ngx_string(\"memcached_key\");\n

\n\n

\nstatic ngx_uint_t  mday[] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };\n

\n\n

\nstatic uint32_t  ngx_crc32_table16[] = {\n    0x00000000, 0x1db71064, 0x3b6e20c8, 0x26d930ac,\n    ...\n    0x9b64c2b0, 0x86d3d2d4, 0xa00ae278, 0xbdbdf21c\n};\n

\n

\nThere is a bunch of commonly used type/name combinations:\n

\nu_char                        *rv;\nngx_int_t                      rc;\nngx_conf_t                    *cf;\nngx_connection_t              *c;\nngx_http_request_t            *r;\nngx_peer_connection_t         *pc;\nngx_http_upstream_srv_conf_t  *us, *uscf;\n

\n

Functions

\nAll functions (even static ones) should have prototypes.\nPrototypes include argument names.\nLong prototypes are wrapped with a single indentation on continuation lines:\n

\nstatic char *ngx_http_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);\nstatic ngx_int_t ngx_http_init_phases(ngx_conf_t *cf,\n    ngx_http_core_main_conf_t *cmcf);\n\nstatic char *ngx_http_merge_servers(ngx_conf_t *cf,\n    ngx_http_core_main_conf_t *cmcf, ngx_http_module_t *module,\n    ngx_uint_t ctx_index);\n

\nThe function name in a definition starts with a new line.\nThe function body opening and closing braces are on separate lines.\nThe body of a function is indented.\nThere are two empty lines between functions:\n

\nstatic ngx_int_t\nngx_http_find_virtual_server(ngx_http_request_t *r, u_char *host, size_t len)\n{\n    ...\n}\n\n\nstatic ngx_int_t\nngx_http_add_addresses(ngx_conf_t *cf, ngx_http_core_srv_conf_t *cscf,\n    ngx_http_conf_port_t *port, ngx_http_listen_opt_t *lsopt)\n{\n    ...\n}\n

\nThere is no space after the function name and opening parenthesis.\nLong function calls are wrapped such that continuation lines start\nfrom the position of the first function argument.\nIf this is impossible, format the first continuation line such that it\nends at position 79:\n

\nngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,\n               \"http header: \\\"%V: %V\\\"\",\n               &h->key, &h->value);\n\nhc->busy = ngx_palloc(r->connection->pool,\n                  cscf->large_client_header_buffers.num * sizeof(ngx_buf_t *));\n

\nThe ngx_inline macro should be used instead of\ninline:\n

\nstatic ngx_inline void ngx_cpuid(uint32_t i, uint32_t *buf);\n

\n

Expressions

\nBinary operators except “.” and “−>”\nshould be separated from their operands by one space.\nUnary operators and subscripts are not separated from their operands by spaces:\n

\nwidth = width * 10 + (*fmt++ - '0');\n

\n

\nch = (u_char) ((decoded << 4) + (ch - '0'));\n

\n

\nr->exten.data = &r->uri.data[i + 1];\n

\n

\nType casts are separated by one space from casted expressions.\nAn asterisk inside type cast is separated with space from type name:\n

\nlen = ngx_sock_ntop((struct sockaddr *) sin6, p, len, 1);\n

\n

\nIf an expression does not fit into single line, it is wrapped.\nThe preferred point to break a line is a binary operator.\nThe continuation line is lined up with the start of expression:\n

\nif (status == NGX_HTTP_MOVED_PERMANENTLY\n    || status == NGX_HTTP_MOVED_TEMPORARILY\n    || status == NGX_HTTP_SEE_OTHER\n    || status == NGX_HTTP_TEMPORARY_REDIRECT\n    || status == NGX_HTTP_PERMANENT_REDIRECT)\n{\n    ...\n}\n

\n

\np->temp_file->warn = \"an upstream response is buffered \"\n                     \"to a temporary file\";\n

\nAs a last resort, it is possible to wrap an expression so that the\ncontinuation line ends at position 79:\n

\nhinit->hash = ngx_pcalloc(hinit->pool, sizeof(ngx_hash_wildcard_t)\n                                     + size * sizeof(ngx_hash_elt_t *));\n

\nThe above rules also apply to sub-expressions,\nwhere each sub-expression has its own indentation level:\n

\nif (((u->conf->cache_use_stale & NGX_HTTP_UPSTREAM_FT_UPDATING)\n     || c->stale_updating) && !r->background\n    && u->conf->cache_background_update)\n{\n    ...\n}\n

\nSometimes, it is convenient to wrap an expression after a cast.\nIn this case, the continuation line is indented:\n

\nnode = (ngx_rbtree_node_t *)\n           ((u_char *) lr - offsetof(ngx_rbtree_node_t, color));\n

\n

\nPointers are explicitly compared to\nNULL (not 0):\n\n

\nif (ptr != NULL) {\n    ...\n}\n

\n

Conditionals and Loops

\nThe “if” keyword is separated from the condition by\none space.\nOpening brace is located on the same line, or on a\ndedicated line if the condition takes several lines.\nClosing brace is located on a dedicated line, optionally followed\nby “else if / else”.\nUsually, there is an empty line before the\n“else if / else” part:\n

\nif (node->left == sentinel) {\n    temp = node->right;\n    subst = node;\n\n} else if (node->right == sentinel) {\n    temp = node->left;\n    subst = node;\n\n} else {\n    subst = ngx_rbtree_min(node->right, sentinel);\n\n    if (subst->left != sentinel) {\n        temp = subst->left;\n\n    } else {\n        temp = subst->right;\n    }\n}\n

\n

\nSimilar formatting rules are applied to “do”\nand “while” loops:\n

\nwhile (p < last && *p == ' ') {\n    p++;\n}\n

\n\n

\ndo {\n    ctx->node = rn;\n    ctx = ctx->next;\n} while (ctx);\n

\n

\nThe “switch” keyword is separated from the condition by\none space.\nOpening brace is located on the same line.\nClosing brace is located on a dedicated line.\nThe “case” keywords are lined up with\n“switch”:\n

\nswitch (ch) {\ncase '!':\n    looked = 2;\n    state = ssi_comment0_state;\n    break;\n\ncase '<':\n    copy_end = p;\n    break;\n\ndefault:\n    copy_end = p;\n    looked = 0;\n    state = ssi_start_state;\n    break;\n}\n

\n

\nMost “for” loops are formatted like this:\n

\nfor (i = 0; i < ccf->env.nelts; i++) {\n    ...\n}\n

\n

\nfor (q = ngx_queue_head(locations);\n     q != ngx_queue_sentinel(locations);\n     q = ngx_queue_next(q))\n{\n    ...\n}\n

\nIf some part of the “for” statement is omitted,\nthis is indicated by the “/* void */” comment:\n

\nfor (i = 0; /* void */ ; i++) {\n    ...\n}\n

\nA loop with an empty body is also indicated by the\n“/* void */” comment which may be put on the same line:\n

\nfor (cl = *busy; cl->next; cl = cl->next) { /* void */ }\n

\nAn endless loop looks like this:\n

\nfor ( ;; ) {\n    ...\n}\n

\n

Labels

\nLabels are surrounded with empty lines and are indented at the previous level:\n

\n    if (i == 0) {\n        u->err = \"host not found\";\n        goto failed;\n    }\n\n    u->addrs = ngx_pcalloc(pool, i * sizeof(ngx_addr_t));\n    if (u->addrs == NULL) {\n        goto failed;\n    }\n\n    u->naddrs = i;\n\n    ...\n\n    return NGX_OK;\n\nfailed:\n\n    freeaddrinfo(res);\n    return NGX_ERROR;\n

\n

Debugging memory issues

\nTo debug memory issues such as buffer overruns or use-after-free errors, you\ncan use the \nAddressSanitizer (ASan) supported by some modern compilers.\nTo enable ASan with gcc and clang,\nuse the -fsanitize=address compiler and linker option.\nWhen building nginx, this can be done by adding the option to\n--with-cc-opt and --with-ld-opt\nparameters of the configure script.\n

\nSince most allocations in nginx are made from nginx internal\npool, enabling ASan may not always be enough to debug\nmemory issues.\nThe internal pool allocates a big chunk of memory from the system and cuts\nsmaller allocations from it.\nHowever, this mechanism can be disabled by setting the\nNGX_DEBUG_PALLOC macro to 1.\nIn this case, allocations are passed directly to the system allocator giving it\nfull control over the buffers boundaries.\n

\nThe following configuration line summarizes the information provided above.\nIt is recommended while developing third-party modules and testing nginx on\ndifferent platforms.\n

\nauto/configure --with-cc-opt='-fsanitize=address -DNGX_DEBUG_PALLOC=1'\n               --with-ld-opt=-fsanitize=address\n

Common Pitfalls

Writing a C module

\nThe most common pitfall is an attempt to write a full-fledged C module\nwhen it can be avoided.\nIn most cases your task can be accomplished by creating a proper configuration.\nIf writing a module is inevitable, try to make it\nas small and simple as possible.\nFor example, a module can only export some\nvariables.\n

\nBefore starting a module, consider the following questions:\n\n

\n\n

C Strings

\nThe most used string type in nginx,\nngx_str_t is not a C-Style\nzero-terminated string.\nYou cannot pass the data to standard C library functions\nsuch as strlen() or strstr().\nInstead, nginx counterparts\nthat accept either ngx_str_t should be used\nor pointer to data and a length.\nHowever, there is a case when ngx_str_t holds\na pointer to a zero-terminated string: strings that come as a result of\nconfiguration file parsing are zero-terminated.\n

Global Variables

\nAvoid using global variables in your modules.\nMost likely this is an error to have a global variable.\nAny global data should be tied to a configuration cycle\nand be allocated from the corresponding memory pool.\nThis allows nginx to perform graceful configuration reloads.\nAn attempt to use global variables will likely break this feature,\nbecause it will be impossible to have two configurations at\nthe same time and get rid of them.\nSometimes global variables are required.\nIn this case, special attention is needed to manage reconfiguration\nproperly.\nAlso, check if libraries used by your code have implicit\nglobal state that may be broken on reload.\n

Manual Memory Management

\nInstead of dealing with malloc/free approach which is error prone,\nlearn how to use nginx pools.\nA pool is created and tied to an object -\nconfiguration,\ncycle,\nconnection,\nor HTTP request.\nWhen the object is destroyed, the associated pool is destroyed too.\nSo when working with an object, it is possible to allocate the amount\nneeded from the corresponding pool and don't care about freeing memory\neven in case of errors.\n

Threads

\nIt is recommended to avoid using threads in nginx because it will\ndefinitely break things: most nginx functions are not thread-safe.\nIt is expected that a thread will be executing only system calls and\nthread-safe library functions.\nIf you need to run some code that is not related to client request processing,\nthe proper way is to schedule a timer in the init_process\nmodule handler and perform required actions in timer handler.\nInternally nginx makes use of threads to\nboost IO-related operations, but this is a special case with a lot\nof limitations.\n

Blocking Libraries

\nA common mistake is to use libraries that are blocking internally.\nMost libraries out there are synchronous and blocking by nature.\nIn other words, they perform one operation at a time and waste\ntime waiting for response from other peer.\nAs a result, when a request is processed with such library, whole\nnginx worker is blocked, thus destroying performance.\nUse only libraries that provide asynchronous interface and don't\nblock whole process.\n

HTTP Requests to External Services

\nOften modules need to perform an HTTP call to some external service.\nA common mistake is to use some external library, such as libcurl,\nto perform the HTTP request.\nIt is absolutely unnecessary to bring a huge amount of external\n(probably blocking!) code\nfor the task which can be accomplished by nginx itself.\n

\nThere are two basic usage scenarios when an external request is needed:\n\n

\n\n

\nIn the first case, the best is to use\nsubrequests API.\nInstead of directly accessing external service, you declare a location\nin nginx configuration and direct your subrequest to this location.\nThis location is not limited to\nproxying\nrequests, but may contain other nginx directives.\nAn example of such approach is the\nauth_request\ndirective implemented in\nngx_http_auth_request module.\n

\nFor the second case, it is possible to use basic HTTP client functionality\navailable in nginx.\nFor example,\nOCSP module\nimplements simple HTTP client.\n

\n", "encoding": "utf-8"} +{"path": "en\\docs\\faq\\accept_failed.html", "extension": ".html", "size_bytes": 3179, "content": "\nWhat does the following error mean in the log file: “accept() failed (53: Software caused connection abort) while accepting new connection on 0.0.0.0:80”?
\n\nPlanning your ingress-nginx migration? Start here:\nkubernetes.nginx.org.\n\n

What does the following error mean in the log file: “accept() failed (53: Software caused connection abort) while accepting new connection on 0.0.0.0:80”?

\nQ:\nWhat does the following error mean in the log file: \"accept() failed (53:\nSoftware caused connection abort) while accepting new\nconnection on 0.0.0.0:80\"?\n

\n \n

\nA:\nSuch errors stem from the connections that the clients managed\nto close before nginx was able to process them. For instance, this can\nhappen in a situation when the user didn’t wait for a page\nheavily populated with images to load fully, and clicked on a\ndifferent link. In this case user’s browser would close all of\nthe prior connections which aren’t longer necessary.\nIt is a non-critical error.\n

\n", "encoding": "utf-8"} +{"path": "en\\docs\\faq\\chunked_encoding_from_backend.html", "extension": ".html", "size_bytes": 3250, "content": "\nWhy nginx doesn’t handle chunked encoding responses from my backend properly?
\n\nPlanning your ingress-nginx migration? Start here:\nkubernetes.nginx.org.\n\n

Why nginx doesn’t handle chunked encoding responses from my backend properly?

\nQ:\nMy backend server appears to send HTTP/1.0 responses using\nchunked encoding but nginx doesn’t handle it correctly.\nFor instance, I’m using nginx as a frontend to my node.js\napplication and instead of pure JSON from backend, nginx\nreturns something framed in decimal numbers like\n\n

\n47\n{\"error\":\"query error\",\"message\":\"Parameter(s) missing: user,password\"}\n0\n

\n\n

\n \n

\nA:\nYour backend violates HTTP specification (see\nRFC 2616,\n\"3.6 Transfer Codings\").\nThe \"chunked\" transfer-codings must not be used with HTTP/1.0.\nYou’d need to either fix your backend application or upgrade\nto nginx version 1.1.4 and newer, where an additional code\nwas introduced to handle such erratic backend behavior.\n

\n", "encoding": "utf-8"} +{"path": "en\\docs\\faq\\daemon_master_process_off.html", "extension": ".html", "size_bytes": 3324, "content": "\nCan I run nginx with “daemon off” or “master_process off” settings in a production environment?
\n\nPlanning your ingress-nginx migration? Start here:\nkubernetes.nginx.org.\n\n

Can I run nginx with “daemon off” or “master_process off” settings in a production environment?

\nQ:\nCan I run nginx with \"daemon off\" or \"master_process off\" settings\nin a production environment?\n

\n \n

\nA:\nFirst of all, both \"daemon on|off\" and \"master_process on|off\" directives were\nintended to be used primarily for nginx code development.\n

\nWhile many people use \"daemon off\" in production it wasn’t really meant for\nthat. Since version 1.0.9 it is now quite safe to run nginx in production\nwith \"daemon off\", though. Bear in mind that non-stop upgrade is not an\noption with \"daemon off\".\n

\nIn a development environment, using \"master_process off\", nginx can run in\nthe foreground without the master process and can be terminated simply\nwith ^C (SIGINT). This is somewhat similar to running Apache with\nan 'X' command-line option. However you should NEVER run nginx in production\nwith \"master_process off\".\n

\n", "encoding": "utf-8"} +{"path": "en\\docs\\faq\\license_copyright.html", "extension": ".html", "size_bytes": 3205, "content": "\nHow can nginx copyright be acknowledged when using nginx as part of a proprietary software distribution?
\n\nPlanning your ingress-nginx migration? Start here:\nkubernetes.nginx.org.\n\n

How can nginx copyright be acknowledged when using nginx as part of a proprietary software distribution?

\nQ:\nI’d like to use nginx distribution as part of my proprietary\nsoftware package. How can nginx copyright be acknowledged\nwhen using nginx as part of a proprietary software distribution?\n

\n \n

\nA:\nThe text below should be added to your license conditions,\nfollowed by the text of the applicable 2-clause BSD license described\nhere.\n\n

\nThis product contains software provided by Nginx, Inc. and its contributors.\n

\n\n

\nAlso, if your build of nginx includes any of the following 3rd party\nproducts: zlib, PCRE, OpenSSL — it’s worth including their\ncopyright acknowledgements and disclaimers as well.\n

\n", "encoding": "utf-8"} +{"path": "en\\docs\\faq\\variables_in_config.html", "extension": ".html", "size_bytes": 3282, "content": "\nIs there a proper way to use nginx variables to make sections of the configuration shorter, using them as macros for making parts of configuration work as templates?
\n\nPlanning your ingress-nginx migration? Start here:\nkubernetes.nginx.org.\n\n

Is there a proper way to use nginx variables to make sections of the configuration shorter, using them as macros for making parts of configuration work as templates?

\nQ:\nIs there a proper way to use nginx variables to make sections of\nthe configuration shorter, using them as macros for making\nparts of configuration work as templates?\n

\n \n

\nA:\nVariables should not be used as template macros. Variables are\nevaluated in the run-time during the processing of each\nrequest, so they are rather costly compared to plain static\nconfiguration. Using variables to store static strings is also\na bad idea. Instead, a macro expansion and \"include\" directives\nshould be used to generate configs more easily and it can be\ndone with the external tools, e.g. sed + make or any other\ncommon template mechanism.\n

\n", "encoding": "utf-8"} +{"path": "en\\docs\\http\\configuring_https_servers.html", "extension": ".html", "size_bytes": 18133, "content": "\nConfiguring HTTPS servers
\n\nPlanning your ingress-nginx migration? Start here:\nkubernetes.nginx.org.\n\n

Configuring HTTPS servers

HTTPS server optimization
SSL certificate chains
A single HTTP/HTTPS server
Name-based HTTPS servers
     An SSL certificate with several names
     Server Name Indication
Compatibility

\nTo configure an HTTPS server, the ssl parameter\nmust be enabled on\nlistening sockets\nin the server block,\nand the locations of the\nserver certificate\nand\nprivate key\nfiles should be specified:\n\n

\nserver {\n    listen              443 ssl;\n    server_name         www.example.com;\n    ssl_certificate     www.example.com.crt;\n    ssl_certificate_key www.example.com.key;\n    ssl_protocols       TLSv1.2 TLSv1.3;\n    ssl_ciphers         HIGH:!aNULL:!MD5;\n    ...\n}\n

\n\nThe server certificate is a public entity.\nIt is sent to every client that connects to the server.\nThe private key is a secure entity and should be stored in a file with\nrestricted access, however, it must be readable by nginx’s master process.\nThe private key may alternately be stored in the same file as the certificate:\n\n

\n    ssl_certificate     www.example.com.cert;\n    ssl_certificate_key www.example.com.cert;\n

\n\nin which case the file access rights should also be restricted.\nAlthough the certificate and the key are stored in one file,\nonly the certificate is sent to a client.\n

\nThe directives ssl_protocols and\nssl_ciphers\ncan be used to limit connections\nto include only the strong versions and ciphers of SSL/TLS.\nBy default nginx uses\n“ssl_protocols TLSv1.2 TLSv1.3”\nand “ssl_ciphers HIGH:!aNULL:!MD5”,\nso configuring them explicitly is generally not needed.\nNote that default values of these directives were\nchanged several times.\n

HTTPS server optimization

\nSSL operations consume extra CPU resources.\nOn multi-processor systems several\nworker processes\nshould be run,\nno less than the number of available CPU cores.\nThe most CPU-intensive operation is the SSL handshake.\nThere are two ways to minimize the number of these operations per client:\nthe first is by enabling\nkeepalive\nconnections to send several\nrequests via one connection and the second is to reuse SSL session\nparameters to avoid SSL handshakes for parallel and subsequent connections.\nThe sessions are stored in an SSL session cache shared between workers\nand configured by the\nssl_session_cache\ndirective.\nOne megabyte of the cache contains about 4000 sessions.\nThe default cache timeout is 5 minutes.\nIt can be increased by using the\nssl_session_timeout\ndirective.\nHere is a sample configuration optimized for a multi-core system\nwith 10 megabyte shared session cache:\n\n

\nworker_processes auto;\n\nhttp {\n    ssl_session_cache   shared:SSL:10m;\n    ssl_session_timeout 10m;\n\n    server {\n        listen              443 ssl;\n        server_name         www.example.com;\n        keepalive_timeout   70;\n\n        ssl_certificate     www.example.com.crt;\n        ssl_certificate_key www.example.com.key;\n        ssl_protocols       TLSv1.2 TLSv1.3;\n        ssl_ciphers         HIGH:!aNULL:!MD5;\n        ...\n

\n

SSL certificate chains

\nSome browsers may complain about a certificate signed by a well-known\ncertificate authority, while other browsers may accept the certificate\nwithout issues.\nThis occurs because the issuing authority has signed the server certificate\nusing an intermediate certificate that is not present in the certificate\nbase of well-known trusted certificate authorities which is distributed\nwith a particular browser.\nIn this case the authority provides a bundle of chained certificates\nwhich should be concatenated to the signed server certificate.\nThe server certificate must appear before the chained certificates\nin the combined file:\n\n

\n$ cat www.example.com.crt bundle.crt > www.example.com.chained.crt\n

\n\nThe resulting file should be used in the\nssl_certificate directive:\n\n

\nserver {\n    listen              443 ssl;\n    server_name         www.example.com;\n    ssl_certificate     www.example.com.chained.crt;\n    ssl_certificate_key www.example.com.key;\n    ...\n}\n

\n\nIf the server certificate and the bundle have been concatenated in the wrong\norder, nginx will fail to start and will display the error message:\n\n

\nSSL_CTX_use_PrivateKey_file(\" ... /www.example.com.key\") failed\n   (SSL: error:05800074:x509 certificate routines::key values mismatch)\n

\n\nbecause nginx has tried to use the private key with the bundle’s\nfirst certificate instead of the server certificate.\n

\nBrowsers usually store intermediate certificates which they receive\nand which are signed by trusted authorities, so actively used browsers\nmay already have the required intermediate certificates and\nmay not complain about a certificate sent without a chained bundle.\nTo ensure the server sends the complete certificate chain,\nthe openssl command-line utility may be used, for example:\n\n

\n$ openssl s_client -connect www.godaddy.com:443\n...\nCertificate chain\n 0 s:/C=US/ST=Arizona/L=Scottsdale/1.3.6.1.4.1.311.60.2.1.3=US\n     /1.3.6.1.4.1.311.60.2.1.2=AZ/O=GoDaddy.com, Inc\n     /OU=MIS Department/CN=www.GoDaddy.com\n     /serialNumber=0796928-7/2.5.4.15=V1.0, Clause 5.(b)\n   i:/C=US/ST=Arizona/L=Scottsdale/O=GoDaddy.com, Inc.\n     /OU=http://certificates.godaddy.com/repository\n     /CN=Go Daddy Secure Certification Authority\n     /serialNumber=07969287\n 1 s:/C=US/ST=Arizona/L=Scottsdale/O=GoDaddy.com, Inc.\n     /OU=http://certificates.godaddy.com/repository\n     /CN=Go Daddy Secure Certification Authority\n     /serialNumber=07969287\n   i:/C=US/O=The Go Daddy Group, Inc.\n     /OU=Go Daddy Class 2 Certification Authority\n 2 s:/C=US/O=The Go Daddy Group, Inc.\n     /OU=Go Daddy Class 2 Certification Authority\n   i:/L=ValiCert Validation Network/O=ValiCert, Inc.\n     /OU=ValiCert Class 2 Policy Validation Authority\n     /CN=http://www.valicert.com//emailAddress=info@valicert.com\n...\n

\n\nIn this example the subject (“s”) of the\nwww.GoDaddy.com server certificate #0 is signed by an issuer\n(“i”) which itself is the subject of the certificate #1,\nwhich is signed by an issuer which itself is the subject of the certificate #2,\nwhich signed by the well-known issuer ValiCert, Inc.\nwhose certificate is stored in the browsers’ built-in\ncertificate base (that lay in the house that Jack built).\n

\nIf a certificate bundle has not been added, only the server certificate #0\nwill be shown.\n

A single HTTP/HTTPS server

\nIt is possible to configure a single server that handles both HTTP\nand HTTPS requests:\n\n

\nserver {\n    listen              80;\n    listen              443 ssl;\n    server_name         www.example.com;\n    ssl_certificate     www.example.com.crt;\n    ssl_certificate_key www.example.com.key;\n    ...\n}\n

\n\n

\nPrior to 0.7.14 SSL could not be enabled selectively for\nindividual listening sockets, as shown above.\nSSL could only be enabled for the entire server using the\nssl directive,\nmaking it impossible to set up a single HTTP/HTTPS server.\nThe ssl parameter of the\nlisten directive\nwas added to solve this issue.\nThe use of the\nssl directive\nin modern versions is thus discouraged;\nit was removed in 1.25.1.\n

\n

Name-based HTTPS servers

\nA common issue arises when configuring two or more HTTPS servers\nlistening on a single IP address:\n\n

\nserver {\n    listen          443 ssl;\n    server_name     www.example.com;\n    ssl_certificate www.example.com.crt;\n    ...\n}\n\nserver {\n    listen          443 ssl;\n    server_name     www.example.org;\n    ssl_certificate www.example.org.crt;\n    ...\n}\n

\n\nWith this configuration a browser receives the default server’s certificate,\ni.e. www.example.com regardless of the requested server name.\nThis is caused by SSL protocol behaviour.\nThe SSL connection is established before the browser sends an HTTP request\nand nginx does not know the name of the requested server.\nTherefore, it may only offer the default server’s certificate.\n

\nThe oldest and most robust method to resolve the issue\nis to assign a separate IP address for every HTTPS server:\n\n

\nserver {\n    listen          192.168.1.1:443 ssl;\n    server_name     www.example.com;\n    ssl_certificate www.example.com.crt;\n    ...\n}\n\nserver {\n    listen          192.168.1.2:443 ssl;\n    server_name     www.example.org;\n    ssl_certificate www.example.org.crt;\n    ...\n}\n

\n

An SSL certificate with several names

\nThere are other ways that allow sharing a single IP address\nbetween several HTTPS servers.\nHowever, all of them have their drawbacks.\nOne way is to use a certificate with several names in\nthe SubjectAltName certificate field, for example,\nwww.example.com and www.example.org.\nHowever, the SubjectAltName field length is limited.\n

\nAnother way is to use a certificate with a wildcard name, for example,\n*.example.org.\nA wildcard certificate secures all subdomains of the specified domain,\nbut only on one level.\nThis certificate matches www.example.org, but does not match\nexample.org and www.sub.example.org.\nThese two methods can also be combined.\nA certificate may contain exact and wildcard names in the\nSubjectAltName field, for example,\nexample.org and *.example.org.\n

\nIt is better to place a certificate file with several names and\nits private key file at the http level of configuration\nto inherit their single memory copy in all servers:\n\n

\nssl_certificate     common.crt;\nssl_certificate_key common.key;\n\nserver {\n    listen          443 ssl;\n    server_name     www.example.com;\n    ...\n}\n\nserver {\n    listen          443 ssl;\n    server_name     www.example.org;\n    ...\n}\n

\n

Server Name Indication

\nA more generic solution for running several HTTPS servers on a single\nIP address is\nTLS\nServer Name Indication extension (SNI, RFC 6066),\nwhich allows a browser to pass a requested server name during the SSL handshake\nand, therefore, the server will know which certificate it should use\nfor the connection.\nSNI is currently\nsupported\nby most modern browsers\nand is a mandatory-to-implement extension in TLSv1.3,\nthough may not be used by some old or special clients.\n

\nOnly domain names can be passed in SNI,\nhowever some browsers may erroneously pass an IP address of the server\nas its name if a request includes literal IP address.\nOne should not rely on this.\n

\n

\nIn order to use SNI in nginx, it must be supported in both the\nOpenSSL library with which the nginx binary has been built as well as\nthe library to which it is being dynamically linked at run time.\nOpenSSL supports SNI since 0.9.8f version if it was built with config option\n“--enable-tlsext”.\nSince OpenSSL 0.9.8j this option is enabled by default.\nIf nginx was built with SNI support, then nginx will show this\nwhen run with the “-V” switch:\n\n

\n$ nginx -V\n...\nTLS SNI support enabled\n...\n

\n\nHowever, if the SNI-enabled nginx is linked dynamically to\nan OpenSSL library without SNI support, nginx displays the warning:\n\n

\nnginx was built with SNI support, however, now it is linked\ndynamically to an OpenSSL library which has no tlsext support,\ntherefore SNI is not available\n

\n

Compatibility

\n

\n

\n

\n

\n

\n

written by Igor Sysoev
edited by Brian Mercer
\n", "encoding": "utf-8"} +{"path": "en\\docs\\http\\converting_rewrite_rules.html", "extension": ".html", "size_bytes": 5563, "content": "\nConverting rewrite rules
\n\nPlanning your ingress-nginx migration? Start here:\nkubernetes.nginx.org.\n\n

Converting rewrite rules

Converting Mongrel rules

A redirect to a main site

\nPeople who during their shared hosting life used to configure\neverything using only Apache’s .htaccess files,\nusually translate the following rules:\n\n

\nRewriteCond  %{HTTP_HOST}  example.org\nRewriteRule  (.*)          http://www.example.org$1\n

\n\nto something like this:\n\n

\nserver {\n    listen       80;\n    server_name  www.example.org  example.org;\n    if ($http_host = example.org) {\n        rewrite  (.*)  http://www.example.org$1;\n    }\n    ...\n}\n

\n

\nThis is a wrong, cumbersome, and ineffective way.\nThe right way is to define a separate server for example.org:\n\n

\nserver {\n    listen       80;\n    server_name  example.org;\n    return       301 http://www.example.org$request_uri;\n}\n\nserver {\n    listen       80;\n    server_name  www.example.org;\n    ...\n}\n

\n\n

\nOn versions prior to 0.9.1, redirects can be made with:\n
\n    rewrite      ^ http://www.example.org$request_uri?;\n
\n

\n\n

\nAnother example.\nInstead of the “upside-down” logic “all that is not\nexample.com and is not www.example.com”:\n\n

\nRewriteCond  %{HTTP_HOST}  !example.com\nRewriteCond  %{HTTP_HOST}  !www.example.com\nRewriteRule  (.*)          http://www.example.com$1\n

\n\none should simply define example.com, www.example.com,\nand “everything else”:\n\n

\nserver {\n    listen       80;\n    server_name  example.com www.example.com;\n    ...\n}\n\nserver {\n    listen       80 default_server;\n    server_name  _;\n    return       301 http://example.com$request_uri;\n}\n

\n\n

\nOn versions prior to 0.9.1, redirects can be made with:\n
\n    rewrite      ^ http://example.com$request_uri?;\n
\n

\n\n

Converting Mongrel rules

\nTypical Mongrel rules:\n\n

\nDocumentRoot /var/www/myapp.com/current/public\n\nRewriteCond %{DOCUMENT_ROOT}/system/maintenance.html -f\nRewriteCond %{SCRIPT_FILENAME} !maintenance.html\nRewriteRule ^.*$ %{DOCUMENT_ROOT}/system/maintenance.html [L]\n\nRewriteCond %{REQUEST_FILENAME} -f\nRewriteRule ^(.*)$ $1 [QSA,L]\n\nRewriteCond %{REQUEST_FILENAME}/index.html -f\nRewriteRule ^(.*)$ $1/index.html [QSA,L]\n\nRewriteCond %{REQUEST_FILENAME}.html -f\nRewriteRule ^(.*)$ $1.html [QSA,L]\n\nRewriteRule ^/(.*)$ balancer://mongrel_cluster%{REQUEST_URI} [P,QSA,L]\n

\n\nshould be converted to\n\n

\nlocation / {\n    root       /var/www/myapp.com/current/public;\n\n    try_files  /system/maintenance.html\n               $uri  $uri/index.html $uri.html\n               @mongrel;\n}\n\nlocation @mongrel {\n    proxy_pass  http://mongrel;\n}\n

\n

\n", "encoding": "utf-8"} +{"path": "en\\docs\\http\\load_balancing.html", "extension": ".html", "size_bytes": 12424, "content": "\nUsing nginx as HTTP load balancer
\n\nPlanning your ingress-nginx migration? Start here:\nkubernetes.nginx.org.\n\n

Using nginx as HTTP load balancer

Load balancing methods
Default load balancing configuration
Least connected load balancing
Least time load balancing
Session persistence
Weighted load balancing
Health checks
Further reading

Introduction

\nLoad balancing across multiple application instances is a commonly used\ntechnique for optimizing resource utilization, maximizing throughput,\nreducing latency, and ensuring fault-tolerant configurations.\n

\nIt is possible to use nginx as a very efficient HTTP load balancer to\ndistribute traffic to several application servers and to improve\nperformance, scalability and reliability of web applications with nginx.\n

Load balancing methods

\nThe following load balancing mechanisms (or methods) are supported in\nnginx:\n

\n

Default load balancing configuration

\nThe simplest configuration for load balancing with nginx may look\nlike the following:\n

\nhttp {\n    upstream myapp1 {\n        server srv1.example.com;\n        server srv2.example.com;\n        server srv3.example.com;\n    }\n\n    server {\n        listen 80;\n\n        location / {\n            proxy_pass http://myapp1;\n        }\n    }\n}\n

\n

\nIn the example above, there are 3 instances of the same application\nrunning on srv1-srv3.\nWhen the load balancing method is not specifically configured,\nit defaults to round-robin.\nAll requests are\n\nproxied to the server group myapp1, and nginx applies HTTP load\nbalancing to distribute the requests.\n

\nReverse proxy implementation in nginx includes load balancing for HTTP,\nHTTPS, FastCGI, uwsgi, SCGI, memcached, and gRPC.\n

\nTo configure load balancing for HTTPS instead of HTTP, just use “https”\nas the protocol.\n

\nWhen setting up load balancing for FastCGI, uwsgi, SCGI, memcached, or gRPC, use\nfastcgi_pass,\nuwsgi_pass,\nscgi_pass,\nmemcached_pass, and\ngrpc_pass\ndirectives respectively.\n

Least connected load balancing

\nAnother load balancing discipline is least-connected.\nLeast-connected allows controlling the load on application\ninstances more fairly in a situation when some of the requests\ntake longer to complete.\n

\nWith the least-connected load balancing, nginx will try not to overload a\nbusy application server with excessive requests, distributing the new\nrequests to a less busy server instead.\n

\nLeast-connected load balancing in nginx is activated when the\n\nleast_conn directive is used as part of the server group configuration:\n

\n    upstream myapp1 {\n        least_conn;\n        server srv1.example.com;\n        server srv2.example.com;\n        server srv3.example.com;\n    }\n

\n

Least time load balancing

\nAnother load balancing discipline is least-time.\nLeast-time selects the server with the lowest average response time\nand the lowest number of active connections, taking into account\ninflight requests.\n

\nWith the least-time load balancing, nginx selects the server based on\nwhich of the following parameters is specified in the\n\nleast_time directive:\n

\n

\nLeast-time load balancing in nginx is activated when the\n\nleast_time directive is used as part of the server group configuration:\n

\n    upstream myapp1 {\n        least_time header;\n        server srv1.example.com;\n        server srv2.example.com;\n        server srv3.example.com;\n    }\n

\n

Session persistence

\nPlease note that with round-robin or least-connected load\nbalancing, each subsequent client’s request can be potentially\ndistributed to a different server.\nThere is no guarantee that the same client will be always\ndirected to the same server.\n

\nIf there is the need to tie a client to a particular application server —\nin other words, make the client’s session “sticky” or “persistent” in\nterms of always trying to select a particular server — the ip-hash load\nbalancing mechanism can be used.\n

\nWith ip-hash, the client’s IP address is used as a hashing key to\ndetermine what server in a server group should be selected for the\nclient’s requests.\nThis method ensures that the requests from the same client\nwill always be directed to the same server\nexcept when this server is unavailable.\n

\nTo configure ip-hash load balancing, just add the\nip_hash\ndirective to the server (upstream) group configuration:\n

\nupstream myapp1 {\n    ip_hash;\n    server srv1.example.com;\n    server srv2.example.com;\n    server srv3.example.com;\n}\n

\n

Weighted load balancing

\nIt is also possible to influence nginx load balancing algorithms even\nfurther by using server weights.\n

\nIn the examples above, the server weights are not configured which means\nthat all specified servers are treated as equally qualified for a\nparticular load balancing method.\n

\nWith the round-robin in particular it also means a more or less equal\ndistribution of requests across the servers — provided there are enough\nrequests, and when the requests are processed in a uniform manner and\ncompleted fast enough.\n

\nWhen the\nweight\nparameter is specified for a server, the weight is accounted as part\nof the load balancing decision.\n

\n    upstream myapp1 {\n        server srv1.example.com weight=3;\n        server srv2.example.com;\n        server srv3.example.com;\n    }\n

\n

\nWith this configuration, every 5 new requests will be distributed across\nthe application instances as the following: 3 requests will be directed\nto srv1, one request will go to srv2, and another one — to srv3.\n

\nIt is similarly possible to use weights with the least-connected and\nip-hash load balancing in the recent versions of nginx.\n

Health checks

\nReverse proxy implementation in nginx includes in-band (or passive)\nserver health checks.\nIf the response from a particular server fails with an error,\nnginx will mark this server as failed, and will try to\navoid selecting this server for subsequent inbound requests for a while.\n

\nThe\nmax_fails\ndirective sets the number of consecutive unsuccessful attempts to\ncommunicate with the server that should happen during\nfail_timeout.\nBy default,\nmax_fails\nis set to 1.\nWhen it is set to 0, health checks are disabled for this server.\nThe\nfail_timeout\nparameter also defines how long the server will be marked as failed.\nAfter\nfail_timeout\ninterval following the server failure, nginx will start to gracefully\nprobe the server with the live client’s requests.\nIf the probes have been successful, the server is marked as a live one.\n

Further reading

\nIn addition, there are more directives and parameters that control server\nload balancing in nginx, e.g.\nproxy_next_upstream,\nbackup,\ndown, and\nkeepalive.\nFor more information please check our\nreference documentation.\n

\nLast but not least,\napplication load balancing,\napplication health checks,\nactivity monitoring and\non-the-fly reconfiguration of server groups are available\nas part of our paid NGINX Plus subscriptions.\n

\n", "encoding": "utf-8"} +{"path": "en\\docs\\http\\ngx_http_access_module.html", "extension": ".html", "size_bytes": 6443, "content": "\nModule ngx_http_access_module
\n\nPlanning your ingress-nginx migration? Start here:\nkubernetes.nginx.org.\n\n

Module ngx_http_access_module

Example Configuration
Directives
     allow
     deny
\n\n

\nThe ngx_http_access_module module allows\nlimiting access to certain client addresses.\n

\nAccess can also be limited by\npassword, by the\nresult of subrequest,\nor by JWT.\nSimultaneous limitation of access by address and by password is controlled\nby the satisfy directive.\n

\n\n\n

Example Configuration

\n

\nlocation / {\n    deny  192.168.1.1;\n    allow 192.168.1.0/24;\n    allow 10.1.1.0/16;\n    allow 2001:0db8::/32;\n    deny  all;\n}\n

\n

\nThe rules are checked in sequence until the first match is found.\nIn this example, access is allowed only for IPv4 networks\n10.1.1.0/16 and 192.168.1.0/24\nexcluding the address 192.168.1.1,\nand for IPv6 network 2001:0db8::/32.\nIn case of a lot of rules, the use of the\nngx_http_geo_module\nmodule variables is preferable.\n

\n\n\n

Directives

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n allow \n address |\n CIDR |\n unix: |\n all;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n http, server, location, limit_except
\n

\nAllows access for the specified network or address.\nIf the special value unix: is specified (1.5.1),\nallows access for all UNIX-domain sockets.\n

\nSeveral allow directives can be specified on the same level.\nThese directives are inherited from the previous configuration level\nif and only if there are no allow and\ndeny directives defined on the current level.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n deny \n address |\n CIDR |\n unix: |\n all;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n http, server, location, limit_except
\n

\nDenies access for the specified network or address.\nIf the special value unix: is specified (1.5.1),\ndenies access for all UNIX-domain sockets.\n

\nSeveral deny directives can be specified on the same level.\nThese directives are inherited from the previous configuration level\nif and only if there are no allow and\ndeny directives defined on the current level.\n

\n\n
\n", "encoding": "utf-8"} +{"path": "en\\docs\\http\\ngx_http_acme_module.html", "extension": ".html", "size_bytes": 23058, "content": "\nModule ngx_http_acme_module
\n\nPlanning your ingress-nginx migration? Start here:\nkubernetes.nginx.org.\n\n

Module ngx_http_acme_module

Example Configuration
Directives
     acme_issuer
     uri
     account_key
     challenge
     common_name_in_csr
     contact
     external_account_key
     preferred_chain
     profile
     ssl_trusted_certificate
     ssl_verify
     state_path
     accept_terms_of_service
     acme_shared_zone
     acme_certificate
Embedded Variables
\n\n

\nThe ngx_http_acme_module module implements\nthe automatic certificate management\n(ACMEv2)\nprotocol.\n

\nThe source code of the module is available\nhere.\nDownload and install instructions are available\nhere.\n

\nThe module is also available in a prebuilt\nnginx-module-acme\npackage\nand in nginx-plus-module-acme package\nas part of our\ncommercial subscription since 1.29.0.\n

\n\n\n

Example Configuration

\n

\nresolver 127.0.0.1:53;\n\nacme_issuer example {\n    uri         https://acme.example.com/directory;\n    contact     admin@example.test;\n    state_path  /var/cache/nginx/acme-example;\n    accept_terms_of_service;\n}\n\nacme_shared_zone zone=ngx_acme_shared:1M;\n\nserver {\n    listen 443 ssl;\n    server_name  .example.test;\n\n    acme_certificate example;\n\n    ssl_certificate       $acme_certificate;\n    ssl_certificate_key   $acme_certificate_key;\n\n    # do not parse the certificate on each request\n    ssl_certificate_cache max=2;\n}\n\nserver {\n    # listener on port 80 is required to process ACME HTTP-01 challenges\n    listen 80;\n\n    location / {\n        return 404;\n    }\n}\n

\n

\n\n\n

Directives

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n acme_issuer name { ... }
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n http
\n

\nDefines an ACME certificate issuer object.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n uri uri;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n acme_issuer
\n

\nThe\ndirectory URL\nof the ACME server.\nThis directive is mandatory.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n account_key alg[:size] | file;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n acme_issuer
\n

\nThe account's private key used for request authentication.\n

\nAccepted values:\n

\n

\nThe generated account keys are preserved across reloads,\nbut will be lost on restart unless state_path is configured.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n challenge type;
\n
\n Default:\n \n
challenge http-01;
\n
\n Context:\n \n acme_issuer
\n

This directive appeared in version 0.2.0.\n

\nSpecifies the ACME challenge type to be used for the issuer.\n

\nAccepted values:\n

\n

\n

\nACME challenges are versioned.\nIf an unversioned name is specified,\nthe module automatically selects the latest implemented version.\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n common_name_in_csr on | off;
\n
\n Default:\n \n
common_name_in_csr off;
\n
\n Context:\n \n acme_issuer
\n

This directive appeared in version 0.4.0.\n

\nIf enabled, sets the Subject Common Name in the certificate request\nto the first DNS name or the first IP address provided.\n

\n

\nEnabling this option may result in rejected certificate requests.\n

\n

\nPrior to version 0.4.0, the Subject Common Name was always set.\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n contact URL;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n acme_issuer
\n

\nSets an array of URLs that the ACME server can use\nto contact the client regarding account issues.\nThe mailto: scheme will be used\nunless specified explicitly.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n external_account_key kid file;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n acme_issuer
\n

This directive appeared in version 0.2.0.\n

\nSpecifies a key identifier kid and a file\nwith the MAC key for\n\nexternal account authorization.\n

\nThe value data:key can be specified\ninstead of the file, which loads a key directly from\nthe configuration without using intermediate files.\n

\nIn both cases, the key is expected to be encoded in\n\nbase64url.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n preferred_chain name;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n acme_issuer
\n

This directive appeared in version 0.3.0.\n

\nSpecifies the preferred certificate chain.\n

\nIf the ACME server offers multiple certificate chains,\nprefer the chain with the topmost certificate issued from the\nSubject Common Name name.\nIf there are no matches, the default chain will be used.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n profile name [require];
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n acme_issuer
\n

This directive appeared in version 0.3.0.\n

\nRequests the\n\ncertificate profile name from the ACME server.\n

\nThe require parameter will cause certificate renewals\nto fail if the server does not support the specified profile.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n ssl_trusted_certificate file;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n acme_issuer
\n

\nSpecifies a file with trusted CA certificates in the PEM format\nused to verify the certificate\nof the ACME server.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n ssl_verify \n on | off;
\n
\n Default:\n \n
ssl_verify on;
\n
\n Context:\n \n acme_issuer
\n

\nEnables or disables verification of the ACME server certificate.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n state_path path | off;
\n
\n Default:\n \n
state_path acme_<issuer>;
\n
\n Context:\n \n acme_issuer
\n

\nDefines a directory for storing the module data\nthat can be persisted across restarts.\nThis can improve the load time by skipping some requests on startup,\nand avoid hitting request rate limits on the ACME server.\n

\nThe directory contains sensitive content, such as\nthe account key, issued certificates, and private keys.\n

\nThe off parameter (0.2.0) disables storing the account\ninformation and issued certificates on disk.\n

\n

\nPrior to version 0.2.0, the state directory was not created by default.\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n accept_terms_of_service;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n acme_issuer
\n

\nAgrees to the terms of service under which the ACME server will be used.\nSome servers require accepting the terms of service\nbefore account registration.\nThe terms are usually available on the ACME server's website,\nand the URL will be printed to the error log if necessary.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n acme_shared_zone \n zone=name:size;
\n
\n Default:\n \n
acme_shared_zone zone=ngx_acme_shared:256k;
\n
\n Context:\n \n http
\n

\nAllows increasing the size of in-memory storage of the module.\nThe shared memory zone will be used to store the issued certificates,\nkeys and challenge data for all the configured certificate issuers.\n

\nThe default zone size is sufficient to hold approximately\n50 ECDSA prime256v1 keys or 35 RSA 2048 keys.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n acme_certificate \n issuer\n [identifier ...]\n [key=alg[:size]];
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n server
\n

\nDefines a certificate with the list of identifiers\nrequested from issuer issuer.\n

\nThe explicit list of identifiers can be omitted.\nIn this case, the identifiers will be taken from the\nserver_name directive\nin the same server block.\nNot all values accepted in the server_name\nare valid certificate identifiers:\nregular expressions and wildcards are not supported.\n

\nThe key parameter sets the type of a generated private key.\nSupported key algorithms and sizes:\necdsa:256 (default),\necdsa:384,\necdsa:521,\nrsa:2048,\nrsa:3072,\nrsa:4096.\n

\n\n\n

Embedded Variables

\nThe ngx_http_acme_module module supports embedded variables,\nvalid in the\nserver block with the\nacme_certificate directive:\n

\n

\n\n
$acme_certificate
\n
\nSSL certificate that can be passed to the\nssl_certificate\n
\n\n
$acme_certificate_key
\n
\nSSL certificate private key that can be passed to\nssl_certificate_key\n
\n\n

\n

\n\n
\n", "encoding": "utf-8"} +{"path": "en\\docs\\http\\ngx_http_addition_module.html", "extension": ".html", "size_bytes": 6326, "content": "\nModule ngx_http_addition_module
\n\nPlanning your ingress-nginx migration? Start here:\nkubernetes.nginx.org.\n\n

Module ngx_http_addition_module

Example Configuration
Directives
     add_before_body
     add_after_body
     addition_types
\n\n

\nThe ngx_http_addition_module module is a filter\nthat adds text before and after a response.\nThis module is not built by default, it should be enabled with the\n--with-http_addition_module\nconfiguration parameter.\n

\n\n\n

Example Configuration

\n

\nlocation / {\n    add_before_body /before_action;\n    add_after_body  /after_action;\n}\n

\n

\n\n\n

Directives

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n add_before_body uri;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n http, server, location
\n

\nAdds the text returned as a result of processing a given subrequest\nbefore the response body.\nAn empty string (\"\") as a parameter cancels addition\ninherited from the previous configuration level.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n add_after_body uri;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n http, server, location
\n

\nAdds the text returned as a result of processing a given subrequest\nafter the response body.\nAn empty string (\"\") as a parameter cancels addition\ninherited from the previous configuration level.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n addition_types mime-type ...;
\n
\n Default:\n \n
addition_types text/html;
\n
\n Context:\n \n http, server, location
\n

This directive appeared in version 0.7.9.\n

\nAllows adding text in responses with the specified MIME types,\nin addition to “text/html”.\nThe special value “*” matches any MIME type (0.8.29).\n

\n\n
\n", "encoding": "utf-8"} +{"path": "en\\docs\\http\\ngx_http_api_module.html", "extension": ".html", "size_bytes": 154776, "content": "\nModule ngx_http_api_module
\n\nPlanning your ingress-nginx migration? Start here:\nkubernetes.nginx.org.\n\n

Module ngx_http_api_module

Example Configuration
Directives
     api
     status_zone
Compatibility
Endpoints
     /
     /nginx
     /processes
     /connections
     /slabs/
     /slabs/{slabZoneName}
     /http/
     /http/requests
     /http/server_zones/
     /http/server_zones/{httpServerZoneName}
     /http/location_zones/
     /http/location_zones/{httpLocationZoneName}
     /http/caches/
     /http/caches/{httpCacheZoneName}
     /http/limit_conns/
     /http/limit_conns/{httpLimitConnZoneName}
     /http/limit_reqs/
     /http/limit_reqs/{httpLimitReqZoneName}
     /http/upstreams/
     /http/upstreams/{httpUpstreamName}/
     /http/upstreams/{httpUpstreamName}/servers/
     /http/upstreams/{httpUpstreamName}/servers/{httpUpstreamServerId}
     /http/keyvals/
     /http/keyvals/{httpKeyvalZoneName}
     /stream/
     /stream/server_zones/
     /stream/server_zones/{streamServerZoneName}
     /stream/limit_conns/
     /stream/limit_conns/{streamLimitConnZoneName}
     /stream/upstreams/
     /stream/upstreams/{streamUpstreamName}/
     /stream/upstreams/{streamUpstreamName}/servers/
     /stream/upstreams/{streamUpstreamName}/servers/{streamUpstreamServerId}
     /stream/keyvals/
     /stream/keyvals/{streamKeyvalZoneName}
     /stream/zone_sync/
     /resolvers/
     /resolvers/{resolverZoneName}
     /ssl
     /license
     /workers/
     /workers/{workerId}
Response Objects
\n\n

\nThe ngx_http_api_module module (1.13.3) provides REST API\nfor accessing various status information,\nconfiguring upstream server groups on-the-fly, and managing\nkey-value pairs\nwithout the need of reconfiguring nginx.\n

\n

\nThe module supersedes the\nngx_http_status_module and\nngx_http_upstream_conf_module\nmodules.\n

\n

\nWhen using the PATCH or POST methods,\nmake sure that the payload does not exceed the\nbuffer size\nfor reading the client request body, otherwise, the\n413 (Request Entity Too Large)\nerror may be returned.\n

\n

\nThis module is available as part of our\ncommercial subscription.\n

\n

\n\n\n

Example Configuration

\n

\nhttp {\n    upstream backend {\n        zone http_backend 64k;\n\n        server backend1.example.com weight=5;\n        server backend2.example.com;\n    }\n\n    proxy_cache_path /data/nginx/cache_backend keys_zone=cache_backend:10m;\n\n    server {\n        server_name backend.example.com;\n\n        location / {\n            proxy_pass  http://backend;\n            proxy_cache cache_backend;\n\n            health_check;\n        }\n\n        status_zone server_backend;\n    }\n\n    keyval_zone zone=one:32k state=one.keyval;\n    keyval $arg_text $text zone=one;\n\n    server {\n        listen 127.0.0.1;\n\n        location /api {\n            api write=on;\n            allow 127.0.0.1;\n            deny all;\n        }\n    }\n}\n\nstream {\n    upstream backend {\n        zone stream_backend 64k;\n\n        server backend1.example.com:12345 weight=5;\n        server backend2.example.com:12345;\n    }\n\n    server {\n        listen      127.0.0.1:12345;\n        proxy_pass  backend;\n        status_zone server_backend;\n        health_check;\n    }\n}\n

\nAll API requests include\na supported API version in the URI.\nExamples of API requests with this configuration:\n

\nhttp://127.0.0.1/api/9/\nhttp://127.0.0.1/api/9/nginx\nhttp://127.0.0.1/api/9/connections\nhttp://127.0.0.1/api/9/workers\nhttp://127.0.0.1/api/9/http/requests\nhttp://127.0.0.1/api/9/http/server_zones/server_backend\nhttp://127.0.0.1/api/9/http/caches/cache_backend\nhttp://127.0.0.1/api/9/http/upstreams/backend\nhttp://127.0.0.1/api/9/http/upstreams/backend/servers/\nhttp://127.0.0.1/api/9/http/upstreams/backend/servers/1\nhttp://127.0.0.1/api/9/http/keyvals/one?key=arg1\nhttp://127.0.0.1/api/9/stream/\nhttp://127.0.0.1/api/9/stream/server_zones/server_backend\nhttp://127.0.0.1/api/9/stream/upstreams/\nhttp://127.0.0.1/api/9/stream/upstreams/backend\nhttp://127.0.0.1/api/9/stream/upstreams/backend/servers/1\n

\n

\n\n\n

Directives

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n api \n[write=on|off];
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n location
\n

\nTurns on the REST API interface in the surrounding location.\nAccess to this location should be\nlimited.\n

\nThe write parameter determines whether the API\nis read-only or read-write.\nBy default, the API is read-only.\n

\nAll API requests should contain a supported API version in the URI.\nIf the request URI equals the location prefix,\nthe list of supported API versions is returned.\nThe current API version is “9”.\n

\nThe optional “fields” argument in the request line\nspecifies which fields of the requested objects will be output:\n

\nhttp://127.0.0.1/api/9/nginx?fields=version,build\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n status_zone zone;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n server, location, if in location
\n

This directive appeared in version 1.13.12.\n

\nEnables collection of virtual\nhttp\nor\nstream\nserver status information in the specified zone.\nSeveral servers may share the same zone.\n

\nStarting from 1.17.0, status information can be collected\nper location.\nThe special value off disables statistics collection\nin nested location blocks.\nNote that the statistics is collected\nin the context of a location where processing ends.\nIt may be different from the original location, if an\ninternal\nredirect happens during request processing.\n

\n\n

Compatibility

\n

\n

\n\n

Endpoints

\n

\n
\n/\n
\n
\n

Supported methods:

\n
    \n
  • \nGET - Return list of root endpoints\n

    Returns a list of root endpoints.

    \n

    \nPossible responses:\n

    \n
      \n
    • 200 - Success, returns an array of strings
    • \n
    • 404 - Unknown version (UnknownVersion), returns Error
    • \n
    \n
  • \n
\n
\n
\n/nginx\n
\n
\n

Supported methods:

\n
    \n
  • \nGET - Return status of nginx running instance\n

    Returns nginx version, build name, address, number of configuration reloads, IDs of master and worker processes.

    \n

    \nRequest parameters:\n

    \n
    fields\n(string, optional)
    \n
    \nLimits which fields of nginx running instance will be output.
    \n

    \n

    \n

    \nPossible responses:\n

    \n
      \n
    • 200 - Success, returns nginx
    • \n
    • 404 - Unknown version (UnknownVersion), returns Error
    • \n
    \n
  • \n
\n
\n
\n/processes\n
\n
\n

Supported methods:

\n
    \n
  • \nGET - Return nginx processes status\n

    Returns the number of abnormally terminated and respawned child processes.

    \n

    \nPossible responses:\n

    \n
      \n
    • 200 - Success, returns Processes
    • \n
    • 404 - Unknown version (UnknownVersion), returns Error
    • \n
    \n
  • \n
  • \nDELETE - Reset nginx processes statistics\n

    Resets counters of abnormally terminated and respawned child processes.

    \n

    \nPossible responses:\n

    \n
      \n
    • 204 - Success
    • \n
    • 404 - Unknown version (UnknownVersion), returns Error
    • \n
    • 405 - Method disabled (MethodDisabled), returns Error
    • \n
    \n
  • \n
\n
\n
\n/connections\n
\n
\n

Supported methods:

\n
    \n
  • \nGET - Return client connections statistics\n

    Returns statistics of client connections.

    \n

    \nRequest parameters:\n

    \n
    fields\n(string, optional)
    \n
    \nLimits which fields of the connections statistics will be output.
    \n

    \n

    \n

    \nPossible responses:\n

    \n
      \n
    • 200 - Success, returns Connections
    • \n
    • 404 - Unknown version (UnknownVersion), returns Error
    • \n
    \n
  • \n
  • \nDELETE - Reset client connections statistics\n

    Resets statistics of accepted and dropped client connections.

    \n

    \nPossible responses:\n

    \n
      \n
    • 204 - Success
    • \n
    • 404 - Unknown version (UnknownVersion), returns Error
    • \n
    • 405 - Method disabled (MethodDisabled), returns Error
    • \n
    \n
  • \n
\n
\n
\n/slabs/\n
\n
\n

Supported methods:

\n
    \n
  • \nGET - Return status of all slabs\n

    Returns status of slabs for each shared memory zone with slab allocator.

    \n

    \nRequest parameters:\n

    \n
    fields\n(string, optional)
    \n
    \nLimits which fields of slab zones will be output. If the “fields” value is empty, then only zone names will be output.
    \n

    \n

    \n

    \nPossible responses:\n

    \n\n
  • \n
\n
\n
\n/slabs/{slabZoneName}\n
\n
\nParameters common for all methods:\n
\n
slabZoneName\n(string, required)
\n
\nThe name of the shared memory zone with slab allocator.
\n
\n

Supported methods:

\n
    \n
  • \nGET - Return status of a slab\n

    Returns status of slabs for a particular shared memory zone with slab allocator.

    \n

    \nRequest parameters:\n

    \n
    fields\n(string, optional)
    \n
    \nLimits which fields of the slab zone will be output.
    \n

    \n

    \n

    \nPossible responses:\n

    \n\n
  • \n
  • \nDELETE - Reset slab statistics\n

    Resets the “reqs” and “fails” metrics for each memory slot.

    \n

    \nPossible responses:\n

    \n
      \n
    • 204 - Success
    • \n
    • 404 - Slab not found (SlabNotFound),\nunknown version (UnknownVersion), returns Error
    • \n
    • 405 - Method disabled (MethodDisabled), returns Error
    • \n
    \n
  • \n
\n
\n
\n/http/\n
\n
\n

Supported methods:

\n
    \n
  • \nGET - Return list of HTTP-related endpoints\n

    Returns a list of first level HTTP endpoints.

    \n

    \nPossible responses:\n

    \n
      \n
    • 200 - Success, returns an array of strings
    • \n
    • 404 - Unknown version (UnknownVersion), returns Error
    • \n
    \n
  • \n
\n
\n
\n/http/requests\n
\n
\n

Supported methods:

\n
    \n
  • \nGET - Return HTTP requests statistics\n

    Returns status of client HTTP requests.

    \n

    \nRequest parameters:\n

    \n
    fields\n(string, optional)
    \n
    \nLimits which fields of client HTTP requests statistics will be output.
    \n

    \n

    \n

    \nPossible responses:\n

    \n
      \n
    • 200 - Success, returns HTTP Requests
    • \n
    • 404 - Unknown version (UnknownVersion), returns Error
    • \n
    \n
  • \n
  • \nDELETE - Reset HTTP requests statistics\n

    Resets the number of total client HTTP requests.

    \n

    \nPossible responses:\n

    \n
      \n
    • 204 - Success
    • \n
    • 404 - Unknown version (UnknownVersion), returns Error
    • \n
    • 405 - Method disabled (MethodDisabled), returns Error
    • \n
    \n
  • \n
\n
\n
\n/http/server_zones/\n
\n
\n

Supported methods:

\n
    \n
  • \nGET - Return status of all HTTP server zones\n

    Returns status information for each HTTP server zone.

    \n

    \nRequest parameters:\n

    \n
    fields\n(string, optional)
    \n
    \nLimits which fields of server zones will be output. If the “fields” value is empty, then only server zone names will be output.
    \n

    \n

    \n

    \nPossible responses:\n

    \n
      \n
    • 200 - Success, returns a collection of \"HTTP Server Zone\" objects for all HTTP server zones
    • \n
    • 404 - Unknown version (UnknownVersion), returns Error
    • \n
    \n
  • \n
\n
\n
\n/http/server_zones/{httpServerZoneName}\n
\n
\nParameters common for all methods:\n
\n
httpServerZoneName\n(string, required)
\n
\nThe name of an HTTP server zone.
\n
\n

Supported methods:

\n
    \n
  • \nGET - Return status of an HTTP server zone\n

    Returns status of a particular HTTP server zone.

    \n

    \nRequest parameters:\n

    \n
    fields\n(string, optional)
    \n
    \nLimits which fields of the server zone will be output.
    \n

    \n

    \n

    \nPossible responses:\n

    \n
      \n
    • 200 - Success, returns HTTP Server Zone
    • \n
    • 404 - Server zone not found (ServerZoneNotFound),\nunknown version (UnknownVersion), returns Error
    • \n
    \n
  • \n
  • \nDELETE - Reset statistics for an HTTP server zone\n

    Resets statistics of accepted and discarded requests, responses, received and sent bytes, counters of SSL handshakes and session reuses in a particular HTTP server zone.

    \n

    \nPossible responses:\n

    \n
      \n
    • 204 - Success
    • \n
    • 404 - Server zone not found (ServerZoneNotFound),\nunknown version (UnknownVersion), returns Error
    • \n
    • 405 - Method disabled (MethodDisabled), returns Error
    • \n
    \n
  • \n
\n
\n
\n/http/location_zones/\n
\n
\n

Supported methods:

\n
    \n
  • \nGET - Return status of all HTTP location zones\n

    Returns status information for each HTTP location zone.

    \n

    \nRequest parameters:\n

    \n
    fields\n(string, optional)
    \n
    \nLimits which fields of location zones will be output. If the “fields” value is empty, then only zone names will be output.
    \n

    \n

    \n

    \nPossible responses:\n

    \n
      \n
    • 200 - Success, returns a collection of \"HTTP Location Zone\" objects for all HTTP location zones
    • \n
    • 404 - Unknown version (UnknownVersion), returns Error
    • \n
    \n
  • \n
\n
\n
\n/http/location_zones/{httpLocationZoneName}\n
\n
\nParameters common for all methods:\n
\n
httpLocationZoneName\n(string, required)
\n
\nThe name of an HTTP location zone.
\n
\n

Supported methods:

\n
    \n
  • \nGET - Return status of an HTTP location zone\n

    Returns status of a particular HTTP location zone.

    \n

    \nRequest parameters:\n

    \n
    fields\n(string, optional)
    \n
    \nLimits which fields of the location zone will be output.
    \n

    \n

    \n

    \nPossible responses:\n

    \n
      \n
    • 200 - Success, returns HTTP Location Zone
    • \n
    • 404 - Location zone not found (LocationZoneNotFound),\nunknown version (UnknownVersion), returns Error
    • \n
    \n
  • \n
  • \nDELETE - Reset statistics for a location zone.\n

    Resets statistics of accepted and discarded requests, responses, received and sent bytes in a particular location zone.

    \n

    \nPossible responses:\n

    \n
      \n
    • 204 - Success
    • \n
    • 404 - Location zone not found (LocationZoneNotFound),\nunknown version (UnknownVersion), returns Error
    • \n
    • 405 - Method disabled (MethodDisabled), returns Error
    • \n
    \n
  • \n
\n
\n
\n/http/caches/\n
\n
\n

Supported methods:

\n
    \n
  • \nGET - Return status of all caches\n

    Returns status of each cache configured by proxy_cache_path and other “*_cache_path” directives.

    \n

    \nRequest parameters:\n

    \n
    fields\n(string, optional)
    \n
    \nLimits which fields of cache zones will be output. If the “fields” value is empty, then only names of cache zones will be output.
    \n

    \n

    \n

    \nPossible responses:\n

    \n
      \n
    • 200 - Success, returns a collection of \"HTTP Cache\" objects for all HTTP caches
    • \n
    • 404 - Unknown version (UnknownVersion), returns Error
    • \n
    \n
  • \n
\n
\n
\n/http/caches/{httpCacheZoneName}\n
\n
\nParameters common for all methods:\n
\n
httpCacheZoneName\n(string, required)
\n
\nThe name of the cache zone.
\n
\n

Supported methods:

\n
    \n
  • \nGET - Return status of a cache\n

    Returns status of a particular cache.

    \n

    \nRequest parameters:\n

    \n
    fields\n(string, optional)
    \n
    \nLimits which fields of the cache zone will be output.
    \n

    \n

    \n

    \nPossible responses:\n

    \n
      \n
    • 200 - Success, returns HTTP Cache
    • \n
    • 404 - Cache not found (CacheNotFound),\nunknown version (UnknownVersion), returns Error
    • \n
    \n
  • \n
  • \nDELETE - Reset cache statistics\n

    Resets statistics of cache hits/misses in a particular cache zone.

    \n

    \nPossible responses:\n

    \n
      \n
    • 204 - Success
    • \n
    • 404 - Cache not found (CacheNotFound),\nunknown version (UnknownVersion), returns Error
    • \n
    • 405 - Method disabled (MethodDisabled), returns Error
    • \n
    \n
  • \n
\n
\n
\n/http/limit_conns/\n
\n
\n

Supported methods:

\n
    \n
  • \nGET - Return status of all HTTP limit_conn zones\n

    Returns status information for each HTTP limit_conn zone.

    \n

    \nRequest parameters:\n

    \n
    fields\n(string, optional)
    \n
    \nLimits which fields of limit_conn zones will be output. If the “fields” value is empty, then only zone names will be output.
    \n

    \n

    \n

    \nPossible responses:\n

    \n
      \n
    • 200 - Success, returns a collection of \"HTTP Connections Limiting\" objects for all HTTP limit conns
    • \n
    • 404 - Unknown version (UnknownVersion), returns Error
    • \n
    \n
  • \n
\n
\n
\n/http/limit_conns/{httpLimitConnZoneName}\n
\n
\nParameters common for all methods:\n
\n
httpLimitConnZoneName\n(string, required)
\n
\nThe name of a limit_conn zone.
\n
\n

Supported methods:

\n
    \n
  • \nGET - Return status of an HTTP limit_conn zone\n

    Returns status of a particular HTTP limit_conn zone.

    \n

    \nRequest parameters:\n

    \n
    fields\n(string, optional)
    \n
    \nLimits which fields of the limit_conn zone will be output.
    \n

    \n

    \n

    \nPossible responses:\n

    \n
      \n
    • 200 - Success, returns HTTP Connections Limiting
    • \n
    • 404 - limit_conn not found (LimitConnNotFound),\nunknown version (UnknownVersion), returns Error
    • \n
    \n
  • \n
  • \nDELETE - Reset statistics for an HTTP limit_conn zone\n

    Resets the connection limiting statistics.

    \n

    \nPossible responses:\n

    \n
      \n
    • 204 - Success
    • \n
    • 404 - limit_conn not found (LimitConnNotFound),\nunknown version (UnknownVersion), returns Error
    • \n
    • 405 - Method disabled (MethodDisabled), returns Error
    • \n
    \n
  • \n
\n
\n
\n/http/limit_reqs/\n
\n
\n

Supported methods:

\n
    \n
  • \nGET - Return status of all HTTP limit_req zones\n

    Returns status information for each HTTP limit_req zone.

    \n

    \nRequest parameters:\n

    \n
    fields\n(string, optional)
    \n
    \nLimits which fields of limit_req zones will be output. If the “fields” value is empty, then only zone names will be output.
    \n

    \n

    \n

    \nPossible responses:\n

    \n
      \n
    • 200 - Success, returns a collection of \"HTTP Requests Rate Limiting\" objects for all HTTP limit reqs
    • \n
    • 404 - Unknown version (UnknownVersion), returns Error
    • \n
    \n
  • \n
\n
\n
\n/http/limit_reqs/{httpLimitReqZoneName}\n
\n
\nParameters common for all methods:\n
\n
httpLimitReqZoneName\n(string, required)
\n
\nThe name of a limit_req zone.
\n
\n

Supported methods:

\n
    \n
  • \nGET - Return status of an HTTP limit_req zone\n

    Returns status of a particular HTTP limit_req zone.

    \n

    \nRequest parameters:\n

    \n
    fields\n(string, optional)
    \n
    \nLimits which fields of the limit_req zone will be output.
    \n

    \n

    \n

    \nPossible responses:\n

    \n\n
  • \n
  • \nDELETE - Reset statistics for an HTTP limit_req zone\n

    Resets the requests limiting statistics.

    \n

    \nPossible responses:\n

    \n
      \n
    • 204 - Success
    • \n
    • 404 - limit_req not found (LimitReqNotFound),\nunknown version (UnknownVersion), returns Error
    • \n
    • 405 - Method disabled (MethodDisabled), returns Error
    • \n
    \n
  • \n
\n
\n
\n/http/upstreams/\n
\n
\n

Supported methods:

\n
    \n
  • \nGET - Return status of all HTTP upstream server groups\n

    Returns status of each HTTP upstream server group and its servers.

    \n

    \nRequest parameters:\n

    \n
    fields\n(string, optional)
    \n
    \nLimits which fields of upstream server groups will be output. If the “fields” value is empty, only names of upstreams will be output.
    \n

    \n

    \n

    \nPossible responses:\n

    \n
      \n
    • 200 - Success, returns a collection of \"HTTP Upstream\" objects for all HTTP upstreams
    • \n
    • 404 - Unknown version (UnknownVersion), returns Error
    • \n
    \n
  • \n
\n
\n
\n/http/upstreams/{httpUpstreamName}/\n
\n
\nParameters common for all methods:\n
\n
httpUpstreamName\n(string, required)
\n
\nThe name of an HTTP upstream server group.
\n
\n

Supported methods:

\n
    \n
  • \nGET - Return status of an HTTP upstream server group\n

    Returns status of a particular HTTP upstream server group and its servers.

    \n

    \nRequest parameters:\n

    \n
    fields\n(string, optional)
    \n
    \nLimits which fields of the upstream server group will be output.
    \n

    \n

    \n

    \nPossible responses:\n

    \n
      \n
    • 200 - Success, returns HTTP Upstream
    • \n
    • 400 - Upstream is static (UpstreamStatic), returns Error
    • \n
    • 404 - Unknown version (UnknownVersion),\nupstream not found (UpstreamNotFound), returns Error
    • \n
    \n
  • \n
  • \nDELETE - Reset statistics of an HTTP upstream server group\n

    Resets the statistics for each upstream server in an upstream server group and queue statistics.

    \n

    \nPossible responses:\n

    \n
      \n
    • 204 - Success
    • \n
    • 400 - Upstream is static (UpstreamStatic), returns Error
    • \n
    • 404 - Unknown version (UnknownVersion),\nupstream not found (UpstreamNotFound), returns Error
    • \n
    • 405 - Method disabled (MethodDisabled), returns Error
    • \n
    \n
  • \n
\n
\n
\n/http/upstreams/{httpUpstreamName}/servers/\n
\n
\nParameters common for all methods:\n
\n
httpUpstreamName\n(string, required)
\n
\nThe name of an upstream server group.
\n
\n

Supported methods:

\n
    \n
  • \nGET - Return configuration of all servers in an HTTP upstream server group\n

    Returns configuration of each server in a particular HTTP upstream server group.

    \n

    \nPossible responses:\n

    \n
      \n
    • 200 - Success, returns an array of HTTP Upstream Servers
    • \n
    • 400 - Upstream is static (UpstreamStatic), returns Error
    • \n
    • 404 - Unknown version (UnknownVersion),\nupstream not found (UpstreamNotFound), returns Error
    • \n
    \n
  • \n
  • \nPOST - Add a server to an HTTP upstream server group\n

    Adds a new server to an HTTP upstream server group. Server parameters are specified in the JSON format.

    \n

    \nRequest parameters:\n

    \n
    postHttpUpstreamServer\n(HTTP Upstream Server, required)
    \n
    \nAddress of a new server and other optional parameters in the JSON format. The “ID”, “backup”, and “service” parameters cannot be changed.
    \n

    \n

    \n

    \nPossible responses:\n

    \n
      \n
    • 201 - Created, returns HTTP Upstream Server
    • \n
    • 400 - Upstream is static (UpstreamStatic),\ninvalid “parameter” value (UpstreamConfFormatError),\nmissing “server” argument (UpstreamConfFormatError),\nunknown parameter “name” (UpstreamConfFormatError),\nnested object or list (UpstreamConfFormatError),\n“error” while parsing (UpstreamBadAddress),\nservice upstream “host” may not have port (UpstreamBadAddress),\nservice upstream “host” requires domain name (UpstreamBadAddress),\ninvalid “weight” (UpstreamBadWeight),\ninvalid “max_conns” (UpstreamBadMaxConns),\ninvalid “max_fails” (UpstreamBadMaxFails),\ninvalid “fail_timeout” (UpstreamBadFailTimeout),\ninvalid “slow_start” (UpstreamBadSlowStart),\nreading request body failed BodyReadError),\nroute is too long (UpstreamBadRoute),\n“service” is empty (UpstreamBadService),\nno resolver defined to resolve (UpstreamConfNoResolver),\nupstream “name” has no backup (UpstreamNoBackup),\nupstream “name” memory exhausted (UpstreamOutOfMemory), returns Error
    • \n
    • 404 - Unknown version (UnknownVersion),\nupstream not found (UpstreamNotFound), returns Error
    • \n
    • 405 - Method disabled (MethodDisabled), returns Error
    • \n
    • 409 - Entry exists (EntryExists), returns Error
    • \n
    • 415 - JSON error (JsonError), returns Error
    • \n
    \n
  • \n
\n
\n
\n/http/upstreams/{httpUpstreamName}/servers/{httpUpstreamServerId}\n
\n
\nParameters common for all methods:\n
\n
httpUpstreamName\n(string, required)
\n
\nThe name of the upstream server group.
\n
httpUpstreamServerId\n(string, required)
\n
\nThe ID of the server.
\n
\n

Supported methods:

\n
    \n
  • \nGET - Return configuration of a server in an HTTP upstream server group\n

    Returns configuration of a particular server in the HTTP upstream server group.

    \n

    \nPossible responses:\n

    \n
      \n
    • 200 - Success, returns HTTP Upstream Server
    • \n
    • 400 - Upstream is static (UpstreamStatic),\ninvalid server ID (UpstreamBadServerId), returns Error
    • \n
    • 404 - Server with ID “id” does not exist (UpstreamServerNotFound),\nunknown version (UnknownVersion),\nupstream not found (UpstreamNotFound), returns Error
    • \n
    \n
  • \n
  • \nPATCH - Modify a server in an HTTP upstream server group\n

    Modifies settings of a particular server in an HTTP upstream server group. Server parameters are specified in the JSON format.

    \n

    \nRequest parameters:\n

    \n
    patchHttpUpstreamServer\n(HTTP Upstream Server, required)
    \n
    \nServer parameters, specified in the JSON format. The “ID”, “backup”, and “service” parameters cannot be changed.
    \n

    \n

    \n

    \nPossible responses:\n

    \n
      \n
    • 200 - Success, returns HTTP Upstream Server
    • \n
    • 400 - Upstream is static (UpstreamStatic),\ninvalid “parameter” value (UpstreamConfFormatError),\nunknown parameter “name” (UpstreamConfFormatError),\nnested object or list (UpstreamConfFormatError),\n“error” while parsing (UpstreamBadAddress),\ninvalid “server” argument (UpstreamBadAddress),\ninvalid server ID (UpstreamBadServerId),\ninvalid “weight” (UpstreamBadWeight),\ninvalid “max_conns” (UpstreamBadMaxConns),\ninvalid “max_fails” (UpstreamBadMaxFails),\ninvalid “fail_timeout” (UpstreamBadFailTimeout),\ninvalid “slow_start” (UpstreamBadSlowStart),\nreading request body failed BodyReadError),\nroute is too long (UpstreamBadRoute),\n“service” is empty (UpstreamBadService),\nserver “ID” address is immutable (UpstreamServerImmutable),\nserver “ID” weight is immutable (UpstreamServerWeightImmutable),\nupstream “name” memory exhausted (UpstreamOutOfMemory), returns Error
    • \n
    • 404 - Server with ID “id” does not exist (UpstreamServerNotFound),\nunknown version (UnknownVersion),\nupstream not found (UpstreamNotFound), returns Error
    • \n
    • 405 - Method disabled (MethodDisabled), returns Error
    • \n
    • 415 - JSON error (JsonError), returns Error
    • \n
    \n
  • \n
  • \nDELETE - Remove a server from an HTTP upstream server group\n

    Removes a server from an HTTP upstream server group.

    \n

    \nPossible responses:\n

    \n
      \n
    • 200 - Success, returns an array of HTTP Upstream Servers
    • \n
    • 400 - Upstream is static (UpstreamStatic),\ninvalid server ID (UpstreamBadServerId),\nserver “id” not removable (UpstreamServerImmutable), returns Error
    • \n
    • 404 - Server with ID “id” does not exist (UpstreamServerNotFound),\nunknown version (UnknownVersion),\nupstream not found (UpstreamNotFound), returns Error
    • \n
    • 405 - Method disabled (MethodDisabled), returns Error
    • \n
    \n
  • \n
\n
\n
\n/http/keyvals/\n
\n
\n

Supported methods:

\n
    \n
  • \nGET - Return key-value pairs from all HTTP keyval zones\n

    Returns key-value pairs for each HTTP keyval shared memory zone.

    \n

    \nRequest parameters:\n

    \n
    fields\n(string, optional)
    \n
    \nIf the “fields” value is empty, then only HTTP keyval zone names will be output.
    \n

    \n

    \n

    \nPossible responses:\n

    \n\n
  • \n
\n
\n
\n/http/keyvals/{httpKeyvalZoneName}\n
\n
\nParameters common for all methods:\n
\n
httpKeyvalZoneName\n(string, required)
\n
\nThe name of an HTTP keyval shared memory zone.
\n
\n

Supported methods:

\n
    \n
  • \nGET - Return key-value pairs from an HTTP keyval zone\n

    Returns key-value pairs stored in a particular HTTP keyval shared memory zone.

    \n

    \nRequest parameters:\n

    \n
    key\n(string, optional)
    \n
    \nGet a particular key-value pair from the HTTP keyval zone.
    \n

    \n

    \n

    \nPossible responses:\n

    \n
      \n
    • 200 - Success, returns HTTP Keyval Shared Memory Zone
    • \n
    • 404 - Keyval not found (KeyvalNotFound),\nkeyval key not found (KeyvalKeyNotFound),\nunknown version (UnknownVersion), returns Error
    • \n
    \n
  • \n
  • \nPOST - Add a key-value pair to the HTTP keyval zone\n

    Adds a new key-value pair to the HTTP keyval shared memory zone. Several key-value pairs can be entered if the HTTP keyval shared memory zone is empty.

    \n

    \nRequest parameters:\n

    \n
    Key-value\n(HTTP Keyval Shared Memory Zone, required)
    \n
    \nA key-value pair is specified in the JSON format. Several key-value pairs can be entered if the HTTP keyval shared memory zone is empty. Expiration time in milliseconds can be specified for a key-value pair with the expire parameter which overrides the timeout parameter of the keyval_zone directive.
    \n

    \n

    \n

    \nPossible responses:\n

    \n
      \n
    • 201 - Created
    • \n
    • 400 - Invalid JSON (KeyvalFormatError),\ninvalid key format (KeyvalFormatError),\nkey required (KeyvalFormatError),\nkeyval timeout is not enabled (KeyvalFormatError),\nonly one key can be added (KeyvalFormatError),\nreading request body failed BodyReadError), returns Error
    • \n
    • 404 - Keyval not found (KeyvalNotFound),\nunknown version (UnknownVersion), returns Error
    • \n
    • 405 - Method disabled (MethodDisabled), returns Error
    • \n
    • 409 - Entry exists (EntryExists),\nkey already exists (KeyvalKeyExists), returns Error
    • \n
    • 413 - Request Entity Too Large, returns Error
    • \n
    • 415 - JSON error (JsonError), returns Error
    • \n
    \n
  • \n
  • \nPATCH - Modify a key-value or delete a key\n

    Changes the value of the selected key in the key-value pair, deletes a key by setting the key value to null, changes expiration time of a key-value pair. If synchronization of keyval zones in a cluster is enabled, deletes a key only on a target cluster node. Expiration time in milliseconds can be specified for a key-value pair with the expire parameter which overrides the timeout parameter of the keyval_zone directive.

    \n

    \nRequest parameters:\n

    \n
    httpKeyvalZoneKeyValue\n(HTTP Keyval Shared Memory Zone, required)
    \n
    \nA new value for the key is specified in the JSON format.
    \n

    \n

    \n

    \nPossible responses:\n

    \n
      \n
    • 204 - Success
    • \n
    • 400 - Invalid JSON (KeyvalFormatError),\nkey required (KeyvalFormatError),\nkeyval timeout is not enabled (KeyvalFormatError),\nonly one key can be updated (KeyvalFormatError),\nreading request body failed BodyReadError), returns Error
    • \n
    • 404 - Keyval not found (KeyvalNotFound),\nkeyval key not found (KeyvalKeyNotFound),\nunknown version (UnknownVersion), returns Error
    • \n
    • 405 - Method disabled (MethodDisabled), returns Error
    • \n
    • 413 - Request Entity Too Large, returns Error
    • \n
    • 415 - JSON error (JsonError), returns Error
    • \n
    \n
  • \n
  • \nDELETE - Empty the HTTP keyval zone\n

    Deletes all key-value pairs from the HTTP keyval shared memory zone. If synchronization of keyval zones in a cluster is enabled, empties the keyval zone only on a target cluster node.

    \n

    \nPossible responses:\n

    \n
      \n
    • 204 - Success
    • \n
    • 404 - Keyval not found (KeyvalNotFound),\nunknown version (UnknownVersion), returns Error
    • \n
    • 405 - Method disabled (MethodDisabled), returns Error
    • \n
    \n
  • \n
\n
\n
\n/stream/\n
\n
\n

Supported methods:

\n
    \n
  • \nGET - Return list of stream-related endpoints\n

    Returns a list of first level stream endpoints.

    \n

    \nPossible responses:\n

    \n
      \n
    • 200 - Success, returns an array of strings
    • \n
    • 404 - Unknown version (UnknownVersion), returns Error
    • \n
    \n
  • \n
\n
\n
\n/stream/server_zones/\n
\n
\n

Supported methods:

\n
    \n
  • \nGET - Return status of all stream server zones\n

    Returns status information for each stream server zone.

    \n

    \nRequest parameters:\n

    \n
    fields\n(string, optional)
    \n
    \nLimits which fields of server zones will be output. If the “fields” value is empty, then only server zone names will be output.
    \n

    \n

    \n

    \nPossible responses:\n

    \n
      \n
    • 200 - Success, returns a collection of \"Stream Server Zone\" objects for all stream server zones
    • \n
    • 404 - Unknown version (UnknownVersion), returns Error
    • \n
    \n
  • \n
\n
\n
\n/stream/server_zones/{streamServerZoneName}\n
\n
\nParameters common for all methods:\n
\n
streamServerZoneName\n(string, required)
\n
\nThe name of a stream server zone.
\n
\n

Supported methods:

\n
    \n
  • \nGET - Return status of a stream server zone\n

    Returns status of a particular stream server zone.

    \n

    \nRequest parameters:\n

    \n
    fields\n(string, optional)
    \n
    \nLimits which fields of the server zone will be output.
    \n

    \n

    \n

    \nPossible responses:\n

    \n
      \n
    • 200 - Success, returns Stream Server Zone
    • \n
    • 404 - Server zone not found (ServerZoneNotFound),\nunknown version (UnknownVersion), returns Error
    • \n
    \n
  • \n
  • \nDELETE - Reset statistics for a stream server zone\n

    Resets statistics of accepted and discarded connections, sessions, received and sent bytes, counters of SSL handshakes and session reuses in a particular stream server zone.

    \n

    \nPossible responses:\n

    \n
      \n
    • 204 - Success
    • \n
    • 404 - Server zone not found (ServerZoneNotFound),\nunknown version (UnknownVersion), returns Error
    • \n
    • 405 - Method disabled (MethodDisabled), returns Error
    • \n
    \n
  • \n
\n
\n
\n/stream/limit_conns/\n
\n
\n

Supported methods:

\n
    \n
  • \nGET - Return status of all stream limit_conn zones\n

    Returns status information for each stream limit_conn zone.

    \n

    \nRequest parameters:\n

    \n
    fields\n(string, optional)
    \n
    \nLimits which fields of limit_conn zones will be output. If the “fields” value is empty, then only zone names will be output.
    \n

    \n

    \n

    \nPossible responses:\n

    \n
      \n
    • 200 - Success, returns a collection of \"Stream Connections Limiting\" objects for all stream limit conns
    • \n
    • 404 - Unknown version (UnknownVersion), returns Error
    • \n
    \n
  • \n
\n
\n
\n/stream/limit_conns/{streamLimitConnZoneName}\n
\n
\nParameters common for all methods:\n
\n
streamLimitConnZoneName\n(string, required)
\n
\nThe name of a limit_conn zone.
\n
\n

Supported methods:

\n
    \n
  • \nGET - Return status of an stream limit_conn zone\n

    Returns status of a particular stream limit_conn zone.

    \n

    \nRequest parameters:\n

    \n
    fields\n(string, optional)
    \n
    \nLimits which fields of the limit_conn zone will be output.
    \n

    \n

    \n

    \nPossible responses:\n

    \n\n
  • \n
  • \nDELETE - Reset statistics for a stream limit_conn zone\n

    Resets the connection limiting statistics.

    \n

    \nPossible responses:\n

    \n
      \n
    • 204 - Success
    • \n
    • 404 - limit_conn not found (LimitConnNotFound),\nunknown version (UnknownVersion), returns Error
    • \n
    • 405 - Method disabled (MethodDisabled), returns Error
    • \n
    \n
  • \n
\n
\n
\n/stream/upstreams/\n
\n
\n

Supported methods:

\n
    \n
  • \nGET - Return status of all stream upstream server groups\n

    Returns status of each stream upstream server group and its servers.

    \n

    \nRequest parameters:\n

    \n
    fields\n(string, optional)
    \n
    \nLimits which fields of upstream server groups will be output. If the “fields” value is empty, only names of upstreams will be output.
    \n

    \n

    \n

    \nPossible responses:\n

    \n
      \n
    • 200 - Success, returns a collection of \"Stream Upstream\" objects for all stream upstreams
    • \n
    • 404 - Unknown version (UnknownVersion), returns Error
    • \n
    \n
  • \n
\n
\n
\n/stream/upstreams/{streamUpstreamName}/\n
\n
\nParameters common for all methods:\n
\n
streamUpstreamName\n(string, required)
\n
\nThe name of a stream upstream server group.
\n
\n

Supported methods:

\n
    \n
  • \nGET - Return status of a stream upstream server group\n

    Returns status of a particular stream upstream server group and its servers.

    \n

    \nRequest parameters:\n

    \n
    fields\n(string, optional)
    \n
    \nLimits which fields of the upstream server group will be output.
    \n

    \n

    \n

    \nPossible responses:\n

    \n
      \n
    • 200 - Success, returns Stream Upstream
    • \n
    • 400 - Upstream is static (UpstreamStatic), returns Error
    • \n
    • 404 - Unknown version (UnknownVersion),\nupstream not found (UpstreamNotFound), returns Error
    • \n
    \n
  • \n
  • \nDELETE - Reset statistics of a stream upstream server group\n

    Resets the statistics for each upstream server in an upstream server group.

    \n

    \nPossible responses:\n

    \n
      \n
    • 204 - Success
    • \n
    • 400 - Upstream is static (UpstreamStatic), returns Error
    • \n
    • 404 - Unknown version (UnknownVersion),\nupstream not found (UpstreamNotFound), returns Error
    • \n
    • 405 - Method disabled (MethodDisabled), returns Error
    • \n
    \n
  • \n
\n
\n
\n/stream/upstreams/{streamUpstreamName}/servers/\n
\n
\nParameters common for all methods:\n
\n
streamUpstreamName\n(string, required)
\n
\nThe name of an upstream server group.
\n
\n

Supported methods:

\n
    \n
  • \nGET - Return configuration of all servers in a stream upstream server group\n

    Returns configuration of each server in a particular stream upstream server group.

    \n

    \nPossible responses:\n

    \n
      \n
    • 200 - Success, returns an array of Stream Upstream Servers
    • \n
    • 400 - Upstream is static (UpstreamStatic), returns Error
    • \n
    • 404 - Unknown version (UnknownVersion),\nupstream not found (UpstreamNotFound), returns Error
    • \n
    \n
  • \n
  • \nPOST - Add a server to a stream upstream server group\n

    Adds a new server to a stream upstream server group. Server parameters are specified in the JSON format.

    \n

    \nRequest parameters:\n

    \n
    postStreamUpstreamServer\n(Stream Upstream Server, required)
    \n
    \nAddress of a new server and other optional parameters in the JSON format. The “ID”, “backup”, and “service” parameters cannot be changed.
    \n

    \n

    \n

    \nPossible responses:\n

    \n
      \n
    • 201 - Created, returns Stream Upstream Server
    • \n
    • 400 - Upstream is static (UpstreamStatic),\ninvalid “parameter” value (UpstreamConfFormatError),\nmissing “server” argument (UpstreamConfFormatError),\nunknown parameter “name” (UpstreamConfFormatError),\nnested object or list (UpstreamConfFormatError),\n“error” while parsing (UpstreamBadAddress),\nno port in server “host” (UpstreamBadAddress),\nservice upstream “host” may not have port (UpstreamBadAddress),\nservice upstream “host” requires domain name (UpstreamBadAddress),\ninvalid “weight” (UpstreamBadWeight),\ninvalid “max_conns” (UpstreamBadMaxConns),\ninvalid “max_fails” (UpstreamBadMaxFails),\ninvalid “fail_timeout” (UpstreamBadFailTimeout),\ninvalid “slow_start” (UpstreamBadSlowStart),\n“service” is empty (UpstreamBadService),\nno resolver defined to resolve (UpstreamConfNoResolver),\nupstream “name” has no backup (UpstreamNoBackup),\nupstream “name” memory exhausted (UpstreamOutOfMemory),\nreading request body failed BodyReadError), returns Error
    • \n
    • 404 - Unknown version (UnknownVersion),\nupstream not found (UpstreamNotFound), returns Error
    • \n
    • 405 - Method disabled (MethodDisabled), returns Error
    • \n
    • 409 - Entry exists (EntryExists), returns Error
    • \n
    • 415 - JSON error (JsonError), returns Error
    • \n
    \n
  • \n
\n
\n
\n/stream/upstreams/{streamUpstreamName}/servers/{streamUpstreamServerId}\n
\n
\nParameters common for all methods:\n
\n
streamUpstreamName\n(string, required)
\n
\nThe name of the upstream server group.
\n
streamUpstreamServerId\n(string, required)
\n
\nThe ID of the server.
\n
\n

Supported methods:

\n
    \n
  • \nGET - Return configuration of a server in a stream upstream server group\n

    Returns configuration of a particular server in the stream upstream server group.

    \n

    \nPossible responses:\n

    \n
      \n
    • 200 - Success, returns Stream Upstream Server
    • \n
    • 400 - Upstream is static (UpstreamStatic),\ninvalid server ID (UpstreamBadServerId), returns Error
    • \n
    • 404 - Unknown version (UnknownVersion),\nupstream not found (UpstreamNotFound),\nserver with ID “id” does not exist (UpstreamServerNotFound), returns Error
    • \n
    \n
  • \n
  • \nPATCH - Modify a server in a stream upstream server group\n

    Modifies settings of a particular server in a stream upstream server group. Server parameters are specified in the JSON format.

    \n

    \nRequest parameters:\n

    \n
    patchStreamUpstreamServer\n(Stream Upstream Server, required)
    \n
    \nServer parameters, specified in the JSON format. The “ID”, “backup”, and “service” parameters cannot be changed.
    \n

    \n

    \n

    \nPossible responses:\n

    \n
      \n
    • 200 - Success, returns Stream Upstream Server
    • \n
    • 400 - Upstream is static (UpstreamStatic),\ninvalid “parameter” value (UpstreamConfFormatError),\nunknown parameter “name” (UpstreamConfFormatError),\nnested object or list (UpstreamConfFormatError),\n“error” while parsing (UpstreamBadAddress),\ninvalid “server” argument (UpstreamBadAddress),\nno port in server “host” (UpstreamBadAddress),\ninvalid server ID (UpstreamBadServerId),\ninvalid “weight” (UpstreamBadWeight),\ninvalid “max_conns” (UpstreamBadMaxConns),\ninvalid “max_fails” (UpstreamBadMaxFails),\ninvalid “fail_timeout” (UpstreamBadFailTimeout),\ninvalid “slow_start” (UpstreamBadSlowStart),\nreading request body failed BodyReadError),\n“service” is empty (UpstreamBadService),\nserver “ID” address is immutable (UpstreamServerImmutable),\nserver “ID” weight is immutable (UpstreamServerWeightImmutable),\nupstream “name” memory exhausted (UpstreamOutOfMemory), returns Error
    • \n
    • 404 - Server with ID “id” does not exist (UpstreamServerNotFound),\nunknown version (UnknownVersion),\nupstream not found (UpstreamNotFound), returns Error
    • \n
    • 405 - Method disabled (MethodDisabled), returns Error
    • \n
    • 415 - JSON error (JsonError), returns Error
    • \n
    \n
  • \n
  • \nDELETE - Remove a server from a stream upstream server group\n

    Removes a server from a stream server group.

    \n

    \nPossible responses:\n

    \n
      \n
    • 200 - Success, returns an array of Stream Upstream Servers
    • \n
    • 400 - Upstream is static (UpstreamStatic),\ninvalid server ID (UpstreamBadServerId),\nserver “id” not removable (UpstreamServerImmutable), returns Error
    • \n
    • 404 - Server with ID “id” does not exist (UpstreamServerNotFound),\nunknown version (UnknownVersion),\nupstream not found (UpstreamNotFound), returns Error
    • \n
    • 405 - Method disabled (MethodDisabled), returns Error
    • \n
    \n
  • \n
\n
\n
\n/stream/keyvals/\n
\n
\n

Supported methods:

\n
    \n
  • \nGET - Return key-value pairs from all stream keyval zones\n

    Returns key-value pairs for each stream keyval shared memory zone.

    \n

    \nRequest parameters:\n

    \n
    fields\n(string, optional)
    \n
    \nIf the “fields” value is empty, then only stream keyval zone names will be output.
    \n

    \n

    \n

    \nPossible responses:\n

    \n\n
  • \n
\n
\n
\n/stream/keyvals/{streamKeyvalZoneName}\n
\n
\nParameters common for all methods:\n
\n
streamKeyvalZoneName\n(string, required)
\n
\nThe name of a stream keyval shared memory zone.
\n
\n

Supported methods:

\n
    \n
  • \nGET - Return key-value pairs from a stream keyval zone\n

    Returns key-value pairs stored in a particular stream keyval shared memory zone.

    \n

    \nRequest parameters:\n

    \n
    key\n(string, optional)
    \n
    \nGet a particular key-value pair from the stream keyval zone.
    \n

    \n

    \n

    \nPossible responses:\n

    \n
      \n
    • 200 - Success, returns Stream Keyval Shared Memory Zone
    • \n
    • 404 - Keyval not found (KeyvalNotFound),\nkeyval key not found (KeyvalKeyNotFound),\nunknown version (UnknownVersion), returns Error
    • \n
    \n
  • \n
  • \nPOST - Add a key-value pair to the stream keyval zone\n

    Adds a new key-value pair to the stream keyval shared memory zone. Several key-value pairs can be entered if the stream keyval shared memory zone is empty.

    \n

    \nRequest parameters:\n

    \n
    Key-value\n(Stream Keyval Shared Memory Zone, required)
    \n
    \nA key-value pair is specified in the JSON format. Several key-value pairs can be entered if the stream keyval shared memory zone is empty. Expiration time in milliseconds can be specified for a key-value pair with the expire parameter which overrides the timeout parameter of the keyval_zone directive.
    \n

    \n

    \n

    \nPossible responses:\n

    \n
      \n
    • 201 - Created
    • \n
    • 400 - Invalid JSON (KeyvalFormatError),\ninvalid key format (KeyvalFormatError),\nkey required (KeyvalFormatError),\nkeyval timeout is not enabled (KeyvalFormatError),\nonly one key can be added (KeyvalFormatError),\nreading request body failed BodyReadError), returns Error
    • \n
    • 404 - Keyval not found (KeyvalNotFound),\nunknown version (UnknownVersion), returns Error
    • \n
    • 405 - Method disabled (MethodDisabled), returns Error
    • \n
    • 409 - Entry exists (EntryExists),\nkey already exists (KeyvalKeyExists), returns Error
    • \n
    • 413 - Request Entity Too Large, returns Error
    • \n
    • 415 - JSON error (JsonError), returns Error
    • \n
    \n
  • \n
  • \nPATCH - Modify a key-value or delete a key\n

    Changes the value of the selected key in the key-value pair, deletes a key by setting the key value to null, changes expiration time of a key-value pair. If synchronization of keyval zones in a cluster is enabled, deletes a key only on a target cluster node. Expiration time is specified in milliseconds with the expire parameter which overrides the timeout parameter of the keyval_zone directive.

    \n

    \nRequest parameters:\n

    \n
    streamKeyvalZoneKeyValue\n(Stream Keyval Shared Memory Zone, required)
    \n
    \nA new value for the key is specified in the JSON format.
    \n

    \n

    \n

    \nPossible responses:\n

    \n
      \n
    • 204 - Success
    • \n
    • 400 - Invalid JSON (KeyvalFormatError),\nkey required (KeyvalFormatError),\nkeyval timeout is not enabled (KeyvalFormatError),\nonly one key can be updated (KeyvalFormatError),\nreading request body failed BodyReadError), returns Error
    • \n
    • 404 - Keyval not found (KeyvalNotFound),\nkeyval key not found (KeyvalKeyNotFound),\nunknown version (UnknownVersion), returns Error
    • \n
    • 405 - Method disabled (MethodDisabled), returns Error
    • \n
    • 413 - Request Entity Too Large, returns Error
    • \n
    • 415 - JSON error (JsonError), returns Error
    • \n
    \n
  • \n
  • \nDELETE - Empty the stream keyval zone\n

    Deletes all key-value pairs from the stream keyval shared memory zone. If synchronization of keyval zones in a cluster is enabled, empties the keyval zone only on a target cluster node.

    \n

    \nPossible responses:\n

    \n
      \n
    • 204 - Success
    • \n
    • 404 - Keyval not found (KeyvalNotFound),\nunknown version (UnknownVersion), returns Error
    • \n
    • 405 - Method disabled (MethodDisabled), returns Error
    • \n
    \n
  • \n
\n
\n
\n/stream/zone_sync/\n
\n
\n

Supported methods:

\n
    \n
  • \nGET - Return sync status of a node\n

    Returns synchronization status of a cluster node.

    \n

    \nPossible responses:\n

    \n\n
  • \n
\n
\n
\n/resolvers/\n
\n
\n

Supported methods:

\n
    \n
  • \nGET - Return status for all resolver zones\n

    Returns status information for each resolver zone.

    \n

    \nRequest parameters:\n

    \n
    fields\n(string, optional)
    \n
    \nLimits which fields of resolvers statistics will be output.
    \n

    \n

    \n

    \nPossible responses:\n

    \n
      \n
    • 200 - Success, returns a collection of \"Resolver Zone\" objects for all resolvers
    • \n
    • 404 - Unknown version (UnknownVersion), returns Error
    • \n
    \n
  • \n
\n
\n
\n/resolvers/{resolverZoneName}\n
\n
\nParameters common for all methods:\n
\n
resolverZoneName\n(string, required)
\n
\nThe name of a resolver zone.
\n
\n

Supported methods:

\n
    \n
  • \nGET - Return statistics of a resolver zone\n

    Returns statistics stored in a particular resolver zone.

    \n

    \nRequest parameters:\n

    \n
    fields\n(string, optional)
    \n
    \nLimits which fields of the resolver zone will be output (requests, responses, or both).
    \n

    \n

    \n

    \nPossible responses:\n

    \n
      \n
    • 200 - Success, returns Resolver Zone
    • \n
    • 404 - Resolver zone not found (ResolverZoneNotFound),\nunknown version (UnknownVersion), returns Error
    • \n
    \n
  • \n
  • \nDELETE - Reset statistics for a resolver zone.\n

    Resets statistics in a particular resolver zone.

    \n

    \nPossible responses:\n

    \n
      \n
    • 204 - Success
    • \n
    • 404 - Resolver zone not found (ResolverZoneNotFound),\nunknown version (UnknownVersion), returns Error
    • \n
    • 405 - Method disabled (MethodDisabled), returns Error
    • \n
    \n
  • \n
\n
\n
\n/ssl\n
\n
\n

Supported methods:

\n
    \n
  • \nGET - Return SSL statistics\n

    Returns SSL statistics.

    \n

    \nRequest parameters:\n

    \n
    fields\n(string, optional)
    \n
    \nLimits which fields of SSL statistics will be output.
    \n

    \n

    \n

    \nPossible responses:\n

    \n
      \n
    • 200 - Success, returns SSL
    • \n
    • 404 - Unknown version (UnknownVersion), returns Error
    • \n
    \n
  • \n
  • \nDELETE - Reset SSL statistics\n

    Resets counters of SSL handshakes and session reuses.

    \n

    \nPossible responses:\n

    \n
      \n
    • 204 - Success
    • \n
    • 404 - Unknown version (UnknownVersion), returns Error
    • \n
    • 405 - Method disabled (MethodDisabled), returns Error
    • \n
    \n
  • \n
\n
\n
\n/license\n
\n
\n

Supported methods:

\n
    \n
  • \nGET - Return license info\n

    \n

    \nPossible responses:\n

    \n
      \n
    • 200 - Success, returns License
    • \n
    • 404 - Unknown version (UnknownVersion), returns Error
    • \n
    \n
  • \n
\n
\n
\n/workers/\n
\n
\n

Supported methods:

\n
    \n
  • \nGET - Return statistics for all worker processes\n

    Returns statistics for all worker processes such as accepted, dropped, active, idle connections, total and current requests.

    \n

    \nRequest parameters:\n

    \n
    fields\n(string, optional)
    \n
    \nLimits which fields of worker process statistics will be output.
    \n

    \n

    \n

    \nPossible responses:\n

    \n
      \n
    • 200 - Success, returns a collection of \"Worker process\" objects for all workers
    • \n
    • 404 - Worker not found (WorkerNotFound),\nunknown version (UnknownVersion), returns Error
    • \n
    \n
  • \n
  • \nDELETE - Reset statistics for all worker processes.\n

    Resets statistics for all worker processes such as\naccepted, dropped, active, idle connections, total and current requests.

    \n

    \nPossible responses:\n

    \n
      \n
    • 204 - Success
    • \n
    • 404 - Worker not found (WorkerNotFound),\nunknown version (UnknownVersion), returns Error
    • \n
    • 405 - Method disabled (MethodDisabled), returns Error
    • \n
    \n
  • \n
\n
\n
\n/workers/{workerId}\n
\n
\nParameters common for all methods:\n
\n
workerId\n(string, required)
\n
\nThe ID of the worker process.
\n
\n

Supported methods:

\n
    \n
  • \nGET - Return status of a worker process\n

    Returns status of a particular worker process.

    \n

    \nRequest parameters:\n

    \n
    fields\n(string, optional)
    \n
    \nLimits which fields of worker process statistics will be output.
    \n

    \n

    \n

    \nPossible responses:\n

    \n
      \n
    • 200 - Success, returns Worker process
    • \n
    • 404 - Worker not found (WorkerNotFound),\nunknown version (UnknownVersion), returns Error
    • \n
    \n
  • \n
  • \nDELETE - Reset statistics for a worker process.\n

    Resets statistics of accepted, dropped, active, idle connections,\nas well as total and current requests.

    \n

    \nPossible responses:\n

    \n
      \n
    • 204 - Success
    • \n
    • 404 - Worker not found (WorkerNotFound),\nunknown version (UnknownVersion), returns Error
    • \n
    • 405 - Method disabled (MethodDisabled), returns Error
    • \n
    \n
  • \n
\n
\n

\n

\n

Response Objects

\n

\n

\n\n
\n", "encoding": "utf-8"} +{"path": "en\\docs\\http\\ngx_http_auth_basic_module.html", "extension": ".html", "size_bytes": 7064, "content": "\nModule ngx_http_auth_basic_module
\n\nPlanning your ingress-nginx migration? Start here:\nkubernetes.nginx.org.\n\n

Module ngx_http_auth_basic_module

Example Configuration
Directives
     auth_basic
     auth_basic_user_file
\n\n

\nThe ngx_http_auth_basic_module module allows\nlimiting access to resources by validating the user name and password\nusing the “HTTP Basic Authentication” protocol.\n

\nAccess can also be limited by\naddress, by the\nresult of subrequest,\nor by JWT.\nSimultaneous limitation of access by address and by password is controlled\nby the satisfy directive.\n

\n\n\n

Example Configuration

\n

\nlocation / {\n    auth_basic           \"closed site\";\n    auth_basic_user_file conf/htpasswd;\n}\n

\n

\n\n\n

Directives

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n auth_basic string | off;
\n
\n Default:\n \n
auth_basic off;
\n
\n Context:\n \n http, server, location, limit_except
\n

\nEnables validation of user name and password using the\n“HTTP Basic Authentication” protocol.\nThe specified parameter is used as a realm.\nParameter value can contain variables (1.3.10, 1.2.7).\nThe special value off cancels the effect\nof the auth_basic directive\ninherited from the previous configuration level.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n auth_basic_user_file file;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n http, server, location, limit_except
\n

\nSpecifies a file that keeps user names and passwords,\nin the following format:\n

\n# comment\nname1:password1\nname2:password2:comment\nname3:password3\n

\nThe file name can contain variables.\n

\nThe following password types are supported:\n

\n

\n\n
\n", "encoding": "utf-8"} +{"path": "en\\docs\\http\\ngx_http_auth_jwt_module.html", "extension": ".html", "size_bytes": 20063, "content": "\nModule ngx_http_auth_jwt_module
\n\nPlanning your ingress-nginx migration? Start here:\nkubernetes.nginx.org.\n\n

Module ngx_http_auth_jwt_module

Supported Algorithms
Example Configuration
Directives
     auth_jwt
     auth_jwt_claim_set
     auth_jwt_header_set
     auth_jwt_key_cache
     auth_jwt_key_file
     auth_jwt_key_request
     auth_jwt_leeway
     auth_jwt_type
     auth_jwt_require
Embedded Variables
\n\n

\nThe ngx_http_auth_jwt_module module (1.11.3)\nimplements client authorization by validating the provided\nJSON Web Token (JWT)\nusing the specified keys.\nThe module supports\nJSON Web Signature (JWS),\nJSON Web Encryption (JWE)\n(1.19.7), and Nested JWT (1.21.0).\nThe module can be used for\nOpenID Connect\nauthentication.\n

\nThe module may be combined with\nother access modules, such as\nngx_http_access_module,\nngx_http_auth_basic_module,\nand\nngx_http_auth_request_module,\nvia the satisfy directive.\n

\n

\nThis module is available as part of our\ncommercial subscription.\n

\n

\n\n\n

Supported Algorithms

\nThe module supports the following JSON Web\nAlgorithms.\n

\nJWS algorithms:\n

\n\n

\nPrior to version 1.13.7,\nonly HS256, RS256, ES256 algorithms were supported.\n

\n

\nJWE content encryption algorithms (1.19.7):\n

\n

\nJWE key management algorithms (1.19.9):\n

\n

\n\n\n

Example Configuration

\n

\nlocation / {\n    auth_jwt          \"closed site\";\n    auth_jwt_key_file conf/keys.json;\n}\n

\n

\n\n\n

Directives

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n auth_jwt \n string\n [token=$variable] |\n off;
\n
\n Default:\n \n
auth_jwt off;
\n
\n Context:\n \n http, server, location, limit_except
\n

\nEnables validation of JSON Web Token.\nThe specified string is used as a realm.\nParameter value can contain variables.\n

\nThe optional token parameter specifies a variable\nthat contains JSON Web Token.\nBy default, JWT is passed in the “Authorization” header\nas a\nBearer Token.\nJWT may be also passed as a cookie or a part of a query string:\n

\nauth_jwt \"closed site\" token=$cookie_auth_token;\n

\n

\nThe special value off cancels the effect\nof the auth_jwt directive\ninherited from the previous configuration level.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n auth_jwt_claim_set $variable name ...;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n http
\n

This directive appeared in version 1.11.10.\n

\nSets the variable to a JWT claim parameter\nidentified by key names.\nName matching starts from the top level of the JSON tree.\nFor arrays, the variable keeps a list of array elements separated by commas.\n

\nauth_jwt_claim_set $email info e-mail;\nauth_jwt_claim_set $job info \"job title\";\n

\n

\nPrior to version 1.13.7, only one key name could be specified,\nand the result was undefined for arrays.\n

\n

\n

\nVariable values for tokens encrypted with JWE\nare available only after decryption which occurs during the\nAccess phase.\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n auth_jwt_header_set $variable name ...;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n http
\n

This directive appeared in version 1.11.10.\n

\nSets the variable to a JOSE header parameter\nidentified by key names.\nName matching starts from the top level of the JSON tree.\nFor arrays, the variable keeps a list of array elements separated by commas.\n

\nPrior to version 1.13.7, only one key name could be specified,\nand the result was undefined for arrays.\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n auth_jwt_key_cache time;
\n
\n Default:\n \n
auth_jwt_key_cache 0;
\n
\n Context:\n \n http, server, location
\n

This directive appeared in version 1.21.4.\n

\nEnables or disables caching of keys\nobtained from a file\nor from a subrequest,\nand sets caching time for them.\nCaching of keys obtained from variables is not supported.\nBy default, caching of keys is disabled.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n auth_jwt_key_file file;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n http, server, location, limit_except
\n

\nSpecifies a file in\nJSON Web Key Set\nformat for validating JWT signature.\nParameter value can contain variables.\n

\nSeveral auth_jwt_key_file directives\ncan be specified on the same level (1.21.1):\n

\nauth_jwt_key_file conf/keys.json;\nauth_jwt_key_file conf/key.jwk;\n

\nIf at least one of the specified keys cannot be loaded or processed,\nnginx will return the\n500 (Internal Server Error) error.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n auth_jwt_key_request uri;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n http, server, location, limit_except
\n

This directive appeared in version 1.15.6.\n

\nAllows retrieving a\nJSON Web Key Set\nfile from a subrequest for validating JWT signature and\nsets the URI where the subrequest will be sent to.\nParameter value can contain variables.\nTo avoid validation overhead,\nit is recommended to cache the key file:\n

\nproxy_cache_path /data/nginx/cache levels=1 keys_zone=foo:10m;\n\nserver {\n    ...\n\n    location / {\n        auth_jwt             \"closed site\";\n        auth_jwt_key_request /jwks_uri;\n    }\n\n    location = /jwks_uri {\n        internal;\n        proxy_cache foo;\n        proxy_pass  http://idp.example.com/keys;\n    }\n}\n

\nSeveral auth_jwt_key_request directives\ncan be specified on the same level (1.21.1):\n

\nauth_jwt_key_request /jwks_uri;\nauth_jwt_key_request /jwks2_uri;\n

\nIf at least one of the specified keys cannot be loaded or processed,\nnginx will return the\n500 (Internal Server Error) error.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n auth_jwt_leeway time;
\n
\n Default:\n \n
auth_jwt_leeway 0s;
\n
\n Context:\n \n http, server, location
\n

This directive appeared in version 1.13.10.\n

\nSets the maximum allowable leeway to compensate\nclock skew when verifying the\nexp\nand\nnbf\nJWT claims.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n auth_jwt_type signed |\n encrypted |\n nested;
\n
\n Default:\n \n
auth_jwt_type signed;
\n
\n Context:\n \n http, server, location, limit_except
\n

This directive appeared in version 1.19.7.\n

\nSpecifies which type of JSON Web Token to expect:\nJWS (signed),\nJWE (encrypted),\nor signed and then encrypted\nNested JWT (nested) (1.21.0).\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n auth_jwt_require \n $value ...\n [error=401 |\n 403]\n;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n http, server, location, limit_except
\n

This directive appeared in version 1.21.2.\n

\nSpecifies additional checks for JWT validation.\nThe value can contain text, variables, and their combination,\nand must start with a variable (1.21.7).\nThe authentication will succeed only\nif all the values are not empty and are not equal to “0”.\n

\nmap $jwt_claim_iss $valid_jwt_iss {\n    \"good\" 1;\n}\n...\n\nauth_jwt_require $valid_jwt_iss;\n

\n

\nIf any of the checks fails,\nthe 401 error code is returned.\nThe optional error parameter (1.21.7)\nallows redefining the error code to 403.\n

\n\n\n

Embedded Variables

\nThe ngx_http_auth_jwt_module module\nsupports embedded variables:\n

\n

\n
$jwt_header_name
\n
\nreturns the value of a specified\nJOSE header\n
\n\n
$jwt_claim_name
\n
\nreturns the value of a specified\nJWT claim\n\n

\nFor nested claims and claims including a dot (“.”),\nthe value of the variable cannot be evaluated;\nthe auth_jwt_claim_set directive should be used instead.\n

\n\n

\nVariable values for tokens encrypted with JWE\nare available only after decryption which occurs during the\nAccess phase.\n

\n
\n\n
$jwt_payload
\n
\nreturns the decrypted top-level payload\nof nested\nor encrypted tokens (1.21.2).\nFor nested tokens returns the enclosed JWS token.\nFor encrypted tokens returns JSON with claims.\n
\n\n

\n

\n\n
\n", "encoding": "utf-8"} +{"path": "en\\docs\\http\\ngx_http_auth_request_module.html", "extension": ".html", "size_bytes": 6345, "content": "\nModule ngx_http_auth_request_module
\n\nPlanning your ingress-nginx migration? Start here:\nkubernetes.nginx.org.\n\n

Module ngx_http_auth_request_module

Example Configuration
Directives
     auth_request
     auth_request_set
\n\n

\nThe ngx_http_auth_request_module module (1.5.4+) implements\nclient authorization based on the result of a subrequest.\nIf the subrequest returns a 2xx response code, the access is allowed.\nIf it returns 401 or 403,\nthe access is denied with the corresponding error code.\nAny other response code returned by the subrequest is considered an error.\n

\nFor the 401 error, the client also receives the\n“WWW-Authenticate” header from the subrequest response.\n

\nThis module is not built by default, it should be enabled with the\n--with-http_auth_request_module\nconfiguration parameter.\n

\nThe module may be combined with\nother access modules, such as\nngx_http_access_module,\nngx_http_auth_basic_module,\nand\nngx_http_auth_jwt_module,\nvia the satisfy directive.\n

\nBefore version 1.7.3, responses to authorization subrequests could not be cached\n(using proxy_cache,\nproxy_store, etc.).\n

\n

\n\n\n

Example Configuration

\n

\nlocation /private/ {\n    auth_request /auth;\n    ...\n}\n\nlocation = /auth {\n    proxy_pass ...\n    proxy_pass_request_body off;\n    proxy_set_header Content-Length \"\";\n    proxy_set_header X-Original-URI $request_uri;\n}\n

\n

\n\n\n

Directives

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n auth_request uri | off;
\n
\n Default:\n \n
auth_request off;
\n
\n Context:\n \n http, server, location
\n

\nEnables authorization based on the result of a subrequest and sets\nthe URI to which the subrequest will be sent.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n auth_request_set $variable value;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n http, server, location
\n

\nSets the request variable to the given\nvalue after the authorization request completes.\nThe value may contain variables from the authorization request,\nsuch as $upstream_http_*.\n

\n\n
\n", "encoding": "utf-8"} +{"path": "en\\docs\\http\\ngx_http_auth_require_module.html", "extension": ".html", "size_bytes": 4760, "content": "\nModule ngx_http_auth_require_module
\n\nPlanning your ingress-nginx migration? Start here:\nkubernetes.nginx.org.\n\n

Module ngx_http_auth_require_module

Example Configuration
Directives
     auth_require
\n\n

\nThe ngx_http_auth_require_module module (1.29.0)\nimplements variable-based client authorization.\nIt can also use variables\nprovided by other access modules such as\nngx_http_auth_request_module\nor\nngx_http_auth_oidc_module.\n

\n

\nThis module is available as part of our\ncommercial subscription.\n

\n

\n\n\n

Example Configuration

\n

\nhttp {\n    oidc_provider my_idp {\n        ...\n    }\n\n    map $oidc_claim_role $admin_role {\n        \"admin\" 1;\n    }\n\n    server {\n        auth_oidc my_idp;\n\n        location /admin {\n            auth_require $admin_role;\n        }\n    }\n}\n

\n

\n\n\n

Directives

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n auth_require \n $value ...\n [error=4xx |\n 5xx]\n;
\n
\n Default:\n \n
auth_require off;
\n
\n Context:\n \n http, server, location, limit_except
\n

\nEnables authorization based on the specified variables.\nThe access is allowed only if all the variables are not\nempty and are not equal to “0”.\nOtherwise, the module returns 403 code, which can be\noverridden by the error parameter.\nSeveral auth_require directives can be used to return\ndifferent error codes.\n

\n\n
\n", "encoding": "utf-8"} +{"path": "en\\docs\\http\\ngx_http_autoindex_module.html", "extension": ".html", "size_bytes": 7623, "content": "\nModule ngx_http_autoindex_module
\n\nPlanning your ingress-nginx migration? Start here:\nkubernetes.nginx.org.\n\n

Module ngx_http_autoindex_module

Example Configuration
Directives
     autoindex
     autoindex_exact_size
     autoindex_format
     autoindex_localtime
\n\n

\nThe ngx_http_autoindex_module module processes requests\nending with the slash character (‘/’) and produces\na directory listing.\nUsually a request is passed to the ngx_http_autoindex_module\nmodule when the\nngx_http_index_module module\ncannot find an index file.\n

\n\n\n

Example Configuration

\n

\nlocation / {\n    autoindex on;\n}\n

\n

\n\n\n

Directives

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n autoindex on | off;
\n
\n Default:\n \n
autoindex off;
\n
\n Context:\n \n http, server, location
\n

\nEnables or disables the directory listing output.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n autoindex_exact_size on | off;
\n
\n Default:\n \n
autoindex_exact_size on;
\n
\n Context:\n \n http, server, location
\n

\nFor the HTML format,\nspecifies whether exact file sizes should be output in the directory listing,\nor rather rounded to kilobytes, megabytes, and gigabytes.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n autoindex_format \n html |\n xml |\n json |\n jsonp;
\n
\n Default:\n \n
autoindex_format html;
\n
\n Context:\n \n http, server, location
\n

This directive appeared in version 1.7.9.\n

\nSets the format of a directory listing.\n

\nWhen the JSONP format is used, the name of a callback function is set\nwith the callback request argument.\nIf the argument is missing or has an empty value,\nthen the JSON format is used.\n

\nThe XML output can be transformed using the\nngx_http_xslt_module module.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n autoindex_localtime on | off;
\n
\n Default:\n \n
autoindex_localtime off;
\n
\n Context:\n \n http, server, location
\n

\nFor the HTML format,\nspecifies whether times in the directory listing should be\noutput in the local time zone or UTC.\n

\n\n
\n", "encoding": "utf-8"} +{"path": "en\\docs\\http\\ngx_http_browser_module.html", "extension": ".html", "size_bytes": 9006, "content": "\nModule ngx_http_browser_module
\n\nPlanning your ingress-nginx migration? Start here:\nkubernetes.nginx.org.\n\n

Module ngx_http_browser_module

Example Configuration
Directives
     ancient_browser
     ancient_browser_value
     modern_browser
     modern_browser_value
\n\n

\nThe ngx_http_browser_module module creates variables\nwhose values depend on the value of the “User-Agent”\nrequest header field:\n

\n\n
$modern_browser
\n
\nequals the value set by the modern_browser_value directive,\nif a browser was identified as modern;\n
\n\n
$ancient_browser
\n
\nequals the value set by the ancient_browser_value directive,\nif a browser was identified as ancient;\n
\n\n
$msie
\n
\nequals “1” if a browser was identified as MSIE of any version.\n
\n\n

\n

\n\n\n

Example Configuration

\nChoosing an index file:\n

\nmodern_browser_value \"modern.\";\n\nmodern_browser msie      5.5;\nmodern_browser gecko     1.0.0;\nmodern_browser opera     9.0;\nmodern_browser safari    413;\nmodern_browser konqueror 3.0;\n\nindex index.${modern_browser}html index.html;\n

\n

\nRedirection for old browsers:\n

\nmodern_browser msie      5.0;\nmodern_browser gecko     0.9.1;\nmodern_browser opera     8.0;\nmodern_browser safari    413;\nmodern_browser konqueror 3.0;\n\nmodern_browser unlisted;\n\nancient_browser Links Lynx netscape4;\n\nif ($ancient_browser) {\n    rewrite ^ /ancient.html;\n}\n

\n

\n\n\n

Directives

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n ancient_browser string ...;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n http, server, location
\n

\nIf any of the specified substrings is found in the “User-Agent”\nrequest header field, the browser will be considered ancient.\nThe special string “netscape4” corresponds to the\nregular expression “^Mozilla/[1-4]”.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n ancient_browser_value string;
\n
\n Default:\n \n
ancient_browser_value 1;
\n
\n Context:\n \n http, server, location
\n

\nSets a value for the $ancient_browser variables.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n modern_browser browser version;
modern_browser unlisted;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n http, server, location
\n

\nSpecifies a version starting from which a browser is considered modern.\nA browser can be any one of the following: msie,\ngecko (browsers based on Mozilla),\nopera, safari,\nor konqueror.\n

\nVersions can be specified in the following formats: X, X.X, X.X.X, or X.X.X.X.\nThe maximum values for each of the format are\n4000, 4000.99, 4000.99.99, and 4000.99.99.99, respectively.\n

\nThe special value unlisted specifies to consider\na browser as modern if it was not listed by the\nmodern_browser and ancient_browser\ndirectives.\nOtherwise such a browser is considered ancient.\nIf a request does not provide the “User-Agent” field\nin the header, the browser is treated as not being listed.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n modern_browser_value string;
\n
\n Default:\n \n
modern_browser_value 1;
\n
\n Context:\n \n http, server, location
\n

\nSets a value for the $modern_browser variables.\n

\n\n
\n", "encoding": "utf-8"} +{"path": "en\\docs\\http\\ngx_http_charset_module.html", "extension": ".html", "size_bytes": 12017, "content": "\nModule ngx_http_charset_module
\n\nPlanning your ingress-nginx migration? Start here:\nkubernetes.nginx.org.\n\n

Module ngx_http_charset_module

Example Configuration
Directives
     charset
     charset_map
     charset_types
     override_charset
     source_charset
\n\n

\nThe ngx_http_charset_module module adds the specified\ncharset to the “Content-Type” response header field.\nIn addition, the module can convert data from one charset to another,\nwith some limitations:\n

\n

\n\n\n

Example Configuration

\n

\ninclude        conf/koi-win;\n\ncharset        windows-1251;\nsource_charset koi8-r;\n

\n

\n\n\n

Directives

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n charset charset | off;
\n
\n Default:\n \n
charset off;
\n
\n Context:\n \n http, server, location, if in location
\n

\nAdds the specified charset to the “Content-Type”\nresponse header field.\nIf this charset is different from the charset specified\nin the source_charset directive, a conversion is performed.\n

\nThe parameter off cancels the addition of charset\nto the “Content-Type” response header field.\n

\nA charset can be defined with a variable:\n

\ncharset $charset;\n

\nIn such a case, all possible values of a variable need to be present\nin the configuration at least once in the form of the\ncharset_map, charset, or\nsource_charset directives.\nFor utf-8, windows-1251, and\nkoi8-r charsets, it is sufficient to include the files\nconf/koi-win, conf/koi-utf, and\nconf/win-utf into configuration.\nFor other charsets, simply making a fictitious conversion table works,\nfor example:\n

\ncharset_map iso-8859-5 _ { }\n

\n

\nIn addition, a charset can be set in the\n“X-Accel-Charset” response header field.\nThis capability can be disabled using the\nproxy_ignore_headers,\nfastcgi_ignore_headers,\nuwsgi_ignore_headers,\nscgi_ignore_headers,\nand\ngrpc_ignore_headers\ndirectives.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n charset_map charset1 charset2 { ... }
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n http
\n

\nDescribes the conversion table from one charset to another.\nA reverse conversion table is built using the same data.\nCharacter codes are given in hexadecimal.\nMissing characters in the range 80-FF are replaced with “?”.\nWhen converting from UTF-8, characters missing in a one-byte charset\nare replaced with “&#XXXX;”.\n

\nExample:\n

\ncharset_map koi8-r windows-1251 {\n    C0 FE ; # small yu\n    C1 E0 ; # small a\n    C2 E1 ; # small b\n    C3 F6 ; # small ts\n    ...\n}\n

\n

\nWhen describing a conversion table to UTF-8, codes for the UTF-8 charset should\nbe given in the second column, for example:\n

\ncharset_map koi8-r utf-8 {\n    C0 D18E ; # small yu\n    C1 D0B0 ; # small a\n    C2 D0B1 ; # small b\n    C3 D186 ; # small ts\n    ...\n}\n

\n

\nFull conversion tables from koi8-r to\nwindows-1251, and from koi8-r and\nwindows-1251 to utf-8\nare provided in the distribution files conf/koi-win,\nconf/koi-utf, and conf/win-utf.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n charset_types mime-type ...;
\n
\n Default:\n \n
charset_types text/html text/xml text/plain text/vnd.wap.wml\napplication/javascript application/rss+xml;
\n
\n Context:\n \n http, server, location
\n

This directive appeared in version 0.7.9.\n

\nEnables module processing in responses with the specified MIME types\nin addition to “text/html”.\nThe special value “*” matches any MIME type (0.8.29).\n

\n

\nUntil version 1.5.4, “application/x-javascript” was used\nas the default MIME type instead of “application/javascript”.\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n override_charset on | off;
\n
\n Default:\n \n
override_charset off;
\n
\n Context:\n \n http, server, location, if in location
\n

\nDetermines whether a conversion should be performed for answers\nreceived from a proxied or a FastCGI/uwsgi/SCGI/gRPC server\nwhen the answers already carry a charset in the “Content-Type”\nresponse header field.\nIf conversion is enabled, a charset specified in the received\nresponse is used as a source charset.\n

\nIt should be noted that if a response is received in a subrequest\nthen the conversion from the response charset to the main request charset\nis always performed, regardless of the override_charset\ndirective setting.\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n source_charset charset;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n http, server, location, if in location
\n

\nDefines the source charset of a response.\nIf this charset is different from the charset specified\nin the charset directive, a conversion is performed.\n

\n\n
\n", "encoding": "utf-8"} +{"path": "en\\docs\\http\\ngx_http_core_module.html", "extension": ".html", "size_bytes": 157587, "content": "\nModule ngx_http_core_module
\n\nPlanning your ingress-nginx migration? Start here:\nkubernetes.nginx.org.\n\n

Module ngx_http_core_module

Directives
     absolute_redirect
     aio
     aio_write
     alias
     auth_delay
     chunked_transfer_encoding
     client_body_buffer_size
     client_body_in_file_only
     client_body_in_single_buffer
     client_body_temp_path
     client_body_timeout
     client_header_buffer_size
     client_header_timeout
     client_max_body_size
     connection_pool_size
     default_type
     directio
     directio_alignment
     disable_symlinks
     early_hints
     error_log_tag
     error_page
     etag
     http
     if_modified_since
     ignore_invalid_headers
     internal
     keepalive_disable
     keepalive_min_timeout
     keepalive_requests
     keepalive_time
     keepalive_timeout
     large_client_header_buffers
     limit_except
     limit_rate
     limit_rate_after
     lingering_close
     lingering_time
     lingering_timeout
     listen
     location
     log_not_found
     log_subrequest
     max_headers
     max_ranges
     merge_slashes
     msie_padding
     msie_refresh
     open_file_cache
     open_file_cache_errors
     open_file_cache_min_uses
     open_file_cache_valid
     output_buffers
     port_in_redirect
     postpone_output
     read_ahead
     recursive_error_pages
     request_pool_size
     reset_timedout_connection
     resolver
     resolver_timeout
     root
     satisfy
     send_lowat
     send_timeout
     sendfile
     sendfile_max_chunk
     server
     server_name
     server_name_in_redirect
     server_names_hash_bucket_size
     server_names_hash_max_size
     server_tokens
     subrequest_output_buffer_size
     tcp_nodelay
     tcp_nopush
     try_files
     types
     types_hash_bucket_size
     types_hash_max_size
     underscores_in_headers
     variables_hash_bucket_size
     variables_hash_max_size
Embedded Variables
\n\n

Directives

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n absolute_redirect on | off;
\n
\n Default:\n \n
absolute_redirect on;
\n
\n Context:\n \n http, server, location
\n

This directive appeared in version 1.11.8.\n

\nIf disabled, redirects issued by nginx will be relative.\n

\nSee also server_name_in_redirect\nand port_in_redirect directives.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n aio \n on |\n off |\n threads[=pool];
\n
\n Default:\n \n
aio off;
\n
\n Context:\n \n http, server, location
\n

This directive appeared in version 0.8.11.\n

\nEnables or disables the use of asynchronous file I/O (AIO)\non FreeBSD and Linux:\n

\nlocation /video/ {\n    aio            on;\n    output_buffers 1 64k;\n}\n

\n

\nOn FreeBSD, AIO can be used starting from FreeBSD 4.3.\nPrior to FreeBSD 11.0,\nAIO can either be linked statically into a kernel:\n

\noptions VFS_AIO\n

\nor loaded dynamically as a kernel loadable module:\n

\nkldload aio\n

\n

\nOn Linux, AIO can be used starting from kernel version 2.6.22.\nAlso, it is necessary to enable\ndirectio,\nor otherwise reading will be blocking:\n

\nlocation /video/ {\n    aio            on;\n    directio       512;\n    output_buffers 1 128k;\n}\n

\n

\nOn Linux,\ndirectio\ncan only be used for reading blocks that are aligned on 512-byte\nboundaries (or 4K for XFS).\nFile’s unaligned end is read in blocking mode.\nThe same holds true for byte range requests and for FLV requests\nnot from the beginning of a file: reading of unaligned data at the\nbeginning and end of a file will be blocking.\n

\nWhen both AIO and sendfile are enabled on Linux,\nAIO is used for files that are larger than or equal to\nthe size specified in the directio directive,\nwhile sendfile is used for files of smaller sizes\nor when directio is disabled.\n

\nlocation /video/ {\n    sendfile       on;\n    aio            on;\n    directio       8m;\n}\n

\n

\nFinally, files can be read and sent\nusing multi-threading (1.7.11),\nwithout blocking a worker process:\n

\nlocation /video/ {\n    sendfile       on;\n    aio            threads;\n}\n

\nRead and send file operations are offloaded to threads of the specified\npool.\nIf the pool name is omitted,\nthe pool with the name “default” is used.\nThe pool name can also be set with variables:\n

\naio threads=pool$disk;\n

\nBy default, multi-threading is disabled, it should be\nenabled with the\n--with-threads configuration parameter.\nCurrently, multi-threading is compatible only with the\nepoll,\nkqueue,\nand\neventport methods.\nMulti-threaded sending of files is only supported on Linux.\n

\nSee also the sendfile directive.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n aio_write on | off;
\n
\n Default:\n \n
aio_write off;
\n
\n Context:\n \n http, server, location
\n

This directive appeared in version 1.9.13.\n

\nIf aio is enabled, specifies whether it is used for writing files.\nCurrently, this only works when using\naio threads\nand is limited to writing temporary files\nwith data received from proxied servers.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n alias path;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n location
\n

\nDefines a replacement for the specified location.\nFor example, with the following configuration\n

\nlocation /i/ {\n    alias /data/w3/images/;\n}\n

\non request of\n“/i/top.gif”, the file\n/data/w3/images/top.gif will be sent.\n

\nThe path value can contain variables,\nexcept $document_root and $realpath_root.\n

\nIf alias is used inside a location defined\nwith a regular expression then such regular expression should\ncontain captures and alias should refer to\nthese captures (0.7.40), for example:\n

\nlocation ~ ^/users/(.+\\.(?:gif|jpe?g|png))$ {\n    alias /data/w3/images/$1;\n}\n

\n

\nWhen location matches the last part of the directive’s value:\n

\nlocation /images/ {\n    alias /data/w3/images/;\n}\n

\nit is better to use the\nroot\ndirective instead:\n

\nlocation /images/ {\n    root /data/w3;\n}\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n auth_delay time;
\n
\n Default:\n \n
auth_delay 0s;
\n
\n Context:\n \n http, server, location
\n

This directive appeared in version 1.17.10.\n

\nDelays processing of unauthorized requests with 401 response code\nto prevent timing attacks when access is limited by\npassword, by the\nresult of subrequest,\nor by JWT.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n chunked_transfer_encoding on | off;
\n
\n Default:\n \n
chunked_transfer_encoding on;
\n
\n Context:\n \n http, server, location
\n

\nAllows disabling chunked transfer encoding in HTTP/1.1.\nIt may come in handy when using a software failing to support\nchunked encoding despite the standard’s requirement.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n client_body_buffer_size size;
\n
\n Default:\n \n
client_body_buffer_size 8k|16k;
\n
\n Context:\n \n http, server, location
\n

\nSets buffer size for reading client request body.\nIn case the request body is larger than the buffer,\nthe whole body or only its part is written to a\ntemporary file.\nBy default, buffer size is equal to two memory pages.\nThis is 8K on x86, other 32-bit platforms, and x86-64.\nIt is usually 16K on other 64-bit platforms.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n client_body_in_file_only \n on |\n clean |\n off;
\n
\n Default:\n \n
client_body_in_file_only off;
\n
\n Context:\n \n http, server, location
\n

\nDetermines whether nginx should save the entire client request body\ninto a file.\nThis directive can be used during debugging, or when using the\n$request_body_file\nvariable, or the\n$r->request_body_file\nmethod of the module\nngx_http_perl_module.\n

\nWhen set to the value on, temporary files are not\nremoved after request processing.\n

\nThe value clean will cause the temporary files\nleft after request processing to be removed.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n client_body_in_single_buffer on | off;
\n
\n Default:\n \n
client_body_in_single_buffer off;
\n
\n Context:\n \n http, server, location
\n

\nDetermines whether nginx should save the entire client request body\nin a single buffer.\nThe directive is recommended when using the\n$request_body\nvariable, to save the number of copy operations involved.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n client_body_temp_path \n path\n [level1\n [level2\n [level3]]];
\n
\n Default:\n \n
client_body_temp_path client_body_temp;
\n
\n Context:\n \n http, server, location
\n

\nDefines a directory for storing temporary files holding client request bodies.\nUp to three-level subdirectory hierarchy can be used under the specified\ndirectory.\nFor example, in the following configuration\n

\nclient_body_temp_path /spool/nginx/client_temp 1 2;\n

\na path to a temporary file might look like this:\n

\n/spool/nginx/client_temp/7/45/00000123457\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n client_body_timeout time;
\n
\n Default:\n \n
client_body_timeout 60s;
\n
\n Context:\n \n http, server, location
\n

\nDefines a timeout for reading client request body.\nThe timeout is set only for a period between two successive read operations,\nnot for the transmission of the whole request body.\nIf a client does not transmit anything within this time, the\nrequest is terminated with the\n408 (Request Time-out)\nerror.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n client_header_buffer_size size;
\n
\n Default:\n \n
client_header_buffer_size 1k;
\n
\n Context:\n \n http, server
\n

\nSets buffer size for reading client request header.\nFor most requests, a buffer of 1K bytes is enough.\nHowever, if a request includes long cookies, or comes from a WAP client,\nit may not fit into 1K.\nIf a request line or a request header field does not fit into\nthis buffer then larger buffers, configured by the\nlarge_client_header_buffers directive,\nare allocated.\n

\nIf the directive is specified on the server level,\nthe value from the default server can be used.\nDetails are provided in the\n“Virtual\nserver selection” section.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n client_header_timeout time;
\n
\n Default:\n \n
client_header_timeout 60s;
\n
\n Context:\n \n http, server
\n

\nDefines a timeout for reading client request header.\nIf a client does not transmit the entire header within this time, the\nrequest is terminated with the\n408 (Request Time-out)\nerror.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n client_max_body_size size;
\n
\n Default:\n \n
client_max_body_size 1m;
\n
\n Context:\n \n http, server, location
\n

\nSets the maximum allowed size of the client request body.\nIf the size in a request exceeds the configured value, the\n413 (Request Entity Too Large)\nerror is returned to the client.\nPlease be aware that\nbrowsers cannot correctly display\nthis error.\nSetting size to 0 disables checking of client\nrequest body size.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n connection_pool_size size;
\n
\n Default:\n \n
connection_pool_size 256|512;
\n
\n Context:\n \n http, server
\n

\nAllows accurate tuning of per-connection memory allocations.\nThis directive has minimal impact on performance\nand should not generally be used.\nBy default, the size is equal to\n256 bytes on 32-bit platforms and 512 bytes on 64-bit platforms.\n

\nPrior to version 1.9.8, the default value was 256 on all platforms.\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n default_type mime-type;
\n
\n Default:\n \n
default_type text/plain;
\n
\n Context:\n \n http, server, location
\n

\nDefines the default MIME type of a response.\nMapping of file name extensions to MIME types can be set\nwith the types directive.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n directio size | off;
\n
\n Default:\n \n
directio off;
\n
\n Context:\n \n http, server, location
\n

This directive appeared in version 0.7.7.\n

\nEnables the use of\nthe O_DIRECT flag (FreeBSD, Linux),\nthe F_NOCACHE flag (macOS),\nor the directio() function (Solaris),\nwhen reading files that are larger than or equal to\nthe specified size.\nThe directive automatically disables (0.7.15) the use of\nsendfile\nfor a given request.\nIt can be useful for serving large files:\n

\ndirectio 4m;\n

\nor when using aio on Linux.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n directio_alignment size;
\n
\n Default:\n \n
directio_alignment 512;
\n
\n Context:\n \n http, server, location
\n

This directive appeared in version 0.8.11.\n

\nSets the alignment for\ndirectio.\nIn most cases, a 512-byte alignment is enough.\nHowever, when using XFS under Linux, it needs to be increased to 4K.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n disable_symlinks off;
disable_symlinks \n on |\n if_not_owner\n [from=part];
\n
\n Default:\n \n
disable_symlinks off;
\n
\n Context:\n \n http, server, location
\n

This directive appeared in version 1.1.15.\n

\nDetermines how symbolic links should be treated when opening files:\n

\n\n
off
\n
\nSymbolic links in the pathname are allowed and not checked.\nThis is the default behavior.\n
\n\n
on
\n
\nIf any component of the pathname is a symbolic link,\naccess to a file is denied.\n
\n\n
if_not_owner
\n
\nAccess to a file is denied if any component of the pathname\nis a symbolic link, and the link and object that the link\npoints to have different owners.\n
\n\n
from=part
\n
\nWhen checking symbolic links\n(parameters on and if_not_owner),\nall components of the pathname are normally checked.\nChecking of symbolic links in the initial part of the pathname\nmay be avoided by specifying additionally the\nfrom=part parameter.\nIn this case, symbolic links are checked only from\nthe pathname component that follows the specified initial part.\nIf the value is not an initial part of the pathname checked, the whole\npathname is checked as if this parameter was not specified at all.\nIf the value matches the whole file name,\nsymbolic links are not checked.\nThe parameter value can contain variables.\n
\n\n

\n

\nExample:\n

\ndisable_symlinks on from=$document_root;\n

\n

\nThis directive is only available on systems that have the\nopenat() and fstatat() interfaces.\nSuch systems include modern versions of FreeBSD, Linux, and Solaris.\n

\nParameters on and if_not_owner\nadd a processing overhead.\n

\nOn systems that do not support opening of directories only for search,\nto use these parameters it is required that worker processes\nhave read permissions for all directories being checked.\n

\n

\n

\nThe\nngx_http_autoindex_module,\nngx_http_random_index_module,\nand ngx_http_dav_module\nmodules currently ignore this directive.\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n early_hints string ...;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n http, server, location
\n

This directive appeared in version 1.29.0.\n

\nDefines conditions under which\nthe 103 (Early Hints) response\nwill be passed to a client.\nIf at least one value of the string parameters is not empty and is not\nequal to “0” then the response will be passed:\n

\nmap $http_sec_fetch_mode $early_hints {\n    navigate $http2$http3;\n}\n\nserver {\n    ...\n    location / {\n        early_hints $early_hints;\n        proxy_pass http://example.com;\n    }\n}\n

\n

\n

\n103 (Early Hints) responses received from\nan upstream server are passed to a client as is, without interpretation.\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n error_log_tag name value;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n http, server, location
\n

This directive appeared in version 1.29.8.\n

\nDefines an additional context tag for HTTP\nerror log messages in\ntext or JSON\nformat, in addition to default tags.\nThe value can contain text, variables, and their combination:\n

\nerror_log_tag  request_id  $request_id;\n

\n

\nSeveral error_log_tag directives\ncan be specified on the same level.\nThese directives are inherited from the previous configuration level\nif and only if there are no error_log_tag directives\ndefined on the current level.\n

\n

\nThis directive is available as part of our\ncommercial subscription.\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n error_page \n code ...\n [=[response]]\n uri;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n http, server, location, if in location
\n

\nDefines the URI that will be shown for the specified errors.\nA uri value can contain variables.\n

\nExample:\n

\nerror_page 404             /404.html;\nerror_page 500 502 503 504 /50x.html;\n

\n

\nThis causes an internal redirect to the specified uri\nwith the client request method changed to “GET”\n(for all methods other than\n“GET” and “HEAD”).\n

\nFurthermore, it is possible to change the response code to another\nusing the “=response” syntax, for example:\n

\nerror_page 404 =200 /empty.gif;\n

\n

\nIf an error response is processed by a proxied server\nor a FastCGI/uwsgi/SCGI/gRPC server,\nand the server may return different response codes (e.g., 200, 302, 401\nor 404), it is possible to respond with the code it returns:\n

\nerror_page 404 = /404.php;\n

\n

\nIf there is no need to change URI and method during internal redirection\nit is possible to pass error processing into a named location:\n

\nlocation / {\n    error_page 404 = @fallback;\n}\n\nlocation @fallback {\n    proxy_pass http://backend;\n}\n

\n

\n

\nIf uri processing leads to an error,\nthe status code of the last occurred error is returned to the client.\n

\n

\nIt is also possible to use URL redirects for error processing:\n

\nerror_page 403      http://example.com/forbidden.html;\nerror_page 404 =301 http://example.com/notfound.html;\n

\nIn this case, by default, the response code 302 is returned to the client.\nIt can only be changed to one of the redirect status\ncodes (301, 302, 303, 307, and 308).\n

\nThe code 307 was not treated as a redirect until versions 1.1.16 and 1.0.13.\n

\n\n

\nThe code 308 was not treated as a redirect until version 1.13.0.\n

\n

\nThese directives are inherited from the previous configuration level\nif and only if there are no error_page directives\ndefined on the current level.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n etag on | off;
\n
\n Default:\n \n
etag on;
\n
\n Context:\n \n http, server, location
\n

This directive appeared in version 1.3.3.\n

\nEnables or disables automatic generation of the “ETag”\nresponse header field for static resources.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n http { ... }
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n main
\n

\nProvides the configuration file context in which the HTTP server directives\nare specified.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n if_modified_since \n off |\n exact |\n before;
\n
\n Default:\n \n
if_modified_since exact;
\n
\n Context:\n \n http, server, location
\n

This directive appeared in version 0.7.24.\n

\nSpecifies how to compare modification time of a response\nwith the time in the\n“If-Modified-Since”\nrequest header field:\n\n

\n\n
off
\n
\nthe response is always considered modified (0.7.34);\n
\n\n
exact
\n
\nexact match;\n
\n\n
before
\n
\nmodification time of the response is\nless than or equal to the time in the “If-Modified-Since”\nrequest header field.\n
\n\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n ignore_invalid_headers on | off;
\n
\n Default:\n \n
ignore_invalid_headers on;
\n
\n Context:\n \n http, server
\n

\nControls whether header fields with invalid names should be ignored.\nValid names are composed of English letters, digits, hyphens, and possibly\nunderscores (as controlled by the underscores_in_headers\ndirective).\n

\nIf the directive is specified on the server level,\nthe value from the default server can be used.\nDetails are provided in the\n“Virtual\nserver selection” section.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n internal;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n location
\n

\nSpecifies that a given location can only be used for internal requests.\nFor external requests, the client error\n404 (Not Found)\nis returned.\nInternal requests are the following:\n\n

\n

\nExample:\n

\nerror_page 404 /404.html;\n\nlocation = /404.html {\n    internal;\n}\n

\n

\nThere is a limit of 10 internal redirects per request to prevent\nrequest processing cycles that can occur in incorrect configurations.\nIf this limit is reached, the error\n500 (Internal Server Error) is returned.\nIn such cases, the “rewrite or internal redirection cycle” message\ncan be seen in the error log.\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n keepalive_disable none | browser ...;
\n
\n Default:\n \n
keepalive_disable msie6;
\n
\n Context:\n \n http, server, location
\n

\nDisables keep-alive connections with misbehaving browsers.\nThe browser parameters specify which\nbrowsers will be affected.\nThe value msie6 disables keep-alive connections\nwith old versions of MSIE, once a POST request is received.\nThe value safari disables keep-alive connections\nwith Safari and Safari-like browsers on macOS and macOS-like\noperating systems.\nThe value none enables keep-alive connections\nwith all browsers.\n

\nPrior to version 1.1.18, the value safari matched\nall Safari and Safari-like browsers on all operating systems, and\nkeep-alive connections with them were disabled by default.\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n keepalive_min_timeout timeout;
\n
\n Default:\n \n
keepalive_min_timeout 0;
\n
\n Context:\n \n http, server, location
\n

This directive appeared in version 1.27.4.\n

\nSets a timeout during which a keep-alive\nclient connection will not be closed on the server side\nfor connection reuse or on graceful shutdown of worker processes.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n keepalive_requests number;
\n
\n Default:\n \n
keepalive_requests 1000;
\n
\n Context:\n \n http, server, location
\n

This directive appeared in version 0.8.0.\n

\nSets the maximum number of requests that can be\nserved through one keep-alive connection.\nAfter the maximum number of requests are made, the connection is closed.\n

\nClosing connections periodically is necessary to free\nper-connection memory allocations.\nTherefore, using too high maximum number of requests\ncould result in excessive memory usage and not recommended.\n

\n

\nPrior to version 1.19.10, the default value was 100.\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n keepalive_time time;
\n
\n Default:\n \n
keepalive_time 1h;
\n
\n Context:\n \n http, server, location
\n

This directive appeared in version 1.19.10.\n

\nLimits the maximum time during which\nrequests can be processed through one keep-alive connection.\nAfter this time is reached, the connection is closed\nfollowing the subsequent request processing.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n keepalive_timeout \n timeout\n [header_timeout];
\n
\n Default:\n \n
keepalive_timeout 75s;
\n
\n Context:\n \n http, server, location
\n

\nThe first parameter sets a timeout during which a keep-alive\nclient connection will stay open on the server side.\nThe zero value disables keep-alive client connections.\nThe optional second parameter sets a value in the\n“Keep-Alive: timeout=time”\nresponse header field.\nTwo parameters may differ.\n

\nThe\n“Keep-Alive: timeout=time”\nheader field is recognized by Mozilla and Konqueror.\nMSIE closes keep-alive connections by itself in about 60 seconds.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n large_client_header_buffers number size;
\n
\n Default:\n \n
large_client_header_buffers 4 8k;
\n
\n Context:\n \n http, server
\n

\nSets the maximum number and size of\nbuffers used for reading large client request header.\nA request line cannot exceed the size of one buffer, or the\n414 (Request-URI Too Large)\nerror is returned to the client.\nA request header field cannot exceed the size of one buffer as well, or the\n400 (Bad Request)\nerror is returned to the client.\nBuffers are allocated only on demand.\nBy default, the buffer size is equal to 8K bytes.\nIf after the end of request processing a connection is transitioned\ninto the keep-alive state, these buffers are released.\n

\nIf the directive is specified on the server level,\nthe value from the default server can be used.\nDetails are provided in the\n“Virtual\nserver selection” section.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n limit_except method ... { ... }
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n location
\n

\nLimits allowed HTTP methods inside a location.\nThe method parameter can be one of the following:\nGET,\nHEAD,\nPOST,\nPUT,\nDELETE,\nMKCOL,\nCOPY,\nMOVE,\nOPTIONS,\nPROPFIND,\nPROPPATCH,\nLOCK,\nUNLOCK,\nor\nPATCH.\nAllowing the GET method makes the\nHEAD method also allowed.\nAccess to other methods can be limited using the\nngx_http_access_module,\nngx_http_auth_basic_module,\nand\nngx_http_auth_jwt_module\n(1.13.10)\nmodules directives:\n

\nlimit_except GET {\n    allow 192.168.1.0/32;\n    deny  all;\n}\n

\nPlease note that this will limit access to all methods\nexcept GET and HEAD.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n limit_rate rate;
\n
\n Default:\n \n
limit_rate 0;
\n
\n Context:\n \n http, server, location, if in location
\n

\nLimits the rate of response transmission to a client.\nThe rate is specified in bytes per second.\nThe zero value disables rate limiting.\n\nThe limit is set per a request, and so if a client simultaneously opens\ntwo connections, the overall rate will be twice as much\nas the specified limit.\n

\nParameter value can contain variables (1.17.0).\nIt may be useful in cases where rate should be limited\ndepending on a certain condition:\n

\nmap $slow $rate {\n    1     4k;\n    2     8k;\n}\n\nlimit_rate $rate;\n

\n

\nRate limit can also be set in the\n$limit_rate variable,\nhowever, since version 1.17.0, this method is not recommended:\n

\nserver {\n\n    if ($slow) {\n        set $limit_rate 4k;\n    }\n\n    ...\n}\n

\n

\nRate limit can also be set in the\n“X-Accel-Limit-Rate” header field of a proxied server response.\nThis capability can be disabled using the\nproxy_ignore_headers,\nfastcgi_ignore_headers,\nuwsgi_ignore_headers,\nand\nscgi_ignore_headers\ndirectives.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n limit_rate_after size;
\n
\n Default:\n \n
limit_rate_after 0;
\n
\n Context:\n \n http, server, location, if in location
\n

This directive appeared in version 0.8.0.\n

\nSets the initial amount after which the further transmission\nof a response to a client will be rate limited.\nParameter value can contain variables (1.17.0).\n

\nExample:\n

\nlocation /flv/ {\n    flv;\n    limit_rate_after 500k;\n    limit_rate       50k;\n}\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n lingering_close \n off |\n on |\n always;
\n
\n Default:\n \n
lingering_close on;
\n
\n Context:\n \n http, server, location
\n
\n

\n This directive appeared in versions 1.1.0 and 1.0.6.\n \n

\n

\nControls how nginx closes client connections.\n

\nThe default value “on” instructs nginx to\nwait for and\nprocess additional data from a client\nbefore fully closing a connection, but only\nif heuristics suggests that a client may be sending more data.\n

\nThe value “always” will cause nginx to unconditionally\nwait for and process additional client data.\n

\nThe value “off” tells nginx to never wait for\nmore data and close the connection immediately.\nThis behavior breaks the protocol and should not be used under normal\ncircumstances.\n

\nTo control closing\nHTTP/2 connections,\nthe directive must be specified on the server level (1.19.1).\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n lingering_time time;
\n
\n Default:\n \n
lingering_time 30s;
\n
\n Context:\n \n http, server, location
\n

\nWhen lingering_close is in effect,\nthis directive specifies the maximum time during which nginx\nwill process (read and ignore) additional data coming from a client.\nAfter that, the connection will be closed, even if there will be\nmore data.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n lingering_timeout time;
\n
\n Default:\n \n
lingering_timeout 5s;
\n
\n Context:\n \n http, server, location
\n

\nWhen lingering_close is in effect, this directive specifies\nthe maximum waiting time for more client data to arrive.\nIf data are not received during this time, the connection is closed.\nOtherwise, the data are read and ignored, and nginx starts waiting\nfor more data again.\nThe “wait-read-ignore” cycle is repeated, but no longer than specified by the\nlingering_time directive.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n listen \n address[:port]\n [default_server]\n [ssl]\n [http2 |\n quic]\n [proxy_protocol]\n [setfib=number]\n [fastopen=number]\n [backlog=number]\n [rcvbuf=size]\n [sndbuf=size]\n [accept_filter=filter]\n [deferred]\n [bind]\n [ipv6only=on|off]\n [reuseport]\n [multipath]\n [so_keepalive=on|off|[keepidle]:[keepintvl]:[keepcnt]];
listen \n port\n [default_server]\n [ssl]\n [http2 |\n quic]\n [proxy_protocol]\n [setfib=number]\n [fastopen=number]\n [backlog=number]\n [rcvbuf=size]\n [sndbuf=size]\n [accept_filter=filter]\n [deferred]\n [bind]\n [ipv6only=on|off]\n [reuseport]\n [multipath]\n [so_keepalive=on|off|[keepidle]:[keepintvl]:[keepcnt]];
listen \n unix:path\n [default_server]\n [ssl]\n [http2 |\n quic]\n [proxy_protocol]\n [backlog=number]\n [rcvbuf=size]\n [sndbuf=size]\n [accept_filter=filter]\n [deferred]\n [bind]\n [so_keepalive=on|off|[keepidle]:[keepintvl]:[keepcnt]];
\n
\n Default:\n \n
listen *:80 | *:8000;
\n
\n Context:\n \n server
\n

\nSets the address and port for IP,\nor the path for a UNIX-domain socket on which\nthe server will accept requests.\nBoth address and port,\nor only address or only port can be specified.\nAn address may also be a hostname, for example:\n

\nlisten 127.0.0.1:8000;\nlisten 127.0.0.1;\nlisten 8000;\nlisten *:8000;\nlisten localhost:8000;\n

\nIPv6 addresses (0.7.36) are specified in square brackets:\n

\nlisten [::]:8000;\nlisten [::1];\n

\nUNIX-domain sockets (0.8.21) are specified with the “unix:”\nprefix:\n

\nlisten unix:/var/run/nginx.sock;\n

\n

\nIf only address is given, the port 80 is used.\n

\nIf the directive is not present then either *:80 is used\nif nginx runs with the superuser privileges, or *:8000\notherwise.\n

\nThe default_server parameter, if present,\nwill cause the server to become the default server for the specified\naddress:port pair.\nIf none of the directives have the default_server\nparameter then the first server with the\naddress:port pair will be\nthe default server for this pair.\n

\nIn versions prior to 0.8.21 this parameter is named simply\ndefault.\n

\n

\nThe ssl parameter (0.7.14) allows specifying that all\nconnections accepted on this port should work in SSL mode.\nThis allows for a more compact configuration for the server that\nhandles both HTTP and HTTPS requests.\n

\nThe http2 parameter (1.9.5) configures the port to accept\nHTTP/2 connections.\nNormally, for this to work the ssl parameter should be\nspecified as well, but nginx can also be configured to accept HTTP/2\nconnections without SSL.\n

\nThe parameter is deprecated,\nthe http2 directive\nshould be used instead.\n

\n

\nThe quic parameter (1.25.0) configures the port to accept\nQUIC connections.\n

\nThe proxy_protocol parameter (1.5.12)\nallows specifying that all connections accepted on this port should use the\nPROXY\nprotocol.\n

\nThe PROXY protocol version 2 is supported since version 1.13.11.\n

\n

\nThe listen directive\ncan have several additional parameters specific to socket-related system calls.\nThese parameters can be specified in any\nlisten directive, but only once for a given\naddress:port pair.\n

\nIn versions prior to 0.8.21, they could only be\nspecified in the listen directive together with the\ndefault parameter.\n

\n

\n\n
\nsetfib=number\n
\n
\nthis parameter (0.8.44) sets the associated routing table, FIB\n(the SO_SETFIB option) for the listening socket.\nThis currently works only on FreeBSD.\n
\n\n
\nfastopen=number\n
\n
\nenables\n“TCP Fast Open”\nfor the listening socket (1.5.8) and\nlimits\nthe maximum length for the queue of connections that have not yet completed\nthe three-way handshake.\n
\nDo not enable this feature unless the server can handle\nreceiving the\n\nsame SYN packet with data more than once.\n
\n
\n\n
\nbacklog=number\n
\n
\nsets the backlog parameter in the\nlisten() call that limits\nthe maximum length for the queue of pending connections.\nBy default,\nbacklog is set to -1 on FreeBSD, DragonFly BSD, and macOS,\nand to 511 on other platforms.\n
\n\n
\nrcvbuf=size\n
\n
\nsets the receive buffer size\n(the SO_RCVBUF option) for the listening socket.\n
\n\n
\nsndbuf=size\n
\n
\nsets the send buffer size\n(the SO_SNDBUF option) for the listening socket.\n
\n\n
\naccept_filter=filter\n
\n
\nsets the name of accept filter\n(the SO_ACCEPTFILTER option) for the listening socket\nthat filters incoming connections before passing them to\naccept().\nThis works only on FreeBSD and NetBSD 5.0+.\nPossible values are\ndataready\nand\nhttpready.\n
\n\n
\ndeferred\n
\n
\ninstructs to use a deferred accept()\n(the TCP_DEFER_ACCEPT socket option) on Linux.\n
\n\n
\nbind\n
\n
\ninstructs to make a separate bind() call for a given\naddress:port pair.\nThis is useful because if there are several listen\ndirectives with the same port but different addresses, and one of the\nlisten directives listens on all addresses\nfor the given port (*:port), nginx\nwill bind() only to *:port.\nIt should be noted that the getsockname() system call will be\nmade in this case to determine the address that accepted the connection.\nIf the setfib,\nfastopen,\nbacklog, rcvbuf,\nsndbuf, accept_filter,\ndeferred, ipv6only,\nreuseport, multipath,\nor so_keepalive parameters\nare used then for a given\naddress:port pair\na separate bind() call will always be made.\n
\n\n
\nipv6only=on|off\n
\n
\nthis parameter (0.7.42) determines\n(via the IPV6_V6ONLY socket option)\nwhether an IPv6 socket listening on a wildcard address [::]\nwill accept only IPv6 connections or both IPv6 and IPv4 connections.\nThis parameter is turned on by default.\nIt can only be set once on start.\n
\nPrior to version 1.3.4,\nif this parameter was omitted then the operating system’s settings were\nin effect for the socket.\n
\n
\n\n
\nreuseport\n
\n
\nthis parameter (1.9.1) instructs to create an individual listening socket\nfor each worker process\n(using the\nSO_REUSEPORT socket option on Linux 3.9+ and DragonFly BSD,\nor SO_REUSEPORT_LB on FreeBSD 12+), allowing a kernel\nto distribute incoming connections between worker processes.\nThis currently works only on Linux 3.9+, DragonFly BSD,\nand FreeBSD 12+ (1.15.1).\n
\nInappropriate use of this option may have its security\nimplications.\n
\n
\n\n
\nmultipath\n
\n
\nthis parameter (1.29.7) configures the\nMultipath TCP\nprotocol (IPPROTO_MPTCP) for the listening socket.\nThis currently works only on Linux 5.6+.\n
\nAdding or removing this parameter will also enable\nthe SO_REUSEPORT socket option, which may have its security\nimplications.\n
\n
\n\n
\nso_keepalive=on|off|[keepidle]:[keepintvl]:[keepcnt]\n
\n
\nthis parameter (1.1.11) configures the “TCP keepalive” behavior\nfor the listening socket.\nIf this parameter is omitted then the operating system’s settings will be\nin effect for the socket.\nIf it is set to the value “on”, the\nSO_KEEPALIVE option is turned on for the socket.\nIf it is set to the value “off”, the\nSO_KEEPALIVE option is turned off for the socket.\nSome operating systems support setting of TCP keepalive parameters on\na per-socket basis using the TCP_KEEPIDLE,\nTCP_KEEPINTVL, and TCP_KEEPCNT socket options.\nOn such systems\n(currently, Linux, NetBSD, Dragonfly, FreeBSD, and macOS),\nthey can be configured\nusing the keepidle, keepintvl, and\nkeepcnt parameters.\nOne or two parameters may be omitted, in which case the system default setting\nfor the corresponding socket option will be in effect.\nFor example,\n
so_keepalive=30m::10
\nwill set the idle timeout (TCP_KEEPIDLE) to 30 minutes,\nleave the probe interval (TCP_KEEPINTVL) at its system default,\nand set the probes count (TCP_KEEPCNT) to 10 probes.\n
\n\n

\n

\nExample:\n

\nlisten 127.0.0.1 default_server accept_filter=dataready backlog=1024;\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n location [\n = |\n ~ |\n ~* |\n ^~\n ] uri { ... }
location @name { ... }
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n server, location
\n

\nSets configuration depending on a request URI.\n

\nThe matching is performed against a normalized URI,\nafter decoding the text encoded in the “%XX” form,\nresolving references to relative path components “.”\nand “..”, and possible\ncompression of two or more\nadjacent slashes into a single slash.\n

\nA location can either be defined by a prefix string, or by a regular expression.\nRegular expressions are specified with the preceding\n“~*” modifier (for case-insensitive matching), or the\n“~” modifier (for case-sensitive matching).\nTo find location matching a given request, nginx first checks\nlocations defined using the prefix strings (prefix locations).\nAmong them, the location with the longest matching\nprefix is selected and remembered.\nThen regular expressions are checked, in the order of their appearance\nin the configuration file.\nThe search of regular expressions terminates on the first match,\nand the corresponding configuration is used.\nIf no match with a regular expression is found then the\nconfiguration of the prefix location remembered earlier is used.\n

\nlocation blocks can be nested, with some exceptions\nmentioned below.\n

\nFor case-insensitive operating systems such as macOS and Cygwin,\nmatching with prefix strings ignores a case (0.7.7).\nHowever, comparison is limited to one-byte locales.\n

\nRegular expressions can contain captures (0.7.40) that can later\nbe used in other directives.\n

\nIf the longest matching prefix location has the “^~” modifier\nthen regular expressions are not checked.\n

\nAlso, using the “=” modifier it is possible to define\nan exact match of URI and location.\nIf an exact match is found, the search terminates.\nFor example, if a “/” request happens frequently,\ndefining “location = /” will speed up the processing\nof these requests, as search terminates right after the first\ncomparison.\nSuch a location cannot obviously contain nested locations.\n

\n

\nIn versions from 0.7.1 to 0.8.41, if a request matched the prefix\nlocation without the “=” and “^~”\nmodifiers, the search also terminated and regular expressions were\nnot checked.\n

\n

\nLet’s illustrate the above by an example:\n

\nlocation = / {\n    [ configuration A ]\n}\n\nlocation / {\n    [ configuration B ]\n}\n\nlocation /documents/ {\n    [ configuration C ]\n}\n\nlocation ^~ /images/ {\n    [ configuration D ]\n}\n\nlocation ~* \\.(gif|jpg|jpeg)$ {\n    [ configuration E ]\n}\n

\nThe “/” request will match configuration A,\nthe “/index.html” request will match configuration B,\nthe “/documents/document.html” request will match\nconfiguration C,\nthe “/images/1.gif” request will match configuration D, and\nthe “/documents/1.jpg” request will match configuration E.\n

\nThe “@” prefix defines a named location.\nSuch a location is not used for a regular request processing, but instead\nused for request redirection.\nThey cannot be nested, and cannot contain nested locations.\n

\nIf a location is defined by a prefix string that ends with the slash character,\nand requests are processed by one of\nproxy_pass,\nfastcgi_pass,\nuwsgi_pass,\nscgi_pass,\nmemcached_pass, or\ngrpc_pass,\nthen the special processing is performed.\nIn response to a request with URI equal to this string,\nbut without the trailing slash,\na permanent redirect with the code 301 will be returned to the requested URI\nwith the slash appended.\nIf this is not desired, an exact match of the URI and location could be\ndefined like this:\n

\nlocation /user/ {\n    proxy_pass http://user.example.com;\n}\n\nlocation = /user {\n    proxy_pass http://login.example.com;\n}\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n log_not_found on | off;
\n
\n Default:\n \n
log_not_found on;
\n
\n Context:\n \n http, server, location
\n

\nEnables or disables logging of errors about not found files into\nerror_log.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n log_subrequest on | off;
\n
\n Default:\n \n
log_subrequest off;
\n
\n Context:\n \n http, server, location
\n

\nEnables or disables logging of subrequests into\naccess_log.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n max_headers number;
\n
\n Default:\n \n
max_headers 1000;
\n
\n Context:\n \n http, server
\n

This directive appeared in version 1.29.8.\n

\nSets the maximum allowed number of header lines in requests.\nIf this limit is reached, the error\n400 (Bad Request)\nis returned.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n max_ranges number;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n http, server, location
\n

This directive appeared in version 1.1.2.\n

\nLimits the maximum allowed number of ranges in byte-range requests.\nRequests that exceed the limit are processed as if there were no\nbyte ranges specified.\nBy default, the number of ranges is not limited.\nThe zero value disables the byte-range support completely.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n merge_slashes on | off;
\n
\n Default:\n \n
merge_slashes on;
\n
\n Context:\n \n http, server
\n

\nEnables or disables compression of two or more adjacent slashes\nin a URI into a single slash.\n

\nNote that compression is essential for the correct matching of prefix string\nand regular expression locations.\nWithout it, the “//scripts/one.php” request would not match\n

\nlocation /scripts/ {\n    ...\n}\n

\nand might be processed as a static file.\nSo it gets converted to “/scripts/one.php”.\n

\nTurning the compression off can become necessary if a URI\ncontains base64-encoded names, since base64 uses the “/”\ncharacter internally.\nHowever, for security considerations, it is better to avoid turning\nthe compression off.\n

\nIf the directive is specified on the server level,\nthe value from the default server can be used.\nDetails are provided in the\n“Virtual\nserver selection” section.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n msie_padding on | off;
\n
\n Default:\n \n
msie_padding on;
\n
\n Context:\n \n http, server, location
\n

\nEnables or disables adding comments to responses for MSIE clients with status\ngreater than 400 to increase the response size to 512 bytes.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n msie_refresh on | off;
\n
\n Default:\n \n
msie_refresh off;
\n
\n Context:\n \n http, server, location
\n

\nEnables or disables issuing refreshes instead of redirects for MSIE clients.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n open_file_cache off;
open_file_cache \nmax=N\n[inactive=time];
\n
\n Default:\n \n
open_file_cache off;
\n
\n Context:\n \n http, server, location
\n

\nConfigures a cache that can store:\n

\n

\nThe directive has the following parameters:\n

\n\n
\nmax\n
\n
\nsets the maximum number of elements in the cache;\non cache overflow the least recently used (LRU) elements are removed;\n
\n\n
\ninactive\n
\n
\ndefines a time after which an element is removed from the cache\nif it has not been accessed during this time;\nby default, it is 60 seconds;\n
\n\n
\noff\n
\n
\ndisables the cache.\n
\n\n

\n

\nExample:\n

\nopen_file_cache          max=1000 inactive=20s;\nopen_file_cache_valid    30s;\nopen_file_cache_min_uses 2;\nopen_file_cache_errors   on;\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n open_file_cache_errors on | off;
\n
\n Default:\n \n
open_file_cache_errors off;
\n
\n Context:\n \n http, server, location
\n

\nEnables or disables caching of file lookup errors by\nopen_file_cache.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n open_file_cache_min_uses number;
\n
\n Default:\n \n
open_file_cache_min_uses 1;
\n
\n Context:\n \n http, server, location
\n

\nSets the minimum number of file accesses during\nthe period configured by the inactive parameter\nof the open_file_cache directive, required for a file\ndescriptor to remain open in the cache.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n open_file_cache_valid time;
\n
\n Default:\n \n
open_file_cache_valid 60s;
\n
\n Context:\n \n http, server, location
\n

\nSets a time after which\nopen_file_cache\nelements should be validated.\n\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n output_buffers number size;
\n
\n Default:\n \n
output_buffers 2 32k;
\n
\n Context:\n \n http, server, location
\n

\nSets the number and size of the\nbuffers used for reading a response from a disk.\n

\nPrior to version 1.9.5, the default value was 1 32k.\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n port_in_redirect on | off;
\n
\n Default:\n \n
port_in_redirect on;
\n
\n Context:\n \n http, server, location
\n

\nEnables or disables specifying the port in\nabsolute redirects issued by nginx.\n

\nThe use of the primary server name in redirects is controlled by\nthe server_name_in_redirect directive.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n postpone_output size;
\n
\n Default:\n \n
postpone_output 1460;
\n
\n Context:\n \n http, server, location
\n

\nIf possible, the transmission of client data will be postponed until\nnginx has at least size bytes of data to send.\nThe zero value disables postponing data transmission.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n read_ahead size;
\n
\n Default:\n \n
read_ahead 0;
\n
\n Context:\n \n http, server, location
\n

\nSets the amount of pre-reading for the kernel when working with file.\n

\nOn Linux, the\nposix_fadvise(0, 0, 0, POSIX_FADV_SEQUENTIAL)\nsystem call is used, and so the size parameter is ignored.\n

\nOn FreeBSD, the\nfcntl(O_READAHEAD,\nsize)\nsystem call, supported since FreeBSD 9.0-CURRENT, is used.\nFreeBSD 7 has to be\npatched.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n recursive_error_pages on | off;
\n
\n Default:\n \n
recursive_error_pages off;
\n
\n Context:\n \n http, server, location
\n

\nEnables or disables doing several redirects using the\nerror_page\ndirective.\nThe number of such redirects is limited.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n request_pool_size size;
\n
\n Default:\n \n
request_pool_size 4k;
\n
\n Context:\n \n http, server
\n

\nAllows accurate tuning of per-request memory allocations.\nThis directive has minimal impact on performance\nand should not generally be used.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n reset_timedout_connection on | off;
\n
\n Default:\n \n
reset_timedout_connection off;
\n
\n Context:\n \n http, server, location
\n

\nEnables or disables resetting timed out connections\nand connections\nclosed\nwith the non-standard code 444 (1.15.2).\nThe reset is performed as follows.\nBefore closing a socket, the\nSO_LINGER\noption is set on it with a timeout value of 0.\nWhen the socket is closed, TCP RST is sent to the client, and all memory\noccupied by this socket is released.\nThis helps avoid keeping an already closed socket with filled buffers\nin a FIN_WAIT1 state for a long time.\n

\nIt should be noted that timed out keep-alive connections are\nclosed normally.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n resolver \n address ...\n [valid=time]\n [ipv4=on|off]\n [ipv6=on|off]\n [status_zone=zone];
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n http, server, location
\n

\nConfigures name servers used to resolve names of upstream servers\ninto addresses, for example:\n

\nresolver 127.0.0.1 [::1]:5353;\n

\nThe address can be specified as a domain name or IP address,\nwith an optional port (1.3.1, 1.2.2).\nIf port is not specified, the port 53 is used.\nName servers are queried in a round-robin fashion.\n

\nBefore version 1.1.7, only a single name server could be configured.\nSpecifying name servers using IPv6 addresses is supported\nstarting from versions 1.3.1 and 1.2.2.\n

\n

\nBy default, nginx will look up both IPv4 and IPv6 addresses while resolving.\nIf looking up of IPv4 or IPv6 addresses is not desired,\nthe ipv4=off (1.23.1) or\nthe ipv6=off parameter can be specified.\n

\nResolving of names into IPv6 addresses is supported\nstarting from version 1.5.8.\n

\n

\nBy default, nginx caches answers using the TTL value of a response.\nAn optional valid parameter allows overriding it:\n

\nresolver 127.0.0.1 [::1]:5353 valid=30s;\n

\n

\nBefore version 1.1.9, tuning of caching time was not possible,\nand nginx always cached answers for the duration of 5 minutes.\n

\n

\nTo prevent DNS spoofing, it is recommended\nconfiguring DNS servers in a properly secured trusted local network.\n

\n

\nThe optional status_zone parameter (1.17.1)\nenables\ncollection\nof DNS server statistics of requests and responses\nin the specified zone.\nThe parameter is available as part of our\ncommercial subscription.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n resolver_timeout time;
\n
\n Default:\n \n
resolver_timeout 30s;
\n
\n Context:\n \n http, server, location
\n

\nSets a timeout for name resolution, for example:\n

\nresolver_timeout 5s;\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n root path;
\n
\n Default:\n \n
root html;
\n
\n Context:\n \n http, server, location, if in location
\n

\nSets the root directory for requests.\nFor example, with the following configuration\n

\nlocation /i/ {\n    root /data/w3;\n}\n

\nThe /data/w3/i/top.gif file will be sent in response to\nthe “/i/top.gif” request.\n

\nThe path value can contain variables,\nexcept $document_root and $realpath_root.\n

\nA path to the file is constructed by merely adding a URI to the value\nof the root directive.\nIf a URI has to be modified, the\nalias directive should be used.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n satisfy all | any;
\n
\n Default:\n \n
satisfy all;
\n
\n Context:\n \n http, server, location
\n

\nAllows access if all (all) or at least one\n(any) of the\nngx_http_access_module,\nngx_http_auth_basic_module,\nngx_http_auth_request_module,\nngx_http_auth_jwt_module\n(1.13.10),\nor\nngx_http_auth_oidc_module\n(1.27.4)\nmodules allow access.\n

\nExample:\n

\nlocation / {\n    satisfy any;\n\n    allow 192.168.1.0/32;\n    deny  all;\n\n    auth_basic           \"closed site\";\n    auth_basic_user_file conf/htpasswd;\n}\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n send_lowat size;
\n
\n Default:\n \n
send_lowat 0;
\n
\n Context:\n \n http, server, location
\n

\nIf the directive is set to a non-zero value, nginx will try to minimize\nthe number of send operations on client sockets by using either\nNOTE_LOWAT flag of the\nkqueue method\nor the SO_SNDLOWAT socket option.\nIn both cases the specified size is used.\n

\nThis directive is ignored on Linux, Solaris, and Windows.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n send_timeout time;
\n
\n Default:\n \n
send_timeout 60s;
\n
\n Context:\n \n http, server, location
\n

\nSets a timeout for transmitting a response to the client.\nThe timeout is set only between two successive write operations,\nnot for the transmission of the whole response.\nIf the client does not receive anything within this time,\nthe connection is closed.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n sendfile on | off;
\n
\n Default:\n \n
sendfile off;
\n
\n Context:\n \n http, server, location, if in location
\n

\nEnables or disables the use of\nsendfile().\n

\nStarting from nginx 0.8.12 and FreeBSD 5.2.1,\naio can be used to pre-load data\nfor sendfile():\n

\nlocation /video/ {\n    sendfile       on;\n    tcp_nopush     on;\n    aio            on;\n}\n

\nIn this configuration, sendfile() is called with\nthe SF_NODISKIO flag which causes it not to block on disk I/O,\nbut, instead, report back that the data are not in memory.\nnginx then initiates an asynchronous data load by reading one byte.\nOn the first read, the FreeBSD kernel loads the first 128K bytes\nof a file into memory, although next reads will only load data in 16K chunks.\nThis can be changed using the\nread_ahead directive.\n

\nBefore version 1.7.11, pre-loading could be enabled with\naio sendfile;.\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n sendfile_max_chunk size;
\n
\n Default:\n \n
sendfile_max_chunk 2m;
\n
\n Context:\n \n http, server, location
\n

\nLimits the amount of data that can be\ntransferred in a single sendfile() call.\nWithout the limit, one fast connection may seize the worker process entirely.\n

\nPrior to version 1.21.4, by default there was no limit.\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n server { ... }
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n http
\n

\nSets configuration for a virtual server.\nThere is no clear separation between IP-based (based on the IP address)\nand name-based (based on the “Host” request header field)\nvirtual servers.\nInstead, the listen directives describe all\naddresses and ports that should accept connections for the server, and the\nserver_name directive lists all server names.\nExample configurations are provided in the\n“How nginx processes a request” document.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n server_name name ...;
\n
\n Default:\n \n
server_name \"\";
\n
\n Context:\n \n server
\n

\nSets names of a virtual server, for example:\n

\nserver {\n    server_name example.com www.example.com;\n}\n

\n

\nThe first name becomes the primary server name.\n

\nServer names can include an asterisk (“*”)\nreplacing the first or last part of a name:\n

\nserver {\n    server_name example.com *.example.com www.example.*;\n}\n

\nSuch names are called wildcard names.\n

\nThe first two of the names mentioned above can be combined in one:\n

\nserver {\n    server_name .example.com;\n}\n

\n

\nIt is also possible to use regular expressions in server names,\npreceding the name with a tilde (“~”):\n

\nserver {\n    server_name www.example.com ~^www\\d+\\.example\\.com$;\n}\n

\n

\nRegular expressions can contain captures (0.7.40) that can later\nbe used in other directives:\n

\nserver {\n    server_name ~^(www\\.)?(.+)$;\n\n    location / {\n        root /sites/$2;\n    }\n}\n\nserver {\n    server_name _;\n\n    location / {\n        root /sites/default;\n    }\n}\n

\n

\nNamed captures in regular expressions create variables (0.8.25)\nthat can later be used in other directives:\n

\nserver {\n    server_name ~^(www\\.)?(?<domain>.+)$;\n\n    location / {\n        root /sites/$domain;\n    }\n}\n\nserver {\n    server_name _;\n\n    location / {\n        root /sites/default;\n    }\n}\n

\n

\nIf the directive’s parameter is set to “$hostname” (0.9.4), the\nmachine’s hostname is inserted.\n

\nIt is also possible to specify an empty server name (0.7.11):\n

\nserver {\n    server_name www.example.com \"\";\n}\n

\nIt allows this server to process requests without the “Host”\nheader field — instead of the default server — for the given address:port pair.\nThis is the default setting.\n

\nBefore 0.8.48, the machine’s hostname was used by default.\n

\n

\nThe search is performed in the following order of priority\nand terminates on the first matching variant:\n

    \n\n
  1. \nthe exact name\n
  2. \n\n
  3. \nthe longest wildcard name starting with an asterisk,\ne.g. “*.example.com”\n
  4. \n\n
  5. \nthe longest wildcard name ending with an asterisk,\ne.g. “mail.*”\n
  6. \n\n
  7. \nthe first matching regular expression\n(in order of appearance in the configuration file)\n
  8. \n\n

\n

\nDetailed description of server names is provided in a separate\nServer names document.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n server_name_in_redirect on | off;
\n
\n Default:\n \n
server_name_in_redirect off;
\n
\n Context:\n \n http, server, location
\n

\nEnables or disables the use of the primary server name, specified by the\nserver_name directive,\nin absolute redirects issued by nginx.\nWhen the use of the primary server name is disabled, the name from the\n“Host” request header field is used.\nIf this field is not present, the IP address of the server is used.\n

\nThe use of a port in redirects is controlled by\nthe port_in_redirect directive.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n server_names_hash_bucket_size size;
\n
\n Default:\n \n
server_names_hash_bucket_size 32|64|128;
\n
\n Context:\n \n http
\n

\nSets the bucket size for the server names hash tables.\nThe default value depends on the size of the processor’s cache line.\nThe details of setting up hash tables are provided in a separate\ndocument.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n server_names_hash_max_size size;
\n
\n Default:\n \n
server_names_hash_max_size 512;
\n
\n Context:\n \n http
\n

\nSets the maximum size of the server names hash tables.\nThe details of setting up hash tables are provided in a separate\ndocument.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n server_tokens \n on |\n off |\n build |\n string;
\n
\n Default:\n \n
server_tokens on;
\n
\n Context:\n \n http, server, location
\n

\nEnables or disables emitting nginx version on error pages and in the\n“Server” response header field.\n

\nThe build parameter (1.11.10) enables emitting\na build name\nalong with nginx version.\n

\nAdditionally, as part of our\ncommercial subscription,\nstarting from version 1.9.13\nthe signature on error pages and\nthe “Server” response header field value\ncan be set explicitly using the string with variables.\nAn empty string disables the emission of the “Server” field.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n subrequest_output_buffer_size size;
\n
\n Default:\n \n
subrequest_output_buffer_size 4k|8k;
\n
\n Context:\n \n http, server, location
\n

This directive appeared in version 1.13.10.\n

\nSets the size of the buffer used for\nstoring the response body of a subrequest.\nBy default, the buffer size is equal to one memory page.\nThis is either 4K or 8K, depending on a platform.\nIt can be made smaller, however.\n

\nThe directive is applicable only for subrequests\nwith response bodies saved into memory.\nFor example, such subrequests are created by\nSSI.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n tcp_nodelay on | off;
\n
\n Default:\n \n
tcp_nodelay on;
\n
\n Context:\n \n http, server, location
\n

\nEnables or disables the use of the TCP_NODELAY option.\nThe option is enabled when a connection is transitioned into the\nkeep-alive state.\nAdditionally, it is enabled on SSL connections,\nfor unbuffered proxying,\nand for WebSocket proxying.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n tcp_nopush on | off;
\n
\n Default:\n \n
tcp_nopush off;
\n
\n Context:\n \n http, server, location
\n

\nEnables or disables the use of\nthe TCP_NOPUSH socket option on FreeBSD\nor the TCP_CORK socket option on Linux.\nThe options are enabled only when sendfile is used.\nEnabling the option allows\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n try_files file ... uri;
try_files file ... =code;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n server, location
\n

\nChecks the existence of files in the specified order and uses\nthe first found file for request processing; the processing\nis performed in the current context.\nThe path to a file is constructed from the\nfile parameter\naccording to the\nroot and alias directives.\nIt is possible to check directory’s existence by specifying\na slash at the end of a name, e.g. “$uri/”.\nIf none of the files were found, an internal redirect to the\nuri specified in the last parameter is made.\nFor example:\n

\nlocation /images/ {\n    try_files $uri /images/default.gif;\n}\n\nlocation = /images/default.gif {\n    expires 30s;\n}\n

\nThe last parameter can also point to a named location,\nas shown in examples below.\nStarting from version 0.7.51, the last parameter can also be a\ncode:\n

\nlocation / {\n    try_files $uri $uri/index.html $uri.html =404;\n}\n

\n

\nExample in proxying Mongrel:\n

\nlocation / {\n    try_files /system/maintenance.html\n              $uri $uri/index.html $uri.html\n              @mongrel;\n}\n\nlocation @mongrel {\n    proxy_pass http://mongrel;\n}\n

\n

\nExample for Drupal/FastCGI:\n

\nlocation / {\n    try_files $uri $uri/ @drupal;\n}\n\nlocation ~ \\.php$ {\n    try_files $uri @drupal;\n\n    fastcgi_pass ...;\n\n    fastcgi_param SCRIPT_FILENAME /path/to$fastcgi_script_name;\n    fastcgi_param SCRIPT_NAME     $fastcgi_script_name;\n    fastcgi_param QUERY_STRING    $args;\n\n    ... other fastcgi_param's\n}\n\nlocation @drupal {\n    fastcgi_pass ...;\n\n    fastcgi_param SCRIPT_FILENAME /path/to/index.php;\n    fastcgi_param SCRIPT_NAME     /index.php;\n    fastcgi_param QUERY_STRING    q=$uri&$args;\n\n    ... other fastcgi_param's\n}\n

\nIn the following example,\n

\nlocation / {\n    try_files $uri $uri/ @drupal;\n}\n

\nthe try_files directive is equivalent to\n

\nlocation / {\n    error_page 404 = @drupal;\n    log_not_found off;\n}\n

\nAnd here,\n

\nlocation ~ \\.php$ {\n    try_files $uri @drupal;\n\n    fastcgi_pass ...;\n\n    fastcgi_param SCRIPT_FILENAME /path/to$fastcgi_script_name;\n\n    ...\n}\n

\ntry_files checks the existence of the PHP file\nbefore passing the request to the FastCGI server.\n

\nExample for Wordpress and Joomla:\n

\nlocation / {\n    try_files $uri $uri/ @wordpress;\n}\n\nlocation ~ \\.php$ {\n    try_files $uri @wordpress;\n\n    fastcgi_pass ...;\n\n    fastcgi_param SCRIPT_FILENAME /path/to$fastcgi_script_name;\n    ... other fastcgi_param's\n}\n\nlocation @wordpress {\n    fastcgi_pass ...;\n\n    fastcgi_param SCRIPT_FILENAME /path/to/index.php;\n    ... other fastcgi_param's\n}\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n types { ... }
\n
\n Default:\n \n
types {\n    text/html  html;\n    image/gif  gif;\n    image/jpeg jpg;\n}
\n
\n Context:\n \n http, server, location
\n

\nMaps file name extensions to MIME types of responses.\nExtensions are case-insensitive.\nSeveral extensions can be mapped to one type, for example:\n

\ntypes {\n    application/octet-stream bin exe dll;\n    application/octet-stream deb;\n    application/octet-stream dmg;\n}\n

\n

\nA sufficiently full mapping table is distributed with nginx in the\nconf/mime.types file.\n

\nTo make a particular location emit the\n“application/octet-stream”\nMIME type for all requests, the following configuration can be used:\n

\nlocation /download/ {\n    types        { }\n    default_type application/octet-stream;\n}\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n types_hash_bucket_size size;
\n
\n Default:\n \n
types_hash_bucket_size 64;
\n
\n Context:\n \n http, server, location
\n

\nSets the bucket size for the types hash tables.\nThe details of setting up hash tables are provided in a separate\ndocument.\n

\nPrior to version 1.5.13,\nthe default value depended on the size of the processor’s cache line.\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n types_hash_max_size size;
\n
\n Default:\n \n
types_hash_max_size 1024;
\n
\n Context:\n \n http, server, location
\n

\nSets the maximum size of the types hash tables.\nThe details of setting up hash tables are provided in a separate\ndocument.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n underscores_in_headers on | off;
\n
\n Default:\n \n
underscores_in_headers off;
\n
\n Context:\n \n http, server
\n

\nEnables or disables the use of underscores in client request header fields.\nWhen the use of underscores is disabled, request header fields whose names\ncontain underscores are\nmarked as invalid and become subject to the\nignore_invalid_headers directive.\n

\nIf the directive is specified on the server level,\nthe value from the default server can be used.\nDetails are provided in the\n“Virtual\nserver selection” section.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n variables_hash_bucket_size size;
\n
\n Default:\n \n
variables_hash_bucket_size 64;
\n
\n Context:\n \n http
\n

\nSets the bucket size for the variables hash table.\nThe details of setting up hash tables are provided in a separate\ndocument.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n variables_hash_max_size size;
\n
\n Default:\n \n
variables_hash_max_size 1024;
\n
\n Context:\n \n http
\n

\nSets the maximum size of the variables hash table.\nThe details of setting up hash tables are provided in a separate\ndocument.\n

\nPrior to version 1.5.13, the default value was 512.\n

\n

\n\n\n

Embedded Variables

\nThe ngx_http_core_module module supports embedded variables\nwith names matching the Apache Server variables.\nFirst of all, these are variables representing client request header\nfields, such as $http_user_agent, $http_cookie,\nand so on.\nAlso there are other variables:\n

\n\n
$arg_name
\n
\nargument name in the request line\n
\n\n
$args
\n
\narguments in the request line\n
\n\n
$binary_remote_addr
\n
\nclient address in a binary form, value’s length is always 4 bytes\nfor IPv4 addresses or 16 bytes for IPv6 addresses\n
\n\n
$body_bytes_sent
\n
\nnumber of bytes sent to a client, not counting the response header;\nthis variable is compatible with the “%B” parameter of the\nmod_log_config\nApache module\n
\n\n
$bytes_sent
\n
\nnumber of bytes sent to a client (1.3.8, 1.2.5)\n
\n\n
$connection
\n
\nconnection serial number (1.3.8, 1.2.5)\n
\n\n
$connection_requests
\n
\ncurrent number of requests made through a connection (1.3.8, 1.2.5)\n
\n\n
$connection_time
\n
\nconnection time in seconds with a milliseconds resolution (1.19.10)\n
\n\n
$content_length
\n
\n“Content-Length” request header field\n
\n\n
$content_type
\n
\n“Content-Type” request header field\n
\n\n\n
\nthe name cookie\n
\n\n
$document_root
\n
\nroot or alias directive’s value\nfor the current request\n
\n\n
$document_uri
\n
\nsame as $uri\n
\n\n
$host
\n
\nin this order of precedence:\nhost name from the request line, or\nhost name from the “Host” request header field, or\nthe server name matching a request\n
\n\n
$hostname
\n
\nhost name\n
\n\n
$http_name
\n
\narbitrary request header field;\nthe last part of a variable name is the field name converted\nto lower case with dashes replaced by underscores\n
\n\n
$https
\n
\n“on”\nif connection operates in SSL mode,\nor an empty string otherwise\n
\n\n
$is_args
\n
\n“?” if a request line has arguments,\nor an empty string otherwise\n
\n\n
$is_request_port
\n
\n“:” if\n$request_port is non-empty,\nor an empty string otherwise (1.29.3)\n
\n\n
$limit_rate
\n
\nsetting this variable enables response rate limiting;\nsee limit_rate\n
\n\n
$msec
\n
\ncurrent time in seconds with the milliseconds resolution (1.3.9, 1.2.6)\n
\n\n
$nginx_version
\n
\nnginx version\n
\n\n
$pid
\n
\nPID of the worker process\n
\n\n
$pipe
\n
\n“p” if request was pipelined, “.”\notherwise (1.3.12, 1.2.7)\n
\n\n
$proxy_protocol_addr
\n
\nclient address from the PROXY protocol header (1.5.12)\n

\nThe PROXY protocol must be previously enabled by setting the\nproxy_protocol parameter\nin the listen directive.\n

\n
\n\n
$proxy_protocol_port
\n
\nclient port from the PROXY protocol header (1.11.0)\n

\nThe PROXY protocol must be previously enabled by setting the\nproxy_protocol parameter\nin the listen directive.\n

\n
\n\n
$proxy_protocol_server_addr
\n
\nserver address from the PROXY protocol header (1.17.6)\n

\nThe PROXY protocol must be previously enabled by setting the\nproxy_protocol parameter\nin the listen directive.\n

\n
\n\n
$proxy_protocol_server_port
\n
\nserver port from the PROXY protocol header (1.17.6)\n

\nThe PROXY protocol must be previously enabled by setting the\nproxy_protocol parameter\nin the listen directive.\n

\n
\n\n
$proxy_protocol_tlv_name
\n
\nTLV from the PROXY Protocol header (1.23.2).\nThe name can be a TLV type name or its numeric value.\nIn the latter case, the value is hexadecimal\nand should be prefixed with 0x:\n\n
\n$proxy_protocol_tlv_alpn\n$proxy_protocol_tlv_0x01\n
\nSSL TLVs can also be accessed by TLV type name\nor its numeric value,\nboth prefixed by ssl_:\n
\n$proxy_protocol_tlv_ssl_version\n$proxy_protocol_tlv_ssl_0x21\n
\n\n

\nThe following TLV type names are supported:\n

    \n\n
  • \nalpn (0x01) - \nupper layer protocol used over the connection\n
  • \n\n
  • \nauthority (0x02) - \nhost name value passed by the client\n
  • \n\n
  • \nunique_id (0x05) - \nunique connection id\n
  • \n\n
  • \nnetns (0x30) - \nname of the namespace\n
  • \n\n
  • \nssl (0x20) - \nbinary SSL TLV structure\n
  • \n\n

\n

\n\n

\nThe following SSL TLV type names are supported:\n

    \n\n
  • \nssl_version (0x21) - \nSSL version used in client connection\n
  • \n\n
  • \nssl_cn (0x22) - \nSSL certificate Common Name\n
  • \n\n
  • \nssl_cipher (0x23) - \nname of the used cipher\n
  • \n\n
  • \nssl_sig_alg (0x24) - \nalgorithm used to sign the certificate\n
  • \n\n
  • \nssl_key_alg (0x25) - \npublic-key algorithm\n
  • \n\n

\n

\n\n

\nAlso, the following special SSL TLV type name is supported:\n

    \n\n
  • \nssl_verify - \nclient SSL certificate verification result,\n0 if the client presented a certificate\nand it was successfully verified,\nnon-zero otherwise.\n
  • \n\n

\n

\n\n

\nThe PROXY protocol must be previously enabled by setting the\nproxy_protocol parameter\nin the listen directive.\n

\n
\n\n
$query_string
\n
\nsame as $args\n
\n\n
$realpath_root
\n
\nan absolute pathname corresponding to the\nroot or alias directive’s value\nfor the current request,\nwith all symbolic links resolved to real paths\n
\n\n
$remote_addr
\n
\nclient address\n
\n\n
$remote_port
\n
\nclient port\n
\n\n
$remote_user
\n
\nuser name supplied with the Basic authentication\n
\n\n
$request
\n
\nfull original request line\n
\n\n
$request_body
\n
\nrequest body\n

\nThe variable’s value is made available in locations\nprocessed by the\nproxy_pass,\nfastcgi_pass,\nuwsgi_pass,\nand\nscgi_pass\ndirectives when the request body was read to\na memory buffer.\n

\n
\n\n
$request_body_file
\n
\nname of a temporary file with the request body\n

\nAt the end of processing, the file needs to be removed.\nTo always write the request body to a file,\nclient_body_in_file_only needs to be enabled.\nWhen the name of a temporary file is passed in a proxied request\nor in a request to a FastCGI/uwsgi/SCGI server,\npassing the request body should be disabled by the\n\nproxy_pass_request_body off,\n\nfastcgi_pass_request_body off,\n\nuwsgi_pass_request_body off, or\n\nscgi_pass_request_body off\ndirectives, respectively.\n

\n
\n\n
$request_completion
\n
\n“OK” if a request has completed,\nor an empty string otherwise\n
\n\n
$request_filename
\n
\nfile path for the current request, based on the\nroot or alias\ndirectives, and the request URI\n
\n\n
$request_id
\n
\nunique request identifier\ngenerated from 16 random bytes, in hexadecimal (1.11.0)\n
\n\n
$request_length
\n
\nrequest length (including request line, header, and request body)\n(1.3.12, 1.2.7)\n
\n\n
$request_method
\n
\nrequest method, usually\n“GET” or “POST”\n
\n\n
$request_port
\n
\nin this order of precedence:\nport number from the\nURI\nauthority component, or\nport number from the “Host” request header field (1.29.3)\n
\n\n
$request_time
\n
\nrequest processing time in seconds with a milliseconds resolution\n(1.3.9, 1.2.6);\ntime elapsed since the first bytes were read from the client\n
\n\n
$request_uri
\n
\nfull original request URI (with arguments)\n
\n\n
$scheme
\n
\nrequest scheme, “http” or “https”\n
\n\n
$sent_http_name
\n
\narbitrary response header field;\nthe last part of a variable name is the field name converted\nto lower case with dashes replaced by underscores\n
\n\n
$sent_trailer_name
\n
\narbitrary field sent at the end of the response (1.13.2);\nthe last part of a variable name is the field name converted\nto lower case with dashes replaced by underscores\n
\n\n
$server_addr
\n
\nan address of the server which accepted a request\n

\nComputing a value of this variable usually requires one system call.\nTo avoid a system call, the listen directives\nmust specify addresses and use the bind parameter.\n

\n
\n\n
$server_name
\n
\nname of the server which accepted a request\n
\n\n
$server_port
\n
\nport of the server which accepted a request\n
\n\n
$server_protocol
\n
\nrequest protocol, usually\n“HTTP/1.0”,\n“HTTP/1.1”,\n“HTTP/2.0”,\nor\n“HTTP/3.0”\n
\n\n
$status
\n
\nresponse status (1.3.2, 1.2.2)\n
\n\n
\n$tcpinfo_rtt,\n$tcpinfo_rttvar,\n$tcpinfo_snd_cwnd,\n$tcpinfo_rcv_space\n
\n
\ninformation about the client TCP connection; available on systems\nthat support the TCP_INFO socket option\n
\n\n
$time_iso8601
\n
\nlocal time in the ISO 8601 standard format (1.3.12, 1.2.7)\n
\n\n
$time_iso8601_ms
\n
\nlocal time in the ISO 8601 standard format\nwith a millisecond resolution (1.29.8)\n

\n

\nThis variable is available as part of our\ncommercial subscription.\n

\n

\n
\n\n
$time_local
\n
\nlocal time in the Common Log Format (1.3.12, 1.2.7)\n
\n\n
$uri
\n
\ncurrent URI in request, normalized\n

\nThe value of $uri may change during request processing,\ne.g. when doing internal redirects, or when using index files.\n

\n
\n\n

\n

\n\n
\n", "encoding": "utf-8"} +{"path": "en\\docs\\http\\ngx_http_dav_module.html", "extension": ".html", "size_bytes": 9089, "content": "\nModule ngx_http_dav_module
\n\nPlanning your ingress-nginx migration? Start here:\nkubernetes.nginx.org.\n\n

Module ngx_http_dav_module

Example Configuration
Directives
     create_full_put_path
     dav_access
     dav_methods
     min_delete_depth
\n\n

\nThe ngx_http_dav_module module is intended for file\nmanagement automation via the WebDAV protocol.\nThe module processes HTTP and WebDAV\nmethods PUT, DELETE, MKCOL, COPY, and MOVE.\n

\nThis module is not built by default, it should be enabled with the\n--with-http_dav_module\nconfiguration parameter.\n

\n

\nWebDAV clients that require additional WebDAV methods to operate\nwill not work with this module.\n

\n

\n\n\n

Example Configuration

\n

\nlocation / {\n    root                  /data/www;\n\n    client_body_temp_path /data/client_temp;\n\n    dav_methods PUT DELETE MKCOL COPY MOVE;\n\n    create_full_put_path  on;\n    dav_access            group:rw  all:r;\n\n    limit_except GET {\n        allow 192.168.1.0/32;\n        deny  all;\n    }\n}\n

\n

\n\n\n

Directives

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n create_full_put_path on | off;
\n
\n Default:\n \n
create_full_put_path off;
\n
\n Context:\n \n http, server, location
\n

\nThe WebDAV specification only allows creating files in already\nexisting directories.\nThis directive allows creating all needed intermediate directories.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n dav_access users:permissions ...;
\n
\n Default:\n \n
dav_access user:rw;
\n
\n Context:\n \n http, server, location
\n

\nSets access permissions for newly created files and directories, e.g.:\n

\ndav_access user:rw group:rw all:r;\n

\n

\nIf any group or all access permissions\nare specified then user permissions may be omitted:\n

\ndav_access group:rw all:r;\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n dav_methods \n off | method ...;
\n
\n Default:\n \n
dav_methods off;
\n
\n Context:\n \n http, server, location
\n

\nAllows the specified HTTP and WebDAV methods.\nThe parameter off denies all methods processed\nby this module.\nThe following methods are supported:\nPUT, DELETE, MKCOL,\nCOPY, and MOVE.\n

\nA file uploaded with the PUT method is first written to a temporary file,\nand then the file is renamed.\nStarting from version 0.8.9, temporary files and the persistent store\ncan be put on different file systems.\nHowever, be aware that in this case a file is copied\nacross two file systems instead of the cheap renaming operation.\nIt is thus recommended that for any given location both saved files and a\ndirectory holding temporary files, set by the\nclient_body_temp_path\ndirective, are put on the same file system.\n

\nWhen creating a file with the PUT method, it is possible to specify\nthe modification date by passing it in the “Date”\nheader field.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n min_delete_depth number;
\n
\n Default:\n \n
min_delete_depth 0;
\n
\n Context:\n \n http, server, location
\n

\nAllows the DELETE method to remove files provided that\nthe number of elements in a request path is not less than the specified\nnumber.\nFor example, the directive\n

\nmin_delete_depth 4;\n

\nallows removing files on requests\n

\n/users/00/00/name\n/users/00/00/name/pic.jpg\n/users/00/00/page.html\n

\nand denies the removal of\n

\n/users/00/00\n

\n

\n\n
\n", "encoding": "utf-8"} +{"path": "en\\docs\\http\\ngx_http_empty_gif_module.html", "extension": ".html", "size_bytes": 3671, "content": "\nModule ngx_http_empty_gif_module
\n\nPlanning your ingress-nginx migration? Start here:\nkubernetes.nginx.org.\n\n

Module ngx_http_empty_gif_module

Example Configuration
Directives
     empty_gif
\n\n

\nThe ngx_http_empty_gif_module module emits\nsingle-pixel transparent GIF.\n

\n\n\n

Example Configuration

\n

\nlocation = /_.gif {\n    empty_gif;\n}\n

\n

\n\n\n

Directives

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n empty_gif;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n location
\n

\nTurns on module processing in a surrounding location.\n

\n\n
\n", "encoding": "utf-8"} +{"path": "en\\docs\\http\\ngx_http_f4f_module.html", "extension": ".html", "size_bytes": 5240, "content": "\nModule ngx_http_f4f_module
\n\nPlanning your ingress-nginx migration? Start here:\nkubernetes.nginx.org.\n\n

Module ngx_http_f4f_module

Example Configuration
Directives
     f4f
     f4f_buffer_size
\n\n

\nThe ngx_http_f4f_module module provides\nserver-side support for Adobe HTTP Dynamic Streaming (HDS).\n

\nThis module implements handling of HTTP Dynamic Streaming requests in the\n“/videoSeg1-Frag1” form — extracting the needed fragment\nfrom the videoSeg1.f4f file using the videoSeg1.f4x\nindex file.\nThis module is an alternative to the Adobe’s f4f module (HTTP Origin Module)\nfor Apache.\n

\nUsual pre-processing with Adobe’s f4fpackager is required, see relevant\ndocumentation for details.\n

\n

\nThis module is available as part of our\ncommercial subscription.\n

\n

\n\n\n

Example Configuration

\n

\nlocation /video/ {\n    f4f;\n    ...\n}\n

\n

\n\n\n

Directives

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n f4f;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n location
\n

\nTurns on module processing in the surrounding location.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n f4f_buffer_size size;
\n
\n Default:\n \n
f4f_buffer_size 512k;
\n
\n Context:\n \n http, server, location
\n

\nSets the size of the buffer used for\nreading the .f4x index file.\n

\n\n
\n", "encoding": "utf-8"} +{"path": "en\\docs\\http\\ngx_http_fastcgi_module.html", "extension": ".html", "size_bytes": 94488, "content": "\nModule ngx_http_fastcgi_module
\n\nPlanning your ingress-nginx migration? Start here:\nkubernetes.nginx.org.\n\n

Module ngx_http_fastcgi_module

Example Configuration
Directives
     fastcgi_allow_upstream
     fastcgi_bind
     fastcgi_bind_dynamic
     fastcgi_buffer_size
     fastcgi_buffering
     fastcgi_buffers
     fastcgi_busy_buffers_size
     fastcgi_cache
     fastcgi_cache_background_update
     fastcgi_cache_bypass
     fastcgi_cache_key
     fastcgi_cache_lock
     fastcgi_cache_lock_age
     fastcgi_cache_lock_timeout
     fastcgi_cache_max_range_offset
     fastcgi_cache_methods
     fastcgi_cache_min_uses
     fastcgi_cache_path
     fastcgi_cache_purge
     fastcgi_cache_revalidate
     fastcgi_cache_use_stale
     fastcgi_cache_valid
     fastcgi_catch_stderr
     fastcgi_connect_timeout
     fastcgi_force_ranges
     fastcgi_hide_header
     fastcgi_ignore_client_abort
     fastcgi_ignore_headers
     fastcgi_index
     fastcgi_intercept_errors
     fastcgi_keep_conn
     fastcgi_limit_rate
     fastcgi_max_temp_file_size
     fastcgi_next_upstream
     fastcgi_next_upstream_timeout
     fastcgi_next_upstream_tries
     fastcgi_no_cache
     fastcgi_param
     fastcgi_pass
     fastcgi_pass_header
     fastcgi_pass_request_body
     fastcgi_pass_request_headers
     fastcgi_read_timeout
     fastcgi_request_buffering
     fastcgi_request_dynamic
     fastcgi_send_lowat
     fastcgi_send_timeout
     fastcgi_socket_keepalive
     fastcgi_split_path_info
     fastcgi_store
     fastcgi_store_access
     fastcgi_temp_file_write_size
     fastcgi_temp_path
Parameters Passed to a FastCGI Server
Embedded Variables
\n\n

\nThe ngx_http_fastcgi_module module allows passing\nrequests to a FastCGI server.\n

\n\n\n

Example Configuration

\n

\nlocation / {\n    fastcgi_pass  localhost:9000;\n    fastcgi_index index.php;\n\n    fastcgi_param SCRIPT_FILENAME /home/www/scripts/php$fastcgi_script_name;\n    fastcgi_param QUERY_STRING    $query_string;\n    fastcgi_param REQUEST_METHOD  $request_method;\n    fastcgi_param CONTENT_TYPE    $content_type;\n    fastcgi_param CONTENT_LENGTH  $content_length;\n}\n

\n

\n\n\n

Directives

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n fastcgi_allow_upstream string ...;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n http, server, location
\n

This directive appeared in version 1.29.3.\n

\nDefines conditions under which access to a FastCGI server\nis allowed or denied.\nIf all string parameters are not empty\nand not equal to “0” then the access is allowed.\nThe conditions are evaluated each time\nbefore a connection to a FastCGI server is established.\nParameter values can contain variables:\n

\ngeo $upstream_last_addr $allow {\n    volatile;\n    10.10.0.0/24        1;\n}\n\nserver {\n    listen 127.0.0.1:8080;\n\n    location / {\n        fastcgi_pass           localhost:9000;\n        fastcgi_allow_upstream $allow;\n        ...\n    }\n}\n

\n

\n

\nThis directive is available as part of our\ncommercial subscription.\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n fastcgi_bind \n address\n [transparent] |\n off;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n http, server, location
\n

This directive appeared in version 0.8.22.\n

\nMakes outgoing connections to a FastCGI server originate\nfrom the specified local IP address with an optional port (1.11.2).\nParameter value can contain variables (1.3.12).\nThe special value off (1.3.12) cancels the effect\nof the fastcgi_bind directive\ninherited from the previous configuration level, which allows the\nsystem to auto-assign the local IP address and port.\n

\nThe transparent parameter (1.11.0) allows\noutgoing connections to a FastCGI server originate\nfrom a non-local IP address,\nfor example, from a real IP address of a client:\n

\nfastcgi_bind $remote_addr transparent;\n

\nIn order for this parameter to work,\nit is usually necessary to run nginx worker processes with the\nsuperuser privileges.\nOn Linux it is not required (1.13.8) as if\nthe transparent parameter is specified, worker processes\ninherit the CAP_NET_RAW capability from the master process.\nIt is also necessary to configure kernel routing table\nto intercept network traffic from the FastCGI server.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n fastcgi_bind_dynamic on | off;
\n
\n Default:\n \n
fastcgi_bind_dynamic off;
\n
\n Context:\n \n http, server, location
\n

This directive appeared in version 1.29.3.\n

\nWhen enabled, makes the bind operation\nat each connection attempt.\n

\n

\nThis directive is available as part of our\ncommercial subscription.\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n fastcgi_buffer_size size;
\n
\n Default:\n \n
fastcgi_buffer_size 4k|8k;
\n
\n Context:\n \n http, server, location
\n

\nSets the size of the buffer used for reading the first part\nof the response received from the FastCGI server.\nThis part usually contains a small response header;\nif it exceeds the buffer size, the response is considered\ninvalid.\nBy default, the buffer size is equal to one memory page.\nThis is either 4K or 8K, depending on a platform.\nIt can be made smaller, however.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n fastcgi_buffering on | off;
\n
\n Default:\n \n
fastcgi_buffering on;
\n
\n Context:\n \n http, server, location
\n

This directive appeared in version 1.5.6.\n

\nEnables or disables buffering of responses from the FastCGI server.\n

\nWhen buffering is enabled, nginx receives a response from the FastCGI server\nas soon as possible, saving it into the buffers set by the\nfastcgi_buffer_size and fastcgi_buffers directives.\nIf the whole response does not fit into memory, a part of it can be saved\nto a temporary file on the disk.\nWriting to temporary files is controlled by the\nfastcgi_max_temp_file_size and\nfastcgi_temp_file_write_size directives.\n

\nWhen buffering is disabled, the response is passed to a client synchronously,\nimmediately as it is received.\nnginx will not try to read the whole response from the FastCGI server.\nThe maximum size of the data that nginx can receive from the server\nat a time is set by the fastcgi_buffer_size directive.\n

\nBuffering can also be enabled or disabled by passing\n“yes” or “no” in the\n“X-Accel-Buffering” response header field.\nThis capability can be disabled using the\nfastcgi_ignore_headers directive.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n fastcgi_buffers number size;
\n
\n Default:\n \n
fastcgi_buffers 8 4k|8k;
\n
\n Context:\n \n http, server, location
\n

\nSets the number and size of the\nbuffers used for reading a response from the FastCGI server,\nfor a single connection.\nBy default, the buffer size is equal to one memory page.\nThis is either 4K or 8K, depending on a platform.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n fastcgi_busy_buffers_size size;
\n
\n Default:\n \n
fastcgi_busy_buffers_size 8k|16k;
\n
\n Context:\n \n http, server, location
\n

\nWhen buffering of responses from the FastCGI\nserver is enabled, limits the total size of buffers that\ncan be busy sending a response to the client while the response is not\nyet fully read.\nIn the meantime, the rest of the buffers can be used for reading the response\nand, if needed, buffering part of the response to a temporary file.\nBy default, size is limited by the size of two buffers set by the\nfastcgi_buffer_size and fastcgi_buffers directives.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n fastcgi_cache zone | off;
\n
\n Default:\n \n
fastcgi_cache off;
\n
\n Context:\n \n http, server, location
\n

\nDefines a shared memory zone used for caching.\nThe same zone can be used in several places.\nParameter value can contain variables (1.7.9).\nThe off parameter disables caching inherited\nfrom the previous configuration level.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n fastcgi_cache_background_update on | off;
\n
\n Default:\n \n
fastcgi_cache_background_update off;
\n
\n Context:\n \n http, server, location
\n

This directive appeared in version 1.11.10.\n

\nAllows starting a background subrequest\nto update an expired cache item,\nwhile a stale cached response is returned to the client.\nNote that it is necessary to\nallow\nthe usage of a stale cached response when it is being updated.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n fastcgi_cache_bypass string ...;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n http, server, location
\n

\nDefines conditions under which the response will not be taken from a cache.\nIf at least one value of the string parameters is not empty and is not\nequal to “0” then the response will not be taken from the cache:\n

\nfastcgi_cache_bypass $cookie_nocache $arg_nocache$arg_comment;\nfastcgi_cache_bypass $http_pragma    $http_authorization;\n

\nCan be used along with the fastcgi_no_cache directive.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n fastcgi_cache_key string;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n http, server, location
\n

\nDefines a key for caching, for example\n

\nfastcgi_cache_key localhost:9000$request_uri;\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n fastcgi_cache_lock on | off;
\n
\n Default:\n \n
fastcgi_cache_lock off;
\n
\n Context:\n \n http, server, location
\n

This directive appeared in version 1.1.12.\n

\nWhen enabled, only one request at a time will be allowed to populate\na new cache element identified according to the fastcgi_cache_key\ndirective by passing a request to a FastCGI server.\nOther requests of the same cache element will either wait\nfor a response to appear in the cache or the cache lock for\nthis element to be released, up to the time set by the\nfastcgi_cache_lock_timeout directive.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n fastcgi_cache_lock_age time;
\n
\n Default:\n \n
fastcgi_cache_lock_age 5s;
\n
\n Context:\n \n http, server, location
\n

This directive appeared in version 1.7.8.\n

\nIf the last request passed to the FastCGI server\nfor populating a new cache element\nhas not completed for the specified time,\none more request may be passed to the FastCGI server.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n fastcgi_cache_lock_timeout time;
\n
\n Default:\n \n
fastcgi_cache_lock_timeout 5s;
\n
\n Context:\n \n http, server, location
\n

This directive appeared in version 1.1.12.\n

\nSets a timeout for fastcgi_cache_lock.\nWhen the time expires,\nthe request will be passed to the FastCGI server,\nhowever, the response will not be cached.\n

\nBefore 1.7.8, the response could be cached.\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n fastcgi_cache_max_range_offset number;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n http, server, location
\n

This directive appeared in version 1.11.6.\n

\nSets an offset in bytes for byte-range requests.\nIf the range is beyond the offset,\nthe range request will be passed to the FastCGI server\nand the response will not be cached.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n fastcgi_cache_methods \n GET |\n HEAD |\n POST\n ...;
\n
\n Default:\n \n
fastcgi_cache_methods GET HEAD;
\n
\n Context:\n \n http, server, location
\n

This directive appeared in version 0.7.59.\n

\nIf the client request method is listed in this directive then\nthe response will be cached.\n“GET” and “HEAD” methods are always\nadded to the list, though it is recommended to specify them explicitly.\nSee also the fastcgi_no_cache directive.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n fastcgi_cache_min_uses number;
\n
\n Default:\n \n
fastcgi_cache_min_uses 1;
\n
\n Context:\n \n http, server, location
\n

\nSets the number of requests after which the response\nwill be cached.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n fastcgi_cache_path \n path\n [levels=levels]\n [use_temp_path=on|off]\n keys_zone=name:size\n [inactive=time]\n [max_size=size]\n [min_free=size]\n [manager_files=number]\n [manager_sleep=time]\n [manager_threshold=time]\n [loader_files=number]\n [loader_sleep=time]\n [loader_threshold=time]\n [purger=on|off]\n [purger_files=number]\n [purger_sleep=time]\n [purger_threshold=time];
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n http
\n

\nSets the path and other parameters of a cache.\nCache data are stored in files.\nBoth the key and file name in a cache are a result of\napplying the MD5 function to the proxied URL.\n\nThe levels parameter defines hierarchy levels of a cache:\nfrom 1 to 3, each level accepts values 1 or 2.\nFor example, in the following configuration\n

\nfastcgi_cache_path /data/nginx/cache levels=1:2 keys_zone=one:10m;\n

\nfile names in a cache will look like this:\n

\n/data/nginx/cache/c/29/b7f54b2df7773722d382f4809d65029c\n

\n

\nA cached response is first written to a temporary file,\nand then the file is renamed.\nStarting from version 0.8.9, temporary files and the cache can be put on\ndifferent file systems.\nHowever, be aware that in this case a file is copied\nacross two file systems instead of the cheap renaming operation.\nIt is thus recommended that for any given location both cache and a directory\nholding temporary files\nare put on the same file system.\nA directory for temporary files is set based on\nthe use_temp_path parameter (1.7.10).\nIf this parameter is omitted or set to the value on,\nthe directory set by the fastcgi_temp_path directive\nfor the given location will be used.\nIf the value is set to off,\ntemporary files will be put directly in the cache directory.\n

\nIn addition, all active keys and information about data are stored\nin a shared memory zone, whose name and size\nare configured by the keys_zone parameter.\nOne megabyte zone can store about 8 thousand keys.\n

\nAs part of\ncommercial subscription,\nthe shared memory zone also stores extended\ncache information,\nthus, it is required to specify a larger zone size for the same number of keys.\nFor example,\none megabyte zone can store about 4 thousand keys.\n

\n

\nCached data that are not accessed during the time specified by the\ninactive parameter get removed from the cache\nregardless of their freshness.\nBy default, inactive is set to 10 minutes.\n

\nThe special “cache manager” process monitors the maximum cache size set\nby the max_size parameter,\nand the minimum amount of free space set\nby the min_free (1.19.1) parameter\non the file system with cache.\nWhen the size is exceeded or there is not enough free space,\nit removes the least recently used data.\nThe data is removed in iterations configured by\nmanager_files,\nmanager_threshold, and\nmanager_sleep parameters (1.11.5).\nDuring one iteration no more than manager_files items\nare deleted (by default, 100).\nThe duration of one iteration is limited by the\nmanager_threshold parameter (by default, 200 milliseconds).\nBetween iterations, a pause configured by the manager_sleep\nparameter (by default, 50 milliseconds) is made.\n

\nA minute after the start the special “cache loader” process is activated.\nIt loads information about previously cached data stored on file system\ninto a cache zone.\nThe loading is also done in iterations.\nDuring one iteration no more than loader_files items\nare loaded (by default, 100).\nBesides, the duration of one iteration is limited by the\nloader_threshold parameter (by default, 200 milliseconds).\nBetween iterations, a pause configured by the loader_sleep\nparameter (by default, 50 milliseconds) is made.\n

\nAdditionally,\nthe following parameters are available as part of our\ncommercial subscription:\n

\n

\n\n
\npurger=on|off\n
\n
\nInstructs whether cache entries that match a\nwildcard key\nwill be removed from the disk by the cache purger (1.7.12).\nSetting the parameter to on\n(default is off)\nwill activate the “cache purger” process that\npermanently iterates through all cache entries\nand deletes the entries that match the wildcard key.\n
\n\n
\npurger_files=number\n
\n
\nSets the number of items that will be scanned during one iteration (1.7.12).\nBy default, purger_files is set to 10.\n
\n\n
\npurger_threshold=number\n
\n
\nSets the duration of one iteration (1.7.12).\nBy default, purger_threshold is set to 50 milliseconds.\n
\n\n
\npurger_sleep=number\n
\n
\nSets a pause between iterations (1.7.12).\nBy default, purger_sleep is set to 50 milliseconds.\n
\n\n

\n

\n

\nIn versions 1.7.3, 1.7.7, and 1.11.10 cache header format has been changed.\nPreviously cached responses will be considered invalid\nafter upgrading to a newer nginx version.\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n fastcgi_cache_purge string ...;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n http, server, location
\n

This directive appeared in version 1.5.7.\n

\nDefines conditions under which the request will be considered a cache\npurge request.\nIf at least one value of the string parameters is not empty and is not equal\nto “0” then the cache entry with a corresponding\ncache key is removed.\nThe result of successful operation is indicated by returning\nthe 204 (No Content) response.\n

\nIf the cache key of a purge request ends\nwith an asterisk (“*”), all cache entries matching the\nwildcard key will be removed from the cache.\nHowever, these entries will remain on the disk until they are deleted\nfor either inactivity,\nor processed by the cache purger (1.7.12),\nor a client attempts to access them.\n

\nExample configuration:\n

\nfastcgi_cache_path /data/nginx/cache keys_zone=cache_zone:10m;\n\nmap $request_method $purge_method {\n    PURGE   1;\n    default 0;\n}\n\nserver {\n    ...\n    location / {\n        fastcgi_pass        backend;\n        fastcgi_cache       cache_zone;\n        fastcgi_cache_key   $uri;\n        fastcgi_cache_purge $purge_method;\n    }\n}\n

\n

\nThis functionality is available as part of our\ncommercial subscription.\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n fastcgi_cache_revalidate on | off;
\n
\n Default:\n \n
fastcgi_cache_revalidate off;
\n
\n Context:\n \n http, server, location
\n

This directive appeared in version 1.5.7.\n

\nEnables revalidation of expired cache items using conditional requests with\nthe “If-Modified-Since” and “If-None-Match”\nheader fields.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n fastcgi_cache_use_stale \n error |\n timeout |\n invalid_header |\n updating |\n http_500 |\n http_503 |\n http_403 |\n http_404 |\n http_429 |\n off\n ...;
\n
\n Default:\n \n
fastcgi_cache_use_stale off;
\n
\n Context:\n \n http, server, location
\n

\nDetermines in which cases a stale cached response can be used\nwhen an error occurs during communication with the FastCGI server.\nThe directive’s parameters match the parameters of the\nfastcgi_next_upstream directive.\n

\nThe error parameter also permits\nusing a stale cached response if a FastCGI server to process a request\ncannot be selected.\n

\nAdditionally, the updating parameter permits\nusing a stale cached response if it is currently being updated.\nThis allows minimizing the number of accesses to FastCGI servers\nwhen updating cached data.\n

\nUsing a stale cached response\ncan also be enabled directly in the response header\nfor a specified number of seconds after the response became stale (1.11.10).\nThis has lower priority than using the directive parameters.\n

\n

\nTo minimize the number of accesses to FastCGI servers when\npopulating a new cache element, the fastcgi_cache_lock\ndirective can be used.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n fastcgi_cache_valid [code ...] time;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n http, server, location
\n

\nSets caching time for different response codes.\nFor example, the following directives\n

\nfastcgi_cache_valid 200 302 10m;\nfastcgi_cache_valid 404      1m;\n

\nset 10 minutes of caching for responses with codes 200 and 302\nand 1 minute for responses with code 404.\n

\nIf only caching time is specified\n

\nfastcgi_cache_valid 5m;\n

\nthen only 200, 301, and 302 responses are cached.\n

\nIn addition, the any parameter can be specified\nto cache any responses:\n

\nfastcgi_cache_valid 200 302 10m;\nfastcgi_cache_valid 301      1h;\nfastcgi_cache_valid any      1m;\n

\n

\nParameters of caching can also be set directly\nin the response header.\nThis has higher priority than setting of caching time using the directive.\n

\nProcessing of one or more of these response header fields can be disabled\nusing the fastcgi_ignore_headers directive.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n fastcgi_catch_stderr string;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n http, server, location
\n

\nSets a string to search for in the error stream of a response\nreceived from a FastCGI server.\nIf the string is found then it is considered that the FastCGI\nserver has returned an invalid response.\nThis allows handling application errors in nginx, for example:\n

\nlocation /php/ {\n    fastcgi_pass backend:9000;\n    ...\n    fastcgi_catch_stderr \"PHP Fatal error\";\n    fastcgi_next_upstream error timeout invalid_header;\n}\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n fastcgi_connect_timeout time;
\n
\n Default:\n \n
fastcgi_connect_timeout 60s;
\n
\n Context:\n \n http, server, location
\n

\nDefines a timeout for establishing a connection with a FastCGI server.\nIt should be noted that this timeout cannot usually exceed 75 seconds.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n fastcgi_force_ranges on | off;
\n
\n Default:\n \n
fastcgi_force_ranges off;
\n
\n Context:\n \n http, server, location
\n

This directive appeared in version 1.7.7.\n

\nEnables byte-range support\nfor both cached and uncached responses from the FastCGI server\nregardless of the “Accept-Ranges” field in these responses.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n fastcgi_hide_header field;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n http, server, location
\n

\nBy default,\nnginx does not pass the header fields “Status” and\n“X-Accel-...” from the response of a FastCGI\nserver to a client.\nThe fastcgi_hide_header directive sets additional fields\nthat will not be passed.\nIf, on the contrary, the passing of fields needs to be permitted,\nthe fastcgi_pass_header directive can be used.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n fastcgi_ignore_client_abort on | off;
\n
\n Default:\n \n
fastcgi_ignore_client_abort off;
\n
\n Context:\n \n http, server, location
\n

\nDetermines whether the connection with a FastCGI server should be\nclosed when a client closes the connection without waiting\nfor a response.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n fastcgi_ignore_headers field ...;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n http, server, location
\n

\nDisables processing of certain response header fields from the FastCGI server.\nThe following fields can be ignored: “X-Accel-Redirect”,\n“X-Accel-Expires”, “X-Accel-Limit-Rate” (1.1.6),\n“X-Accel-Buffering” (1.1.6),\n“X-Accel-Charset” (1.1.6), “Expires”,\n“Cache-Control”, “Set-Cookie” (0.8.44),\nand “Vary” (1.7.7).\n

\nIf not disabled, processing of these header fields has the following\neffect:\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n fastcgi_index name;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n http, server, location
\n

\nSets a file name that will be appended after a URI that ends with\na slash, in the value of the $fastcgi_script_name variable.\nFor example, with these settings\n

\nfastcgi_index index.php;\nfastcgi_param SCRIPT_FILENAME /home/www/scripts/php$fastcgi_script_name;\n

\nand the “/page.php” request,\nthe SCRIPT_FILENAME parameter will be equal to\n“/home/www/scripts/php/page.php”,\nand with the “/” request it will be equal to\n“/home/www/scripts/php/index.php”.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n fastcgi_intercept_errors on | off;
\n
\n Default:\n \n
fastcgi_intercept_errors off;
\n
\n Context:\n \n http, server, location
\n

\nDetermines whether FastCGI server responses with codes greater than or equal\nto 300 should be passed to a client\nor be intercepted and redirected to nginx for processing\nwith the error_page directive.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n fastcgi_keep_conn on | off;
\n
\n Default:\n \n
fastcgi_keep_conn off;
\n
\n Context:\n \n http, server, location
\n

This directive appeared in version 1.1.4.\n

\nBy default, a FastCGI server will close a connection right after\nsending the response.\nHowever, when this directive is set to the value on,\nnginx will instruct a FastCGI server to keep connections open.\nThis is necessary, in particular, for\nkeepalive\nconnections to FastCGI servers to function.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n fastcgi_limit_rate rate;
\n
\n Default:\n \n
fastcgi_limit_rate 0;
\n
\n Context:\n \n http, server, location
\n

This directive appeared in version 1.7.7.\n

\nLimits the speed of reading the response from the FastCGI server.\nThe rate is specified in bytes per second.\nThe zero value disables rate limiting.\nThe limit is set per a request, and so if nginx simultaneously opens\ntwo connections to the FastCFI server,\nthe overall rate will be twice as much as the specified limit.\nThe limitation works only if\nbuffering of responses from the FastCGI\nserver is enabled.\nParameter value can contain variables (1.27.0).\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n fastcgi_max_temp_file_size size;
\n
\n Default:\n \n
fastcgi_max_temp_file_size 1024m;
\n
\n Context:\n \n http, server, location
\n

\nWhen buffering of responses from the FastCGI\nserver is enabled, and the whole response does not fit into the buffers\nset by the fastcgi_buffer_size and fastcgi_buffers\ndirectives, a part of the response can be saved to a temporary file.\nThis directive sets the maximum size of the temporary file.\nThe size of data written to the temporary file at a time is set\nby the fastcgi_temp_file_write_size directive.\n

\nThe zero value disables buffering of responses to temporary files.\n

\n

\nThis restriction does not apply to responses\nthat will be cached\nor stored on disk.\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n fastcgi_next_upstream \n error |\n timeout |\n denied |\n invalid_header |\n http_500 |\n http_503 |\n http_403 |\n http_404 |\n http_429 |\n non_idempotent |\n off\n ...;
\n
\n Default:\n \n
fastcgi_next_upstream error timeout;
\n
\n Context:\n \n http, server, location
\n

\nSpecifies in which cases a request should be passed to the next server:\n

\n\n
error
\n
an error occurred while establishing a connection with the\nserver, passing a request to it, or reading the response header;
\n\n
timeout
\n
a timeout has occurred while establishing a connection with the\nserver, passing a request to it, or reading the response header;
\n\n
denied
\n
the server denied\nthe connection (1.29.3);\n

\n

\nThis parameter is available as part of our\ncommercial subscription.\n

\n

\n
\n\n
invalid_header
\n
a server returned an empty or invalid response;
\n\n
http_500
\n
a server returned a response with the code 500;
\n\n
http_503
\n
a server returned a response with the code 503;
\n\n
http_403
\n
a server returned a response with the code 403;
\n\n
http_404
\n
a server returned a response with the code 404;
\n\n
http_429
\n
a server returned a response with the code 429 (1.11.13);
\n\n
non_idempotent
\n
normally, requests with a\nnon-idempotent\nmethod\n(POST, LOCK, PATCH)\nare not passed to the next server\nif a request has been sent to an upstream server (1.9.13);\nenabling this option explicitly allows retrying such requests;\n
\n\n
off
\n
disables passing a request to the next server.
\n\n

\n

\nOne should bear in mind that passing a request to the next server is\nonly possible if nothing has been sent to a client yet.\nThat is, if an error or timeout occurs in the middle of the\ntransferring of a response, fixing this is impossible.\n

\nThe directive also defines what is considered an\nunsuccessful\nattempt of communication with a server.\nThe cases of error, timeout,\ndenied and\ninvalid_header are always considered unsuccessful attempts,\neven if they are not specified in the directive.\nThe cases of http_500, http_503,\nand http_429 are\nconsidered unsuccessful attempts only if they are specified in the directive.\nThe cases of http_403 and http_404\nare never considered unsuccessful attempts.\n

\nPassing a request to the next server can be limited by\nthe number of tries\nand by time.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n fastcgi_next_upstream_timeout time;
\n
\n Default:\n \n
fastcgi_next_upstream_timeout 0;
\n
\n Context:\n \n http, server, location
\n

This directive appeared in version 1.7.5.\n

\nLimits the time during which a request can be passed to the\nnext server.\nThe 0 value turns off this limitation.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n fastcgi_next_upstream_tries number;
\n
\n Default:\n \n
fastcgi_next_upstream_tries 0;
\n
\n Context:\n \n http, server, location
\n

This directive appeared in version 1.7.5.\n

\nLimits the number of possible tries for passing a request to the\nnext server.\nThe 0 value turns off this limitation.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n fastcgi_no_cache string ...;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n http, server, location
\n

\nDefines conditions under which the response will not be saved to a cache.\nIf at least one value of the string parameters is not empty and is not\nequal to “0” then the response will not be saved:\n

\nfastcgi_no_cache $cookie_nocache $arg_nocache$arg_comment;\nfastcgi_no_cache $http_pragma    $http_authorization;\n

\nCan be used along with the fastcgi_cache_bypass directive.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n fastcgi_param \n parameter value\n [if_not_empty];
\n
\n Default:\n \n
fastcgi_param HTTP_HOST $host$is_request_port$request_port;
\n
\n Context:\n \n http, server, location
\n

\nSets a parameter that should be passed to the FastCGI server.\nThe value can contain text, variables, and their combination.\nThese directives are inherited from the previous configuration level\nif and only if there are no fastcgi_param directives\ndefined on the current level.\n

\nThe following example shows the minimum required settings for PHP:\n

\nfastcgi_param SCRIPT_FILENAME /home/www/scripts/php$fastcgi_script_name;\nfastcgi_param QUERY_STRING    $query_string;\n

\n

\nThe SCRIPT_FILENAME parameter is used in PHP for\ndetermining the script name, and the QUERY_STRING\nparameter is used to pass request parameters.\n

\nFor scripts that process POST requests, the\nfollowing three parameters are also required:\n

\nfastcgi_param REQUEST_METHOD  $request_method;\nfastcgi_param CONTENT_TYPE    $content_type;\nfastcgi_param CONTENT_LENGTH  $content_length;\n

\n

\nIf PHP was built with the --enable-force-cgi-redirect\nconfiguration parameter, the REDIRECT_STATUS parameter\nshould also be passed with the value “200”:\n

\nfastcgi_param REDIRECT_STATUS 200;\n

\n

\nIf the directive is specified with if_not_empty (1.1.11) then\nsuch a parameter will be passed to the server only if its value is not empty:\n

\nfastcgi_param HTTPS           $https if_not_empty;\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n fastcgi_pass address;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n location, if in location
\n

\nSets the address of a FastCGI server.\nThe address can be specified as a domain name or IP address,\nand a port:\n

\nfastcgi_pass localhost:9000;\n

\nor as a UNIX-domain socket path:\n

\nfastcgi_pass unix:/tmp/fastcgi.socket;\n

\n

\nIf a domain name resolves to several addresses, all of them will be\nused in a round-robin fashion.\nIn addition, an address can be specified as a\nserver group.\n

\nParameter value can contain variables.\nIn this case, if an address is specified as a domain name,\nthe name is searched among the described\nserver groups,\nand, if not found, is determined using a\nresolver.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n fastcgi_pass_header field;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n http, server, location
\n

\nPermits passing otherwise disabled header\nfields from a FastCGI server to a client.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n fastcgi_pass_request_body on | off;
\n
\n Default:\n \n
fastcgi_pass_request_body on;
\n
\n Context:\n \n http, server, location
\n

\nIndicates whether the original request body is passed\nto the FastCGI server.\nSee also the fastcgi_pass_request_headers directive.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n fastcgi_pass_request_headers on | off;
\n
\n Default:\n \n
fastcgi_pass_request_headers on;
\n
\n Context:\n \n http, server, location
\n

\nIndicates whether the header fields of the original request are passed\nto the FastCGI server.\nSee also the fastcgi_pass_request_body directive.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n fastcgi_read_timeout time;
\n
\n Default:\n \n
fastcgi_read_timeout 60s;
\n
\n Context:\n \n http, server, location
\n

\nDefines a timeout for reading a response from the FastCGI server.\nThe timeout is set only between two successive read operations,\nnot for the transmission of the whole response.\nIf the FastCGI server does not transmit anything within this time,\nthe connection is closed.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n fastcgi_request_buffering on | off;
\n
\n Default:\n \n
fastcgi_request_buffering on;
\n
\n Context:\n \n http, server, location
\n

This directive appeared in version 1.7.11.\n

\nEnables or disables buffering of a client request body.\n

\nWhen buffering is enabled, the entire request body is\nread\nfrom the client before sending the request to a FastCGI server.\n

\nWhen buffering is disabled, the request body is sent to the FastCGI server\nimmediately as it is received.\nIn this case, the request cannot be passed to the\nnext server\nif nginx already started sending the request body.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n fastcgi_request_dynamic on | off;
\n
\n Default:\n \n
fastcgi_request_dynamic off;
\n
\n Context:\n \n http, server, location
\n

This directive appeared in version 1.29.3.\n

\nEnables or disables creation of a separate request instance\nfor each FastCGI server.\nBy default, a single request is used for all FastCGI servers.\nIf enabled, a separate request instance is created,\nallowing per-server request customization.\n

\n

\nThis directive is available as part of our\ncommercial subscription.\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n fastcgi_send_lowat size;
\n
\n Default:\n \n
fastcgi_send_lowat 0;
\n
\n Context:\n \n http, server, location
\n

\nIf the directive is set to a non-zero value, nginx will try to\nminimize the number\nof send operations on outgoing connections to a FastCGI server by using either\nNOTE_LOWAT flag of the\nkqueue method,\nor the SO_SNDLOWAT socket option,\nwith the specified size.\n

\nThis directive is ignored on Linux, Solaris, and Windows.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n fastcgi_send_timeout time;
\n
\n Default:\n \n
fastcgi_send_timeout 60s;
\n
\n Context:\n \n http, server, location
\n

\nSets a timeout for transmitting a request to the FastCGI server.\nThe timeout is set only between two successive write operations,\nnot for the transmission of the whole request.\nIf the FastCGI server does not receive anything within this time,\nthe connection is closed.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n fastcgi_socket_keepalive on | off;
\n
\n Default:\n \n
fastcgi_socket_keepalive off;
\n
\n Context:\n \n http, server, location
\n

This directive appeared in version 1.15.6.\n

\nConfigures the “TCP keepalive” behavior\nfor outgoing connections to a FastCGI server.\nBy default, the operating system’s settings are in effect for the socket.\nIf the directive is set to the value “on”, the\nSO_KEEPALIVE socket option is turned on for the socket.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n fastcgi_split_path_info regex;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n location
\n

\nDefines a regular expression that captures a value for the\n$fastcgi_path_info variable.\nThe regular expression should have two captures: the first becomes\na value of the $fastcgi_script_name variable, the second\nbecomes a value of the $fastcgi_path_info variable.\nFor example, with these settings\n

\nlocation ~ ^(.+\\.php)(.*)$ {\n    fastcgi_split_path_info       ^(.+\\.php)(.*)$;\n    fastcgi_param SCRIPT_FILENAME /path/to/php$fastcgi_script_name;\n    fastcgi_param PATH_INFO       $fastcgi_path_info;\n

\nand the “/show.php/article/0001” request,\nthe SCRIPT_FILENAME parameter will be equal to\n“/path/to/php/show.php”, and the\nPATH_INFO parameter will be equal to\n“/article/0001”.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n fastcgi_store \n on |\n off |\n string;
\n
\n Default:\n \n
fastcgi_store off;
\n
\n Context:\n \n http, server, location
\n

\nEnables saving of files to a disk.\nThe on parameter saves files with paths\ncorresponding to the directives\nalias or\nroot.\nThe off parameter disables saving of files.\nIn addition, the file name can be set explicitly using the\nstring with variables:\n

\nfastcgi_store /data/www$original_uri;\n

\n

\nThe modification time of files is set according to the received\n“Last-Modified” response header field.\nThe response is first written to a temporary file,\nand then the file is renamed.\nStarting from version 0.8.9, temporary files and the persistent store\ncan be put on different file systems.\nHowever, be aware that in this case a file is copied\nacross two file systems instead of the cheap renaming operation.\nIt is thus recommended that for any given location both saved files and a\ndirectory holding temporary files, set by the fastcgi_temp_path\ndirective, are put on the same file system.\n

\nThis directive can be used to create local copies of static unchangeable\nfiles, e.g.:\n

\nlocation /images/ {\n    root                 /data/www;\n    error_page           404 = /fetch$uri;\n}\n\nlocation /fetch/ {\n    internal;\n\n    fastcgi_pass         backend:9000;\n    ...\n\n    fastcgi_store        on;\n    fastcgi_store_access user:rw group:rw all:r;\n    fastcgi_temp_path    /data/temp;\n\n    alias                /data/www/;\n}\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n fastcgi_store_access users:permissions ...;
\n
\n Default:\n \n
fastcgi_store_access user:rw;
\n
\n Context:\n \n http, server, location
\n

\nSets access permissions for newly created files and directories, e.g.:\n

\nfastcgi_store_access user:rw group:rw all:r;\n

\n

\nIf any group or all access permissions\nare specified then user permissions may be omitted:\n

\nfastcgi_store_access group:rw all:r;\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n fastcgi_temp_file_write_size size;
\n
\n Default:\n \n
fastcgi_temp_file_write_size 8k|16k;
\n
\n Context:\n \n http, server, location
\n

\nLimits the size of data written to a temporary file\nat a time, when buffering of responses from the FastCGI server\nto temporary files is enabled.\nBy default, size is limited by two buffers set by the\nfastcgi_buffer_size and fastcgi_buffers directives.\nThe maximum size of a temporary file is set by the\nfastcgi_max_temp_file_size directive.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n fastcgi_temp_path \n path\n [level1\n [level2\n [level3]]];
\n
\n Default:\n \n
fastcgi_temp_path fastcgi_temp;
\n
\n Context:\n \n http, server, location
\n

\nDefines a directory for storing temporary files\nwith data received from FastCGI servers.\nUp to three-level subdirectory hierarchy can be used underneath the specified\ndirectory.\nFor example, in the following configuration\n

\nfastcgi_temp_path /spool/nginx/fastcgi_temp 1 2;\n

\na temporary file might look like this:\n

\n/spool/nginx/fastcgi_temp/7/45/00000123457\n

\n

\nSee also the use_temp_path parameter of the\nfastcgi_cache_path directive.\n

\n\n\n

Parameters Passed to a FastCGI Server

\nHTTP request header fields are passed to a FastCGI server as parameters.\nIn applications and scripts running as FastCGI servers,\nthese parameters are usually made available as environment variables.\nFor example, the “User-Agent” header field is passed as the\nHTTP_USER_AGENT parameter.\nIn addition to HTTP request header fields, it is possible to pass arbitrary\nparameters using the fastcgi_param directive.\n

\n\n\n

Embedded Variables

\nThe ngx_http_fastcgi_module module supports embedded\nvariables that can be used to set parameters using the\nfastcgi_param directive:\n

\n\n
$fastcgi_script_name\n
\n
\nrequest URI or, if a URI ends with a slash, request URI with an index file\nname configured by the fastcgi_index directive appended to it.\nThis variable can be used to set the\nSCRIPT_FILENAME and PATH_TRANSLATED\nparameters that determine the script name in PHP.\nFor example, for the “/info/” request with the\nfollowing directives\n
\nfastcgi_index index.php;\nfastcgi_param SCRIPT_FILENAME /home/www/scripts/php$fastcgi_script_name;\n
\nthe SCRIPT_FILENAME parameter will be equal to\n“/home/www/scripts/php/info/index.php”.\n\n

\nWhen using the fastcgi_split_path_info directive,\nthe $fastcgi_script_name variable equals the value of\nthe first capture set by the directive.\n

\n
\n\n
$fastcgi_path_info
\n
the value of the second capture set by the\nfastcgi_split_path_info directive.\nThis variable can be used to set the\nPATH_INFO parameter.\n
\n\n

\n

\n\n
\n", "encoding": "utf-8"} +{"path": "en\\docs\\http\\ngx_http_flv_module.html", "extension": ".html", "size_bytes": 4000, "content": "\nModule ngx_http_flv_module
\n\nPlanning your ingress-nginx migration? Start here:\nkubernetes.nginx.org.\n\n

Module ngx_http_flv_module

Example Configuration
Directives
     flv
\n\n

\nThe ngx_http_flv_module module provides pseudo-streaming\nserver-side support for Flash Video (FLV) files.\n

\nIt handles requests with the start argument in\nthe request URI’s query string specially, by sending back the contents\nof a file starting from the requested byte offset and with the prepended FLV\nheader.\n

\nThis module is not built by default, it should be enabled with the\n--with-http_flv_module\nconfiguration parameter.\n

\n\n\n

Example Configuration

\n

\nlocation ~ \\.flv$ {\n    flv;\n}\n

\n

\n\n\n

Directives

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n flv;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n location
\n

\nTurns on module processing in a surrounding location.\n

\n\n
\n", "encoding": "utf-8"} +{"path": "en\\docs\\http\\ngx_http_geoip_module.html", "extension": ".html", "size_bytes": 11974, "content": "\nModule ngx_http_geoip_module
\n\nPlanning your ingress-nginx migration? Start here:\nkubernetes.nginx.org.\n\n

Module ngx_http_geoip_module

Example Configuration
Directives
     geoip_country
     geoip_city
     geoip_org
     geoip_proxy
     geoip_proxy_recursive
\n\n

\nThe ngx_http_geoip_module module (0.8.6+) creates variables\nwith values depending on the client IP address, using the precompiled\nMaxMind databases.\n

\nWhen using the databases with IPv6 support (1.3.12, 1.2.7),\nIPv4 addresses are looked up as IPv4-mapped IPv6 addresses.\n

\nThis module is not built by default, it should be enabled with the\n--with-http_geoip_module\nconfiguration parameter.\n

\nThis module requires the\nMaxMind GeoIP library.\n

\n

\n\n\n

Example Configuration

\n

\nhttp {\n    geoip_country         GeoIP.dat;\n    geoip_city            GeoLiteCity.dat;\n    geoip_proxy           192.168.100.0/24;\n    geoip_proxy           2001:0db8::/32;\n    geoip_proxy_recursive on;\n    ...\n

\n

\n\n\n

Directives

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n geoip_country file;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n http
\n

\nSpecifies a database used to determine the country\ndepending on the client IP address.\nThe following variables are available when using this database:\n

\n\n
$geoip_country_code
\n
\ntwo-letter country code, for example,\n“RU”, “US”.\n
\n\n
$geoip_country_code3\n
\n
\nthree-letter country code, for example,\n“RUS”, “USA”.\n
\n\n
$geoip_country_name
\n
\ncountry name, for example,\n“Russian Federation”, “United States”.\n
\n\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n geoip_city file;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n http
\n

\nSpecifies a database used to determine the country, region, and city\ndepending on the client IP address.\nThe following variables are available when using this database:\n

\n\n
$geoip_area_code
\n
telephone area code (US only).\n
\nThis variable may contain outdated information since\nthe corresponding database field is deprecated.\n
\n
\n\n
\n$geoip_city_continent_code
\n
two-letter continent code, for example,\n“EU”, “NA”.\n
\n\n
$geoip_city_country_code\n
\n
\ntwo-letter country code, for example,\n“RU”, “US”.\n
\n\n
$geoip_city_country_code3\n
\n
\nthree-letter country code, for example,\n“RUS”, “USA”.\n
\n\n
$geoip_city_country_name\n
\n
\ncountry name, for example,\n“Russian Federation”, “United States”.\n
\n\n
$geoip_dma_code
\n
\nDMA region code in US (also known as “metro code”), according to the\ngeotargeting\nin Google AdWords API.\n
\n\n
$geoip_latitude
\n
latitude.
\n\n
$geoip_longitude
\n
longitude.
\n\n
$geoip_region
\n
\ntwo-symbol country region code (region, territory, state, province, federal land\nand the like), for example,\n“48”, “DC”.\n
\n\n
$geoip_region_name
\n
\ncountry region name (region, territory, state, province, federal land\nand the like), for example,\n“Moscow City”, “District of Columbia”.\n
\n\n
$geoip_city
\n
\ncity name, for example,\n“Moscow”, “Washington”.\n
\n\n
$geoip_postal_code
\n
\npostal code.\n
\n\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n geoip_org file;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n http
\n

This directive appeared in version 1.0.3.\n

\nSpecifies a database used to determine the organization\ndepending on the client IP address.\nThe following variable is available when using this database:\n

\n\n
$geoip_org
\n
\norganization name, for example, “The University of Melbourne”.\n
\n\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n geoip_proxy address | CIDR;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n http
\n
\n

\n This directive appeared in versions 1.3.0 and 1.2.1.\n \n

\n

\nDefines trusted addresses.\nWhen a request comes from a trusted address,\nan address from the “X-Forwarded-For” request\nheader field will be used instead.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n geoip_proxy_recursive on | off;
\n
\n Default:\n \n
geoip_proxy_recursive off;
\n
\n Context:\n \n http
\n
\n

\n This directive appeared in versions 1.3.0 and 1.2.1.\n \n

\n

\nIf recursive search is disabled then instead of the original client\naddress that matches one of the trusted addresses, the last\naddress sent in “X-Forwarded-For” will be used.\nIf recursive search is enabled then instead of the original client\naddress that matches one of the trusted addresses, the last\nnon-trusted address sent in “X-Forwarded-For” will be used.\n

\n\n
\n", "encoding": "utf-8"} +{"path": "en\\docs\\http\\ngx_http_geo_module.html", "extension": ".html", "size_bytes": 7617, "content": "\nModule ngx_http_geo_module
\n\nPlanning your ingress-nginx migration? Start here:\nkubernetes.nginx.org.\n\n

Module ngx_http_geo_module

Example Configuration
Directives
     geo
\n\n

\nThe ngx_http_geo_module module creates variables\nwith values depending on the client IP address.\n

\n\n\n

Example Configuration

\n

\ngeo $geo {\n    default        0;\n\n    127.0.0.1      2;\n    192.168.1.0/24 1;\n    10.1.0.0/16    1;\n\n    ::1            2;\n    2001:0db8::/32 1;\n}\n

\n

\n\n\n

Directives

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n geo [$address] $variable { ... }
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n http
\n

\nDescribes the dependency of values of the specified variable\non the client IP address.\nBy default, the address is taken from the $remote_addr variable,\nbut it can also be taken from another variable (0.7.27), for example:\n

\ngeo $arg_remote_addr $geo {\n    ...;\n}\n

\n

\n

\nSince variables are evaluated only when used, the mere existence\nof even a large number of declared “geo” variables\ndoes not cause any extra costs for request processing.\n

\n

\nIf the value of a variable does not represent a valid IP address\nthen the “255.255.255.255” address is used.\n

\nAddresses are specified either as prefixes in CIDR notation\n(including individual addresses) or as ranges (0.7.23).\n

\nIPv6 prefixes are supported starting from versions 1.3.10 and 1.2.7.\n

\n

\nThe following special parameters are also supported:\n

\n\n
delete
\n
\ndeletes the specified network (0.7.23).\n
\n\n
default
\n
\na value set to the variable if the client address does not\nmatch any of the specified addresses.\nWhen addresses are specified in CIDR notation,\n“0.0.0.0/0” and “::/0”\ncan be used instead of default.\nWhen default is not specified, the default\nvalue will be an empty string.\n
\n\n
include
\n
\nincludes a file with addresses and values.\nThere can be several inclusions.\n
\n\n
proxy
\n
\ndefines trusted addresses (0.8.7, 0.7.63).\nWhen a request comes from a trusted address,\nan address from the “X-Forwarded-For” request\nheader field will be used instead.\nIn contrast to the regular addresses, trusted addresses are\nchecked sequentially.\n
\nTrusted IPv6 addresses are supported starting from versions 1.3.0 and 1.2.1.\n
\n
\n\n
proxy_recursive
\n
\nenables recursive address search (1.3.0, 1.2.1).\nIf recursive search is disabled then instead of the original client\naddress that matches one of the trusted addresses, the last\naddress sent in “X-Forwarded-For” will be used.\nIf recursive search is enabled then instead of the original client\naddress that matches one of the trusted addresses, the last\nnon-trusted address sent in “X-Forwarded-For” will be used.\n
\n\n
ranges
\n
\nindicates that addresses are specified as ranges (0.7.23).\nThis parameter should be the first.\nTo speed up loading of a geo base, addresses should be put in ascending order.\n
\n\n
volatile
\n
\nindicates that the variable is not cacheable (1.29.3).\n
\n\n

\n

\nExample:\n

\ngeo $country {\n    default        ZZ;\n    include        conf/geo.conf;\n    delete         127.0.0.0/16;\n    proxy          192.168.100.0/24;\n    proxy          2001:0db8::/32;\n\n    127.0.0.0/24   US;\n    127.0.0.1/32   RU;\n    10.1.0.0/16    RU;\n    192.168.1.0/24 UK;\n}\n

\n

\nThe conf/geo.conf file could contain the following lines:\n

\n10.2.0.0/16    RU;\n192.168.2.0/24 RU;\n

\n

\nA value of the most specific match is used.\nFor example, for the 127.0.0.1 address the value “RU”\nwill be chosen, not “US”.\n

\nExample with ranges:\n

\ngeo $country {\n    ranges;\n    default                   ZZ;\n    127.0.0.0-127.0.0.0       US;\n    127.0.0.1-127.0.0.1       RU;\n    127.0.0.1-127.0.0.255     US;\n    10.1.0.0-10.1.255.255     RU;\n    192.168.1.0-192.168.1.255 UK;\n}\n

\n

\n\n
\n", "encoding": "utf-8"} +{"path": "en\\docs\\http\\ngx_http_grpc_module.html", "extension": ".html", "size_bytes": 50639, "content": "\nModule ngx_http_grpc_module
\n\nPlanning your ingress-nginx migration? Start here:\nkubernetes.nginx.org.\n\n

Module ngx_http_grpc_module

Example Configuration
Directives
     grpc_allow_upstream
     grpc_bind
     grpc_bind_dynamic
     grpc_buffer_size
     grpc_connect_timeout
     grpc_hide_header
     grpc_ignore_headers
     grpc_intercept_errors
     grpc_next_upstream
     grpc_next_upstream_timeout
     grpc_next_upstream_tries
     grpc_pass
     grpc_pass_header
     grpc_read_timeout
     grpc_request_dynamic
     grpc_send_timeout
     grpc_set_header
     grpc_socket_keepalive
     grpc_ssl_certificate
     grpc_ssl_certificate_cache
     grpc_ssl_certificate_key
     grpc_ssl_ciphers
     grpc_ssl_conf_command
     grpc_ssl_crl
     grpc_ssl_key_log
     grpc_ssl_name
     grpc_ssl_password_file
     grpc_ssl_protocols
     grpc_ssl_server_name
     grpc_ssl_session_reuse
     grpc_ssl_trusted_certificate
     grpc_ssl_verify
     grpc_ssl_verify_depth
\n\n

\nThe ngx_http_grpc_module module allows passing requests\nto a gRPC server (1.13.10).\nThe module requires the\nngx_http_v2_module module.\n

\n\n\n

Example Configuration

\n

\nserver {\n    listen 9000;\n\n    http2 on;\n\n    location / {\n        grpc_pass 127.0.0.1:9000;\n    }\n}\n

\n

\n\n\n

Directives

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n grpc_allow_upstream address;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n http, server, location
\n

This directive appeared in version 1.29.3.\n

\nDefines conditions under which access to a gRPC server\nis allowed or denied.\nIf all string parameters are not empty\nand not equal to “0” then the access is allowed.\nThe conditions are evaluated each time\nbefore a connection to a gRPC server is established.\nParameter values can contain variables:\n

\ngeo $upstream_last_addr $allow {\n    volatile;\n    10.10.0.0/24        1;\n}\n\nserver {\n    listen 127.0.0.1:8080;\n    http2 on;\n\n    location / {\n        grpc_pass           localhost:9000;\n        grpc_allow_upstream $allow;\n        ...\n    }\n}\n

\n

\n

\nThis directive is available as part of our\ncommercial subscription.\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n grpc_bind \n address\n [transparent ] |\n off;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n http, server, location
\n

\nMakes outgoing connections to a gRPC server originate\nfrom the specified local IP address with an optional port.\nParameter value can contain variables.\nThe special value off cancels the effect\nof the grpc_bind directive\ninherited from the previous configuration level, which allows the\nsystem to auto-assign the local IP address and port.\n

\nThe transparent parameter allows\noutgoing connections to a gRPC server originate\nfrom a non-local IP address,\nfor example, from a real IP address of a client:\n

\ngrpc_bind $remote_addr transparent;\n

\nIn order for this parameter to work,\nit is usually necessary to run nginx worker processes with the\nsuperuser privileges.\nOn Linux it is not required as if\nthe transparent parameter is specified, worker processes\ninherit the CAP_NET_RAW capability from the master process.\nIt is also necessary to configure kernel routing table\nto intercept network traffic from the gRPC server.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n grpc_bind_dynamic on | off;
\n
\n Default:\n \n
grpc_bind_dynamic off;
\n
\n Context:\n \n http, server, location
\n

This directive appeared in version 1.29.3.\n

\nWhen enabled, makes the bind operation\nat each connection attempt.\n

\n

\nThis directive is available as part of our\ncommercial subscription.\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n grpc_buffer_size size;
\n
\n Default:\n \n
grpc_buffer_size 4k|8k;
\n
\n Context:\n \n http, server, location
\n

\nSets the size of the buffer used for reading the response\nreceived from the gRPC server.\nThe first part of the response usually contains a small header;\nif it exceeds the buffer size, the response is considered\ninvalid.\nThe response is passed to the client synchronously, as soon as it is received.\nBy default, the buffer size is equal to one memory page.\nThis is either 4K or 8K, depending on a platform.\nIt can be made smaller, however.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n grpc_connect_timeout time;
\n
\n Default:\n \n
grpc_connect_timeout 60s;
\n
\n Context:\n \n http, server, location
\n

\nDefines a timeout for establishing a connection with a gRPC server.\nIt should be noted that this timeout cannot usually exceed 75 seconds.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n grpc_hide_header field;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n http, server, location
\n

\nBy default,\nnginx does not pass the header fields “Date”,\n“Server”, and\n“X-Accel-...” from the response of a gRPC\nserver to a client.\nThe grpc_hide_header directive sets additional fields\nthat will not be passed.\nIf, on the contrary, the passing of fields needs to be permitted,\nthe grpc_pass_header directive can be used.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n grpc_ignore_headers field ...;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n http, server, location
\n

\nDisables processing of certain response header fields from the gRPC server.\nThe following fields can be ignored: “X-Accel-Redirect”\nand “X-Accel-Charset”.\n

\nIf not disabled, processing of these header fields has the following\neffect:\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n grpc_intercept_errors on | off;
\n
\n Default:\n \n
grpc_intercept_errors off;
\n
\n Context:\n \n http, server, location
\n

\nDetermines whether gRPC server responses with codes greater than or equal\nto 300 should be passed to a client\nor be intercepted and redirected to nginx for processing\nwith the error_page directive.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n grpc_next_upstream \n error |\n timeout |\n denied |\n invalid_header |\n http_500 |\n http_502 |\n http_503 |\n http_504 |\n http_403 |\n http_404 |\n http_429 |\n non_idempotent |\n off\n ...;
\n
\n Default:\n \n
grpc_next_upstream error timeout;
\n
\n Context:\n \n http, server, location
\n

\nSpecifies in which cases a request should be passed to the next server:\n

\n\n
error
\n
an error occurred while establishing a connection with the\nserver, passing a request to it, or reading the response header;
\n\n
timeout
\n
a timeout has occurred while establishing a connection with the\nserver, passing a request to it, or reading the response header;
\n\n
denied
\n
the server denied\nthe connection (1.29.3);\n

\n

\nThis parameter is available as part of our\ncommercial subscription.\n

\n

\n
\n\n
invalid_header
\n
a server returned an empty or invalid response;
\n\n
http_500
\n
a server returned a response with the code 500;
\n\n
http_502
\n
a server returned a response with the code 502;
\n\n
http_503
\n
a server returned a response with the code 503;
\n\n
http_504
\n
a server returned a response with the code 504;
\n\n
http_403
\n
a server returned a response with the code 403;
\n\n
http_404
\n
a server returned a response with the code 404;
\n\n
http_429
\n
a server returned a response with the code 429;
\n\n
non_idempotent
\n
normally, requests with a\nnon-idempotent\nmethod\n(POST, LOCK, PATCH)\nare not passed to the next server\nif a request has been sent to an upstream server;\nenabling this option explicitly allows retrying such requests;\n
\n\n
off
\n
disables passing a request to the next server.
\n\n

\n

\nOne should bear in mind that passing a request to the next server is\nonly possible if nothing has been sent to a client yet.\nThat is, if an error or timeout occurs in the middle of the\ntransferring of a response, fixing this is impossible.\n

\nThe directive also defines what is considered an\nunsuccessful\nattempt of communication with a server.\nThe cases of error, timeout,\ndenied and\ninvalid_header are always considered unsuccessful attempts,\neven if they are not specified in the directive.\nThe cases of http_500, http_502,\nhttp_503, http_504,\nand http_429 are\nconsidered unsuccessful attempts only if they are specified in the directive.\nThe cases of http_403 and http_404\nare never considered unsuccessful attempts.\n

\nPassing a request to the next server can be limited by\nthe number of tries\nand by time.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n grpc_next_upstream_timeout time;
\n
\n Default:\n \n
grpc_next_upstream_timeout 0;
\n
\n Context:\n \n http, server, location
\n

\nLimits the time during which a request can be passed to the\nnext server.\nThe 0 value turns off this limitation.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n grpc_next_upstream_tries number;
\n
\n Default:\n \n
grpc_next_upstream_tries 0;
\n
\n Context:\n \n http, server, location
\n

\nLimits the number of possible tries for passing a request to the\nnext server.\nThe 0 value turns off this limitation.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n grpc_pass address;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n location, if in location
\n

\nSets the gRPC server address.\nThe address can be specified as a domain name or IP address,\nand a port:\n

\ngrpc_pass localhost:9000;\n

\nor as a UNIX-domain socket path:\n

\ngrpc_pass unix:/tmp/grpc.socket;\n

\nAlternatively, the “grpc://” scheme can be used:\n

\ngrpc_pass grpc://127.0.0.1:9000;\n

\nTo use gRPC over SSL, the “grpcs://” scheme should be used:\n

\ngrpc_pass grpcs://127.0.0.1:443;\n

\n

\nIf a domain name resolves to several addresses, all of them will be\nused in a round-robin fashion.\nIn addition, an address can be specified as a\nserver group.\n

\nParameter value can contain variables (1.17.8).\nIn this case, if an address is specified as a domain name,\nthe name is searched among the described\nserver groups,\nand, if not found, is determined using a\nresolver.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n grpc_pass_header field;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n http, server, location
\n

\nPermits passing otherwise disabled header\nfields from a gRPC server to a client.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n grpc_read_timeout time;
\n
\n Default:\n \n
grpc_read_timeout 60s;
\n
\n Context:\n \n http, server, location
\n

\nDefines a timeout for reading a response from the gRPC server.\nThe timeout is set only between two successive read operations,\nnot for the transmission of the whole response.\nIf the gRPC server does not transmit anything within this time,\nthe connection is closed.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n grpc_request_dynamic on | off;
\n
\n Default:\n \n
grpc_request_dynamic off;
\n
\n Context:\n \n http, server, location
\n

This directive appeared in version 1.29.3.\n

\nEnables or disables creation of a separate request instance\nfor each gRPC server.\nBy default, a single request is used for all gRPC servers.\nIf enabled, a separate request instance is created,\nallowing per-server request customization.\nFor example, the server-specific “Host” request header field\ncan be set:\n

\ngrpc_request_dynamic on;\ngrpc_set_header      Host $upstream_last_server_name;\n

\n

\n

\nThis directive is available as part of our\ncommercial subscription.\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n grpc_send_timeout time;
\n
\n Default:\n \n
grpc_send_timeout 60s;
\n
\n Context:\n \n http, server, location
\n

\nSets a timeout for transmitting a request to the gRPC server.\nThe timeout is set only between two successive write operations,\nnot for the transmission of the whole request.\nIf the gRPC server does not receive anything within this time,\nthe connection is closed.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n grpc_set_header field value;
\n
\n Default:\n \n
grpc_set_header Content-Length $content_length;
\n
\n Context:\n \n http, server, location
\n

\nAllows redefining or appending fields to the request header\npassed to the gRPC server.\nThe value can contain text, variables, and their combinations.\nThese directives are inherited from the previous configuration level\nif and only if there are no grpc_set_header directives\ndefined on the current level.\n

\nIf the value of a header field is an empty string then this\nfield will not be passed to a gRPC server:\n

\ngrpc_set_header Accept-Encoding \"\";\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n grpc_socket_keepalive on | off;
\n
\n Default:\n \n
grpc_socket_keepalive off;
\n
\n Context:\n \n http, server, location
\n

This directive appeared in version 1.15.6.\n

\nConfigures the “TCP keepalive” behavior\nfor outgoing connections to a gRPC server.\nBy default, the operating system’s settings are in effect for the socket.\nIf the directive is set to the value “on”, the\nSO_KEEPALIVE socket option is turned on for the socket.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n grpc_ssl_certificate file;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n http, server, location
\n

\nSpecifies a file with the certificate in the PEM format\nused for authentication to a gRPC SSL server.\n

\nSince version 1.21.0, variables can be used in the file name.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n grpc_ssl_certificate_cache off;
grpc_ssl_certificate_cache \n max=N\n [inactive=time]\n [valid=time];
\n
\n Default:\n \n
grpc_ssl_certificate_cache off;
\n
\n Context:\n \n http, server, location
\n

This directive appeared in version 1.27.4.\n

\nDefines a cache that stores\nSSL certificates and\nsecret keys\nspecified with variables.\n

\nThe directive has the following parameters:\n

\n\n
\nmax\n
\n
\nsets the maximum number of elements in the cache;\non cache overflow the least recently used (LRU) elements are removed;\n
\n\n
\ninactive\n
\n
\ndefines a time after which an element is removed from the cache\nif it has not been accessed during this time;\nby default, it is 10 seconds;\n
\n\n
\nvalid\n
\n
\ndefines a time during which\nan element in the cache is considered valid\nand can be reused;\nby default, it is 60 seconds.\nCertificates that exceed this time will be reloaded or revalidated;\n
\n\n
\noff\n
\n
\ndisables the cache.\n
\n\n

\n

\nExample:\n

\ngrpc_ssl_certificate       $grpc_ssl_server_name.crt;\ngrpc_ssl_certificate_key   $grpc_ssl_server_name.key;\ngrpc_ssl_certificate_cache max=1000 inactive=20s valid=1m;\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n grpc_ssl_certificate_key file;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n http, server, location
\n

\nSpecifies a file with the secret key in the PEM format\nused for authentication to a gRPC SSL server.\n

\nThe value\nengine:name:id\ncan be specified instead of the file,\nwhich loads a secret key with a specified id\nfrom the OpenSSL engine name.\n

\nThe value\nstore:scheme:id\ncan be specified instead of the file (1.29.0),\nwhich is used to load a secret key with a specified id\nand OpenSSL provider registered URI scheme, such as\npkcs11.\n

\nSince version 1.21.0, variables can be used in the file name.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n grpc_ssl_ciphers ciphers;
\n
\n Default:\n \n
grpc_ssl_ciphers DEFAULT;
\n
\n Context:\n \n http, server, location
\n

\nSpecifies the enabled ciphers for requests to a gRPC SSL server.\nThe ciphers are specified in the format understood by the OpenSSL library.\n

\nThe full list can be viewed using the\n“openssl ciphers” command.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n grpc_ssl_conf_command name value;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n http, server, location
\n

This directive appeared in version 1.19.4.\n

\nSets arbitrary OpenSSL configuration\ncommands\nwhen establishing a connection with the gRPC SSL server.\n

\nThe directive is supported when using OpenSSL 1.0.2 or higher.\n

\n

\nSeveral grpc_ssl_conf_command directives\ncan be specified on the same level.\nThese directives are inherited from the previous configuration level\nif and only if there are\nno grpc_ssl_conf_command directives\ndefined on the current level.\n

\n

\nNote that configuring OpenSSL directly\nmight result in unexpected behavior.\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n grpc_ssl_crl file;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n http, server, location
\n

\nSpecifies a file with revoked certificates (CRL)\nin the PEM format used to verify\nthe certificate of the gRPC SSL server.\nWhen using intermediate certificates, their CRLs should be\nspecified in the same file.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n grpc_ssl_key_log path;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n http, server, location
\n

This directive appeared in version 1.27.2.\n

\nEnables logging of gRPC SSL server connection SSL keys\nand specifies the path to the key log file.\nKeys are logged in the\nSSLKEYLOGFILE\nformat compatible with Wireshark.\n

\n

\nThis directive is available as part of our\ncommercial subscription.\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n grpc_ssl_name name;
\n
\n Default:\n \n
grpc_ssl_name host from grpc_pass;
\n
\n Context:\n \n http, server, location
\n

\nAllows overriding the server name used to\nverify\nthe certificate of the gRPC SSL server and to be\npassed through SNI\nwhen establishing a connection with the gRPC SSL server.\n

\nBy default, the host part from grpc_pass is used.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n grpc_ssl_password_file file;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n http, server, location
\n

\nSpecifies a file with passphrases for\nsecret keys\nwhere each passphrase is specified on a separate line.\nPassphrases are tried in turn when loading the key.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n grpc_ssl_protocols \n [SSLv2]\n [SSLv3]\n [TLSv1]\n [TLSv1.1]\n [TLSv1.2]\n [TLSv1.3];
\n
\n Default:\n \n
grpc_ssl_protocols TLSv1.2 TLSv1.3;
\n
\n Context:\n \n http, server, location
\n

\nEnables the specified protocols for requests to a gRPC SSL server.\n

\n

\nThe TLSv1.3 parameter is used by default\nsince 1.23.4.\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n grpc_ssl_server_name on | off;
\n
\n Default:\n \n
grpc_ssl_server_name off;
\n
\n Context:\n \n http, server, location
\n

\nEnables or disables passing of the server name through\nTLS\nServer Name Indication extension (SNI, RFC 6066)\nwhen establishing a connection with the gRPC SSL server.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n grpc_ssl_session_reuse on | off;
\n
\n Default:\n \n
grpc_ssl_session_reuse on;
\n
\n Context:\n \n http, server, location
\n

\nDetermines whether SSL sessions can be reused when working with\nthe gRPC server.\nIf the errors\n“digest check failed”\nappear in the logs, try disabling session reuse.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n grpc_ssl_trusted_certificate file;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n http, server, location
\n

\nSpecifies a file with trusted CA certificates in the PEM format\nused to verify\nthe certificate of the gRPC SSL server.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n grpc_ssl_verify on | off;
\n
\n Default:\n \n
grpc_ssl_verify off;
\n
\n Context:\n \n http, server, location
\n

\nEnables or disables verification of the gRPC SSL server certificate.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n grpc_ssl_verify_depth number;
\n
\n Default:\n \n
grpc_ssl_verify_depth 1;
\n
\n Context:\n \n http, server, location
\n

\nSets the verification depth in the gRPC SSL server certificates chain.\n

\n\n
\n", "encoding": "utf-8"} +{"path": "en\\docs\\http\\ngx_http_gunzip_module.html", "extension": ".html", "size_bytes": 5647, "content": "\nModule ngx_http_gunzip_module
\n\nPlanning your ingress-nginx migration? Start here:\nkubernetes.nginx.org.\n\n

Module ngx_http_gunzip_module

Example Configuration
Directives
     gunzip
     gunzip_buffers
\n\n

\nThe ngx_http_gunzip_module module is a filter that\ndecompresses responses with “Content-Encoding: gzip”\nfor clients that do not support “gzip” encoding method.\nThe module will be useful when it is desirable to store\ndata compressed to save space and reduce I/O costs.\n

\nThis module is not built by default, it should be enabled with the\n--with-http_gunzip_module\nconfiguration parameter.\n

\n\n\n

Example Configuration

\n

\nlocation /storage/ {\n    gunzip on;\n    ...\n}\n

\n

\n\n\n

Directives

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n gunzip on | off;
\n
\n Default:\n \n
gunzip off;
\n
\n Context:\n \n http, server, location
\n

\nEnables or disables decompression of gzipped responses\nfor clients that lack gzip support.\nIf enabled, the following directives are also taken into account\nwhen determining if clients support gzip:\ngzip_http_version,\ngzip_proxied, and\ngzip_disable.\nSee also the gzip_vary directive.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n gunzip_buffers number size;
\n
\n Default:\n \n
gunzip_buffers 32 4k|16 8k;
\n
\n Context:\n \n http, server, location
\n

\nSets the number and size of buffers\nused to decompress a response.\nBy default, the buffer size is equal to one memory page.\nThis is either 4K or 8K, depending on a platform.\n

\n\n
\n", "encoding": "utf-8"} +{"path": "en\\docs\\http\\ngx_http_gzip_module.html", "extension": ".html", "size_bytes": 14983, "content": "\nModule ngx_http_gzip_module
\n\nPlanning your ingress-nginx migration? Start here:\nkubernetes.nginx.org.\n\n

Module ngx_http_gzip_module

Example Configuration
Directives
     gzip
     gzip_buffers
     gzip_comp_level
     gzip_disable
     gzip_http_version
     gzip_min_length
     gzip_proxied
     gzip_types
     gzip_vary
Embedded Variables
\n\n

\nThe ngx_http_gzip_module module is a filter\nthat compresses responses using the “gzip” method.\nThis often helps to reduce the size of transmitted data by half or even more.\n

\nWhen using the SSL/TLS protocol, compressed responses may be subject to\nBREACH attacks.\n

\n

\n\n\n

Example Configuration

\n

\ngzip            on;\ngzip_min_length 1000;\ngzip_proxied    expired no-cache no-store private auth;\ngzip_types      text/plain application/xml;\n

\n

\nThe $gzip_ratio variable can be used to log the\nachieved compression ratio.\n

\n\n\n

Directives

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n gzip on | off;
\n
\n Default:\n \n
gzip off;
\n
\n Context:\n \n http, server, location, if in location
\n

\nEnables or disables gzipping of responses.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n gzip_buffers number size;
\n
\n Default:\n \n
gzip_buffers 32 4k|16 8k;
\n
\n Context:\n \n http, server, location
\n

\nSets the number and size of buffers\nused to compress a response.\nBy default, the buffer size is equal to one memory page.\nThis is either 4K or 8K, depending on a platform.\n

\nUntil version 0.7.28, four 4K or 8K buffers were used by default.\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n gzip_comp_level level;
\n
\n Default:\n \n
gzip_comp_level 1;
\n
\n Context:\n \n http, server, location
\n

\nSets a gzip compression level of a response.\nAcceptable values are in the range from 1 to 9.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n gzip_disable regex ...;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n http, server, location
\n

This directive appeared in version 0.6.23.\n

\nDisables gzipping of responses for requests with\n“User-Agent” header fields matching\nany of the specified regular expressions.\n

\nThe special mask “msie6” (0.7.12) corresponds to\nthe regular expression “MSIE [4-6]\\.”, but works faster.\nStarting from version 0.8.11, “MSIE 6.0; ... SV1”\nis excluded from this mask.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n gzip_http_version 1.0 | 1.1;
\n
\n Default:\n \n
gzip_http_version 1.1;
\n
\n Context:\n \n http, server, location
\n

\nSets the minimum HTTP version of a request required to compress a response.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n gzip_min_length length;
\n
\n Default:\n \n
gzip_min_length 20;
\n
\n Context:\n \n http, server, location
\n

\nSets the minimum length of a response that will be gzipped.\nThe length is determined only from the “Content-Length”\nresponse header field.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n gzip_proxied \n off |\n expired |\n no-cache |\n no-store |\n private |\n no_last_modified |\n no_etag |\n auth |\n any\n ...;
\n
\n Default:\n \n
gzip_proxied off;
\n
\n Context:\n \n http, server, location
\n

\nEnables or disables gzipping of responses for proxied\nrequests depending on the request and response.\nThe fact that the request is proxied is determined by\nthe presence of the “Via” request header field.\nThe directive accepts multiple parameters:\n

\n\n
off
\n
\ndisables compression for all proxied requests,\nignoring other parameters;\n
\n\n
expired
\n
\nenables compression if a response header includes the\n“Expires” field with a value that disables caching;\n
\n\n
no-cache
\n
\nenables compression if a response header includes the\n“Cache-Control” field with the\n“no-cache” parameter;\n
\n\n
no-store
\n
\nenables compression if a response header includes the\n“Cache-Control” field with the\n“no-store” parameter;\n
\n\n
private
\n
\nenables compression if a response header includes the\n“Cache-Control” field with the\n“private” parameter;\n
\n\n
no_last_modified
\n
\nenables compression if a response header does not include the\n“Last-Modified” field;\n
\n\n
no_etag
\n
\nenables compression if a response header does not include the\n“ETag” field;\n
\n\n
auth
\n
\nenables compression if a request header includes the\n“Authorization” field;\n
\n\n
any
\n
\nenables compression for all proxied requests.\n
\n\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n gzip_types mime-type ...;
\n
\n Default:\n \n
gzip_types text/html;
\n
\n Context:\n \n http, server, location
\n

\nEnables gzipping of responses for the specified MIME types in addition\nto “text/html”.\nThe special value “*” matches any MIME type (0.8.29).\nResponses with the “text/html” type are always compressed.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n gzip_vary on | off;
\n
\n Default:\n \n
gzip_vary off;
\n
\n Context:\n \n http, server, location
\n

\nEnables or disables inserting the “Vary: Accept-Encoding”\nresponse header field if the directives\ngzip,\ngzip_static, or\ngunzip\nare active.\n

\n\n\n

Embedded Variables

\n

\n\n
$gzip_ratio
\n
achieved compression ratio, computed as the ratio between the\noriginal and compressed response sizes.
\n\n

\n

\n\n
\n", "encoding": "utf-8"} +{"path": "en\\docs\\http\\ngx_http_gzip_static_module.html", "extension": ".html", "size_bytes": 4937, "content": "\nModule ngx_http_gzip_static_module
\n\nPlanning your ingress-nginx migration? Start here:\nkubernetes.nginx.org.\n\n

Module ngx_http_gzip_static_module

Example Configuration
Directives
     gzip_static
\n\n

\nThe ngx_http_gzip_static_module module allows\nsending precompressed files with the “.gz”\nfilename extension instead of regular files.\n

\nThis module is not built by default, it should be enabled with the\n--with-http_gzip_static_module\nconfiguration parameter.\n

\n\n\n

Example Configuration

\n

\ngzip_static  on;\ngzip_proxied expired no-cache no-store private auth;\n

\n

\n\n\n

Directives

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n gzip_static \n on |\n off |\n always;
\n
\n Default:\n \n
gzip_static off;
\n
\n Context:\n \n http, server, location
\n

\nEnables (“on”) or disables (“off”)\nchecking the existence of precompressed files.\nThe following directives are also taken into account:\ngzip_http_version,\ngzip_proxied,\ngzip_disable,\nand gzip_vary.\n

\nWith the “always” value (1.3.6), gzipped file is used\nin all cases, without checking if the client supports it.\nIt is useful if there are no uncompressed files on the disk anyway\nor the ngx_http_gunzip_module\nis used.\n

\nThe files can be compressed using the gzip command,\nor any other compatible one.\nIt is recommended that the modification date and time of original and\ncompressed files be the same.\n

\n\n
\n", "encoding": "utf-8"} +{"path": "en\\docs\\http\\ngx_http_headers_module.html", "extension": ".html", "size_bytes": 12937, "content": "\nModule ngx_http_headers_module
\n\nPlanning your ingress-nginx migration? Start here:\nkubernetes.nginx.org.\n\n

Module ngx_http_headers_module

Example Configuration
Directives
     add_header
     add_header_inherit
     add_trailer
     add_trailer_inherit
     expires
\n\n

\nThe ngx_http_headers_module module allows adding\nthe “Expires” and “Cache-Control” header\nfields, and arbitrary fields, to a response header.\n

\n\n\n

Example Configuration

\n

\nexpires    24h;\nexpires    modified +24h;\nexpires    @24h;\nexpires    0;\nexpires    -1;\nexpires    epoch;\nexpires    $expires;\nadd_header Cache-Control private;\n

\n

\n\n\n

Directives

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n add_header \nname value\n[always];
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n http, server, location, if in location
\n

\nAdds the specified field to a response header provided that\nthe response code equals 200, 201 (1.3.10), 204, 206, 301, 302, 303, 304,\n307 (1.1.16, 1.0.13), or 308 (1.13.0).\nParameter value can contain variables.\n

\nThere could be several add_header directives.\nThese directives are inherited from the previous configuration level\nif and only if there are no add_header directives\ndefined on the current level.\nInheritance rules can be redefined with the\nadd_header_inherit directive (1.29.3).\n

\nIf the always parameter is specified (1.7.5),\nthe header field will be added regardless of the response code.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n add_header_inherit \n on |\n off |\n merge;
\n
\n Default:\n \n
add_header_inherit on;
\n
\n Context:\n \n http, server, location, if in location
\n

This directive appeared in version 1.29.3.\n

\nAllows altering inheritance rules for the values specified in the\nadd_header directives.\nBy default, the\nstandard inheritance model is used.\n

\nThe merge parameter enables appending values\nfrom the previous level to the values defined at the current level.\n

\nThe off parameter cancels inheritance of the values\nfrom the previous configuration level.\n

\nThe inheritance rules themselves are inherited in a standard way.\nFor example, add_header_inherit merge;\nspecified at the top level will\nbe inherited in all nested levels recursively unless redefined later.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n add_trailer \nname value\n[always];
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n http, server, location, if in location
\n

This directive appeared in version 1.13.2.\n

\nAdds the specified field to the end of a response provided that\nthe response code equals 200, 201, 206, 301, 302, 303, 307, or 308.\nParameter value can contain variables.\n

\nThere could be several add_trailer directives.\nThese directives are inherited from the previous configuration level\nif and only if there are no add_trailer directives\ndefined on the current level.\nInheritance rules can be redefined with the\nadd_trailer_inherit directive (1.29.3).\n

\nIf the always parameter is specified\nthe specified field will be added regardless of the response code.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n add_trailer_inherit \n on |\n off |\n merge;
\n
\n Default:\n \n
add_trailer_inherit on;
\n
\n Context:\n \n http, server, location, if in location
\n

This directive appeared in version 1.29.3.\n

\nAllows altering inheritance rules for the values specified in the\nadd_trailer directives.\nBy default, the\nstandard inheritance model is used.\n

\nThe merge parameter enables appending values\nfrom the previous level to the values defined at the current level.\n

\nThe off parameter cancels inheritance of the values\nfrom the previous configuration level.\n

\nThe inheritance rules themselves are inherited in a standard way.\nFor example, add_trailer_inherit merge;\nspecified at the top level will\nbe inherited in all nested levels recursively unless redefined later.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n expires [modified] time;
expires \n epoch |\n max |\n off;
\n
\n Default:\n \n
expires off;
\n
\n Context:\n \n http, server, location, if in location
\n

\nEnables or disables adding or modifying the “Expires”\nand “Cache-Control” response header fields provided that\nthe response code equals 200, 201 (1.3.10), 204, 206, 301, 302, 303, 304,\n307 (1.1.16, 1.0.13), or 308 (1.13.0).\nThe parameter can be a positive or negative\ntime.\n

\nThe time in the “Expires” field is computed as a sum of the\ncurrent time and time specified in the directive.\nIf the modified parameter is used (0.7.0, 0.6.32)\nthen the time is computed as a sum of the file’s modification time and\nthe time specified in the directive.\n

\nIn addition, it is possible to specify a time of day using\nthe “@” prefix (0.7.9, 0.6.34):\n

\nexpires @15h30m;\n

\n

\nThe contents of the “Cache-Control” field depends\non the sign of the specified time:\n

\n

\nThe epoch parameter sets “Expires”\nto the value “Thu, 01 Jan 1970 00:00:01 GMT”,\nand “Cache-Control” to “no-cache”.\n

\nThe max parameter sets “Expires”\nto the value “Thu, 31 Dec 2037 23:55:55 GMT”,\nand “Cache-Control” to 10 years.\n

\nThe off parameter disables adding or modifying the\n“Expires” and “Cache-Control” response\nheader fields.\n

\nThe last parameter value can contain variables (1.7.9):\n

\nmap $sent_http_content_type $expires {\n    default         off;\n    application/pdf 42d;\n    ~image/         max;\n}\n\nexpires $expires;\n

\n

\n\n
\n", "encoding": "utf-8"} +{"path": "en\\docs\\http\\ngx_http_hls_module.html", "extension": ".html", "size_bytes": 13027, "content": "\nModule ngx_http_hls_module
\n\nPlanning your ingress-nginx migration? Start here:\nkubernetes.nginx.org.\n\n

Module ngx_http_hls_module

Example Configuration
Directives
     hls
     hls_buffers
     hls_forward_args
     hls_fragment
     hls_mp4_buffer_size
     hls_mp4_max_buffer_size
\n\n

\nThe ngx_http_hls_module module provides HTTP Live Streaming\n(HLS) server-side support for MP4 and MOV media files.\nSuch files typically have the .mp4, .m4v,\n.m4a, .mov, or .qt filename extensions.\nThe module supports H.264 video codec, AAC and MP3 audio codecs.\n

\nFor each media file, two URIs are supported:\n

\n

\n

\nThis module is available as part of our\ncommercial subscription.\n

\n

\n\n\n

Example Configuration

\n

\nlocation / {\n    hls;\n    hls_fragment            5s;\n    hls_buffers             10 10m;\n    hls_mp4_buffer_size     1m;\n    hls_mp4_max_buffer_size 5m;\n    root /var/video/;\n}\n

\nWith this configuration, the following URIs are supported for\nthe “/var/video/test.mp4” file:\n

\nhttp://hls.example.com/test.mp4.m3u8?offset=1.000&start=1.000&end=2.200\nhttp://hls.example.com/test.mp4.m3u8?len=8.000\nhttp://hls.example.com/test.mp4.ts?start=1.000&end=2.200\n

\n

\n\n\n

Directives

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n hls;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n location
\n

\nTurns on HLS streaming in the surrounding location.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n hls_buffers number size;
\n
\n Default:\n \n
hls_buffers 8 2m;
\n
\n Context:\n \n http, server, location
\n

\nSets the maximum number and size of buffers\nthat are used for reading and writing data frames.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n hls_forward_args on | off;
\n
\n Default:\n \n
hls_forward_args off;
\n
\n Context:\n \n http, server, location
\n

This directive appeared in version 1.5.12.\n

\nAdds arguments from a playlist request to URIs of fragments.\nThis may be useful for performing client authorization at the moment of\nrequesting a fragment, or when protecting an HLS stream with the\nngx_http_secure_link_module\nmodule.\n

\nFor example, if a client requests a playlist\nhttp://example.com/hls/test.mp4.m3u8?a=1&b=2,\nthe arguments a=1 and b=2\nwill be added to URIs of fragments after the arguments\nstart and end:\n

\n#EXTM3U\n#EXT-X-VERSION:3\n#EXT-X-TARGETDURATION:15\n#EXT-X-PLAYLIST-TYPE:VOD\n\n#EXTINF:9.333,\ntest.mp4.ts?start=0.000&end=9.333&a=1&b=2\n#EXTINF:7.167,\ntest.mp4.ts?start=9.333&end=16.500&a=1&b=2\n#EXTINF:5.416,\ntest.mp4.ts?start=16.500&end=21.916&a=1&b=2\n#EXTINF:5.500,\ntest.mp4.ts?start=21.916&end=27.416&a=1&b=2\n#EXTINF:15.167,\ntest.mp4.ts?start=27.416&end=42.583&a=1&b=2\n#EXTINF:9.626,\ntest.mp4.ts?start=42.583&end=52.209&a=1&b=2\n\n#EXT-X-ENDLIST\n

\n

\nIf an HLS stream is protected with the\nngx_http_secure_link_module\nmodule, $uri should not be used in the\nsecure_link_md5\nexpression because this will cause errors when requesting the fragments.\nBase URI should be used\ninstead of $uri\n($hls_uri in the example):\n

\nhttp {\n    ...\n\n    map $uri $hls_uri {\n        ~^(?<base_uri>.*).m3u8$ $base_uri;\n        ~^(?<base_uri>.*).ts$   $base_uri;\n        default                 $uri;\n    }\n\n    server {\n        ...\n\n        location /hls/ {\n            hls;\n            hls_forward_args on;\n\n            alias /var/videos/;\n\n            secure_link $arg_md5,$arg_expires;\n            secure_link_md5 \"$secure_link_expires$hls_uri$remote_addr secret\";\n\n            if ($secure_link = \"\") {\n                return 403;\n            }\n\n            if ($secure_link = \"0\") {\n                return 410;\n            }\n        }\n    }\n}\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n hls_fragment time;
\n
\n Default:\n \n
hls_fragment 5s;
\n
\n Context:\n \n http, server, location
\n

\nDefines the default fragment length for playlist URIs requested without the\n“len” argument.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n hls_mp4_buffer_size size;
\n
\n Default:\n \n
hls_mp4_buffer_size 512k;
\n
\n Context:\n \n http, server, location
\n

\nSets the initial size of the buffer used for\nprocessing MP4 and MOV files.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n hls_mp4_max_buffer_size size;
\n
\n Default:\n \n
hls_mp4_max_buffer_size 10m;
\n
\n Context:\n \n http, server, location
\n

\nDuring metadata processing, a larger buffer may become necessary.\nIts size cannot exceed the specified size,\nor else nginx will return the server error\n500 (Internal Server Error),\nand log the following message:\n

\n\"/some/movie/file.mp4\" mp4 moov atom is too large:\n12583268, you may want to increase hls_mp4_max_buffer_size\n

\n

\n\n
\n", "encoding": "utf-8"} +{"path": "en\\docs\\http\\ngx_http_image_filter_module.html", "extension": ".html", "size_bytes": 13807, "content": "\nModule ngx_http_image_filter_module
\n\nPlanning your ingress-nginx migration? Start here:\nkubernetes.nginx.org.\n\n

Module ngx_http_image_filter_module

Example Configuration
Directives
     image_filter
     image_filter_buffer
     image_filter_interlace
     image_filter_jpeg_quality
     image_filter_sharpen
     image_filter_transparency
     image_filter_webp_quality
\n\n

\nThe ngx_http_image_filter_module module (0.7.54+) is a filter\nthat transforms images in JPEG, GIF, PNG, and WebP formats.\n

\nThis module is not built by default, it should be enabled with the\n--with-http_image_filter_module\nconfiguration parameter.\n

\nThis module utilizes the\nlibgd library.\nIt is recommended to use the latest available version of the library.\n

\n

\nThe WebP format support appeared in version 1.11.6.\nTo transform images in this format,\nthe libgd library must be compiled with the WebP support.\n

\n

\n\n\n

Example Configuration

\n

\nlocation /img/ {\n    proxy_pass   http://backend;\n    image_filter resize 150 100;\n    image_filter rotate 90;\n    error_page   415 = /empty;\n}\n\nlocation = /empty {\n    empty_gif;\n}\n

\n

\n\n\n

Directives

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n image_filter off;
image_filter test;
image_filter size;
image_filter \n rotate\n 90 | 180 |\n 270;
image_filter \n resize\n width\n height;
image_filter \n crop\n width\n height;
\n
\n Default:\n \n
image_filter off;
\n
\n Context:\n \n location
\n

\nSets the type of transformation to perform on images:\n

\n\n
off
\n
\nturns off module processing in a surrounding location.\n
\n\n
test
\n
\nensures that responses are images in either JPEG, GIF, PNG, or WebP format.\nOtherwise, the\n415 (Unsupported Media Type)\nerror is returned.\n
\n\n
size
\n
\noutputs information about images in a JSON format, e.g.:\n
\n{ \"img\" : { \"width\": 100, \"height\": 100, \"type\": \"gif\" } }\n
\nIn case of an error, the output is as follows:\n
\n{}\n
\n
\n\n
rotate\n90|180|270\n
\n
\nrotates images counter-clockwise by the specified number of degrees.\nParameter value can contain variables.\nThis mode can be used either alone or along with the\nresize and crop transformations.\n
\n\n
resize\nwidth\nheight\n
\n
\nproportionally reduces an image to the specified sizes.\nTo reduce by only one dimension, another dimension can be specified as\n“-”.\nIn case of an error, the server will return code\n415 (Unsupported Media Type).\nParameter values can contain variables.\nWhen used along with the rotate parameter,\nthe rotation happens after reduction.\n
\n\n
crop\nwidth\nheight\n
\n
\nproportionally reduces an image to the larger side size\nand crops extraneous edges by another side.\nTo reduce by only one dimension, another dimension can be specified as\n“-”.\nIn case of an error, the server will return code\n415 (Unsupported Media Type).\nParameter values can contain variables.\nWhen used along with the rotate parameter,\nthe rotation happens before reduction.\n
\n\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n image_filter_buffer size;
\n
\n Default:\n \n
image_filter_buffer 1M;
\n
\n Context:\n \n http, server, location
\n

\nSets the maximum size of the buffer used for reading images.\nWhen the size is exceeded the server returns error\n415 (Unsupported Media Type).\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n image_filter_interlace on | off;
\n
\n Default:\n \n
image_filter_interlace off;
\n
\n Context:\n \n http, server, location
\n

This directive appeared in version 1.3.15.\n

\nIf enabled, final images will be interlaced.\nFor JPEG, final images will be in “progressive JPEG” format.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n image_filter_jpeg_quality quality;
\n
\n Default:\n \n
image_filter_jpeg_quality 75;
\n
\n Context:\n \n http, server, location
\n

\nSets the desired quality of the transformed JPEG images.\nAcceptable values are in the range from 1 to 100.\nLesser values usually imply both lower image quality and less data to transfer.\nThe maximum recommended value is 95.\nParameter value can contain variables.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n image_filter_sharpen percent;
\n
\n Default:\n \n
image_filter_sharpen 0;
\n
\n Context:\n \n http, server, location
\n

\nIncreases sharpness of the final image.\nThe sharpness percentage can exceed 100.\nThe zero value disables sharpening.\nParameter value can contain variables.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n image_filter_transparency on|off;
\n
\n Default:\n \n
image_filter_transparency on;
\n
\n Context:\n \n http, server, location
\n

\nDefines whether transparency should be preserved when transforming\nGIF images or PNG images with colors specified by a palette.\nThe loss of transparency results in images of a better quality.\nThe alpha channel transparency in PNG is always preserved.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n image_filter_webp_quality quality;
\n
\n Default:\n \n
image_filter_webp_quality 80;
\n
\n Context:\n \n http, server, location
\n

This directive appeared in version 1.11.6.\n

\nSets the desired quality of the transformed WebP images.\nAcceptable values are in the range from 1 to 100.\nLesser values usually imply both lower image quality and less data to transfer.\nParameter value can contain variables.\n

\n\n
\n", "encoding": "utf-8"} +{"path": "en\\docs\\http\\ngx_http_index_module.html", "extension": ".html", "size_bytes": 4662, "content": "\nModule ngx_http_index_module
\n\nPlanning your ingress-nginx migration? Start here:\nkubernetes.nginx.org.\n\n

Module ngx_http_index_module

Example Configuration
Directives
     index
\n\n

\nThe ngx_http_index_module module processes requests\nending with the slash character (‘/’).\nSuch requests can also be processed by the\nngx_http_autoindex_module\nand\nngx_http_random_index_module\nmodules.\n

\n\n\n

Example Configuration

\n

\nlocation / {\n    index index.$geo.html index.html;\n}\n

\n

\n\n\n

Directives

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n index file ...;
\n
\n Default:\n \n
index index.html;
\n
\n Context:\n \n http, server, location
\n

\nDefines files that will be used as an index.\nThe file name can contain variables.\nFiles are checked in the specified order.\nThe last element of the list can be a file with an absolute path.\nExample:\n

\nindex index.$geo.html index.0.html /index.html;\n

\n

\nIt should be noted that using an index file causes an internal redirect,\nand the request can be processed in a different location.\nFor example, with the following configuration:\n

\nlocation = / {\n    index index.html;\n}\n\nlocation / {\n    ...\n}\n

\na “/” request will actually be processed in the\nsecond location as “/index.html”.\n

\n\n
\n", "encoding": "utf-8"} +{"path": "en\\docs\\http\\ngx_http_internal_redirect_module.html", "extension": ".html", "size_bytes": 5533, "content": "\nModule ngx_http_internal_redirect_module
\n\nPlanning your ingress-nginx migration? Start here:\nkubernetes.nginx.org.\n\n

Module ngx_http_internal_redirect_module

Example Configuration
Directives
     internal_redirect
\n\n

\nThe ngx_http_internal_redirect_module module (1.23.4) allows\nmaking an internal redirect.\nIn contrast to\nrewriting URIs,\nthe redirection is made after checking\nrequest and\nconnection processing limits,\nand access limits.\n

\n

\nThis module is available as part of our\ncommercial subscription.\n

\n

\n\n\n

Example Configuration

\n

\nlimit_req_zone $jwt_claim_sub zone=jwt_sub:10m rate=1r/s;\n\nserver {\n    location / {\n        auth_jwt          \"realm\";\n        auth_jwt_key_file key.jwk;\n\n        internal_redirect @rate_limited;\n    }\n\n    location @rate_limited {\n        internal;\n\n        limit_req  zone=jwt_sub burst=10;\n        proxy_pass http://backend;\n    }\n}\n

\nThe example implements\nper-user\nrate limiting.\nImplementation without internal_redirect\nis vulnerable to DoS attacks by unsigned JWTs, as normally the\nlimit_req\ncheck is performed\nbefore\nauth_jwt check.\nUsing internal_redirect\nallows reordering these checks.\n

\n\n\n

Directives

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n internal_redirect uri;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n server, location
\n

\nSets the URI for internal redirection of the request.\nIt is also possible to use a\nnamed location\ninstead of the URI.\nThe uri value can contain variables.\nIf the uri value is empty,\nthen the redirect will not be made.\n

\n\n
\n", "encoding": "utf-8"} +{"path": "en\\docs\\http\\ngx_http_js_module.html", "extension": ".html", "size_bytes": 52850, "content": "\nModule ngx_http_js_module
\n\nPlanning your ingress-nginx migration? Start here:\nkubernetes.nginx.org.\n\n

Module ngx_http_js_module

Example Configuration
Directives
     js_body_filter
     js_access
     js_content
     js_context_reuse
     js_engine
     js_fetch_buffer_size
     js_fetch_ciphers
     js_fetch_max_response_buffer_size
     js_fetch_protocols
     js_fetch_timeout
     js_fetch_trusted_certificate
     js_fetch_verify
     js_fetch_verify_depth
     js_fetch_proxy
     js_fetch_keepalive
     js_fetch_keepalive_requests
     js_fetch_keepalive_time
     js_fetch_keepalive_timeout
     js_header_filter
     js_import
     js_include
     js_load_http_native_module
     js_path
     js_periodic
     js_preload_object
     js_set
     js_shared_dict_zone
     js_var
Request Argument
\n\n

\nThe ngx_http_js_module module is used to implement\nlocation and variable handlers\nin njs —\na subset of the JavaScript language.\n

\nDownload and install instructions are available\nhere.\n

\n\n\n

Example Configuration

\nThe example works since\n0.4.0.\n

\nhttp {\n    js_import http.js;\n\n    js_set $foo     http.foo;\n    js_set $summary http.summary;\n    js_set $hash    http.hash;\n\n    resolver 10.0.0.1;\n\n    server {\n        listen 8000;\n\n        location / {\n            add_header X-Foo $foo;\n            js_content http.baz;\n        }\n\n        location = /summary {\n            return 200 $summary;\n        }\n\n        location = /hello {\n            js_content http.hello;\n        }\n\n        # since 0.7.0\n        location = /fetch {\n            js_content                   http.fetch;\n            js_fetch_trusted_certificate /path/to/ISRG_Root_X1.pem;\n        }\n\n        # since 0.7.0\n        location = /crypto {\n            add_header Hash $hash;\n            return     200;\n        }\n    }\n}\n

\n

\nThe http.js file:\n

\nfunction foo(r) {\n    r.log(\"hello from foo() handler\");\n    return \"foo\";\n}\n\nfunction summary(r) {\n    var a, s, h;\n\n    s = \"JS summary\\n\\n\";\n\n    s += \"Method: \" + r.method + \"\\n\";\n    s += \"HTTP version: \" + r.httpVersion + \"\\n\";\n    s += \"Host: \" + r.headersIn.host + \"\\n\";\n    s += \"Remote Address: \" + r.remoteAddress + \"\\n\";\n    s += \"URI: \" + r.uri + \"\\n\";\n\n    s += \"Headers:\\n\";\n    for (h in r.headersIn) {\n        s += \"  header '\" + h + \"' is '\" + r.headersIn[h] + \"'\\n\";\n    }\n\n    s += \"Args:\\n\";\n    for (a in r.args) {\n        s += \"  arg '\" + a + \"' is '\" + r.args[a] + \"'\\n\";\n    }\n\n    return s;\n}\n\nfunction baz(r) {\n    r.status = 200;\n    r.headersOut.foo = 1234;\n    r.headersOut['Content-Type'] = \"text/plain; charset=utf-8\";\n    r.headersOut['Content-Length'] = 15;\n    r.sendHeader();\n    r.send(\"nginx\");\n    r.send(\"java\");\n    r.send(\"script\");\n\n    r.finish();\n}\n\nfunction hello(r) {\n    r.return(200, \"Hello world!\");\n}\n\n// since 0.7.0\nasync function fetch(r) {\n    let results = await Promise.all([ngx.fetch('https://nginx.org/'),\n                                     ngx.fetch('https://nginx.org/en/')]);\n\n    r.return(200, JSON.stringify(results, undefined, 4));\n}\n\n// since 0.7.0\nasync function hash(r) {\n    let hash = await crypto.subtle.digest('SHA-512', r.headersIn.host);\n    r.setReturnValue(Buffer.from(hash).toString('hex'));\n}\n\nexport default {foo, summary, baz, hello, fetch, hash};\n

\n

\n\n\n

Directives

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n js_body_filter module.function\n[buffer_type=string | buffer];
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n location, if in location, limit_except
\n

This directive appeared in version 0.5.2.\n

\nSets an njs function as a response body filter.\nThe filter function is called for each data chunk of a response body\nwith the following arguments:\n\n

\n
r
\n
\nthe HTTP request object\n
\n\n
data
\n
\nthe incoming data chunk,\nmay be a string or Buffer\ndepending on the buffer_type value,\nby default is a string.\nSince 0.8.5, the\ndata value is implicitly converted to a valid UTF-8 string\nby default.\nFor binary data, the buffer_type value\nshould be set to buffer.\n
\n\n
flags
\n
\nan object with the following properties:\n
\n
last
\n
\na boolean value, true if data is a last buffer.\n
\n\n
\n
\n\n

\n

\nThe filter function can pass its own modified version\nof the input data chunk to the next body filter by calling\nr.sendBuffer().\nFor example, to transform all the lowercase letters in the response body:\n

\nfunction filter(r, data, flags) {\n    r.sendBuffer(data.toLowerCase(), flags);\n}\n

\n

\nIf the filter function changes the length of the response body, the\n“Content-Length” response header (if present) should be cleared\nin js_header_filter\nto enforce chunked transfer encoding:\n

\nexample.conf:\n location /foo {\n     # proxy_pass http://localhost:8080;\n\n    js_header_filter main.clear_content_length;\n    js_body_filter   main.filter;\n }\n\nexample.js:\n function clear_content_length(r) {\n     delete r.headersOut['Content-Length'];\n }\n

\n

\nTo stop filtering and pass the data chunks to the client\nwithout calling js_body_filter,\nr.done()\ncan be used.\nFor example, to prepend some data to the response body:\n

\nfunction prepend(r, data, flags) {\n    r.sendBuffer(\"XXX\");\n    r.sendBuffer(data, flags);\n    r.done();\n}\n

\n

\n

\nAs the js_body_filter handler\nreturns its result immediately, it supports\nonly synchronous operations.\nThus, asynchronous operations such as\nr.subrequest()\nor\nsetTimeout()\nare not supported.\n

\n

\n

\nThe directive can be specified inside the\nif block\nsince 0.7.7.\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n js_access module.function;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n location, if in location, limit_except
\n

This directive appeared in version 0.9.9.\n

\nSets an njs function as a handler in the\naccess phase.\nAsynchronous operations such as\nr.subrequest(),\nngx.fetch(),\nand setTimeout()\nare supported.\n

\nA handler that returns without calling\nr.return()\nor\nr.decline()\ngrants access.\nTo deny access or send a custom response (for example, a redirect),\nthe handler may call\nr.return().\nTo make the handler express no opinion, deferring the decision to other\naccess checkers under\nsatisfy any,\nthe handler may call\nr.decline().\n

\nFor example:\n

\nexample.conf:\n location /protected/ {\n     js_access  main.auth;\n     proxy_pass http://upstream;\n }\n\nexample.js:\n async function auth(r) {\n     let reply = await ngx.fetch('http://authsvc/check', {\n         headers: {Authorization: r.headersIn.Authorization}\n     });\n\n     if (reply.status != 200) {\n         r.return(401);\n         return;\n     }\n }\n\n export default {auth};\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n js_content module.function;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n location, if in location, limit_except
\n

\nSets an njs function as a location content handler.\nSince 0.4.0,\na module function can be referenced.\n

\n

\nThe directive can be specified inside the\nif block\nsince 0.7.7.\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n js_context_reuse number;
\n
\n Default:\n \n
js_context_reuse 128;
\n
\n Context:\n \n http, server, location
\n

This directive appeared in version 0.8.6.\n

\nSets a maximum number of JS context to be reused for\nQuickJS engine.\nEach context is used for a single request.\nThe finished context is put into a pool of reusable contexts.\nIf the pool is full, the context is destroyed.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n js_engine njs | qjs;
\n
\n Default:\n \n
js_engine njs;
\n
\n Context:\n \n http, server, location
\n

This directive appeared in version 0.8.6.\n

\nSets a JavaScript engine\nto be used for njs scripts.\nThe njs parameter sets the njs engine, also used by default.\nThe qjs parameter sets the QuickJS engine.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n js_fetch_buffer_size size;
\n
\n Default:\n \n
js_fetch_buffer_size 16k;
\n
\n Context:\n \n http, server, location
\n

This directive appeared in version 0.7.4.\n

\nSets the size of the buffer used for reading and writing\nwith Fetch API.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n js_fetch_ciphers ciphers;
\n
\n Default:\n \n
js_fetch_ciphers HIGH:!aNULL:!MD5;
\n
\n Context:\n \n http, server, location
\n

This directive appeared in version 0.7.0.\n

\nSpecifies the enabled ciphers for HTTPS requests\nwith Fetch API.\nThe ciphers are specified in the format understood by the\nOpenSSL library.\n

\nThe full list can be viewed using the\n“openssl ciphers” command.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n js_fetch_max_response_buffer_size size;
\n
\n Default:\n \n
js_fetch_max_response_buffer_size 1m;
\n
\n Context:\n \n http, server, location
\n

This directive appeared in version 0.7.4.\n

\nSets the maximum size of the response received\nwith Fetch API.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n js_fetch_protocols \n [TLSv1]\n [TLSv1.1]\n [TLSv1.2]\n [TLSv1.3];
\n
\n Default:\n \n
js_fetch_protocols TLSv1 TLSv1.1 TLSv1.2;
\n
\n Context:\n \n http, server, location
\n

This directive appeared in version 0.7.0.\n

\nEnables the specified protocols for HTTPS requests\nwith Fetch API.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n js_fetch_timeout time;
\n
\n Default:\n \n
js_fetch_timeout 60s;
\n
\n Context:\n \n http, server, location
\n

This directive appeared in version 0.7.4.\n

\nDefines a timeout for reading and writing\nfor Fetch API.\nThe timeout is set only between two successive read/write operations,\nnot for the whole response.\nIf no data is transmitted within this time, the connection is closed.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n js_fetch_trusted_certificate file;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n http, server, location
\n

This directive appeared in version 0.7.0.\n

\nSpecifies a file with trusted CA certificates in the PEM format\nused to\nverify\nthe HTTPS certificate\nwith Fetch API.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n js_fetch_verify on | off;
\n
\n Default:\n \n
js_fetch_verify on;
\n
\n Context:\n \n http, server, location
\n

This directive appeared in version 0.7.4.\n

\nEnables or disables verification of the HTTPS server certificate\nwith Fetch API.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n js_fetch_verify_depth number;
\n
\n Default:\n \n
js_fetch_verify_depth 100;
\n
\n Context:\n \n http, server, location
\n

This directive appeared in version 0.7.0.\n

\nSets the verification depth in the HTTPS server certificates chain\nwith Fetch API.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n js_fetch_proxy url;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n http, server, location
\n

This directive appeared in version 0.9.4.\n

\nConfigures a forward proxy URL\nwith Fetch API.\nThe url supports the HTTP scheme only\nand can contain optional user credentials\nin the format http://[user:password@]host:port\nfor Basic authentication.\nSupports both HTTP and HTTPS connections to destination servers.\nIf the url is empty, proxy routing is disabled.\nThe parameter value can contain variables.\n

\nExample:\n

\nlocation /fetch {\n    js_fetch_proxy http://user:pass@proxy.example.com:3128;\n    js_content main.fetch_handler;\n}\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n js_fetch_keepalive connections;
\n
\n Default:\n \n
js_fetch_keepalive 0;
\n
\n Context:\n \n http, server, location
\n

This directive appeared in version 0.9.2.\n

\nActivates the cache for connections to destination servers.\nWhen the value is greater than 0,\nenables keepalive connections for\nFetch API.\n

\nThe connections parameter sets the maximum number of idle\nkeepalive connections to destination servers that are preserved in the cache\nof each worker process.\nWhen this number is exceeded, the least recently used connections are closed.\n

\nExample:\n

\nlocation /fetch {\n    js_fetch_keepalive 32;\n    js_fetch_trusted_certificate /path/to/ISRG_Root_X1.pem;\n    js_content main.fetch_handler;\n}\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n js_fetch_keepalive_requests number;
\n
\n Default:\n \n
js_fetch_keepalive_requests 1000;
\n
\n Context:\n \n http, server, location
\n

This directive appeared in version 0.9.2.\n

\nSets the maximum number of requests that can be served through one keepalive\nconnection with Fetch API.\nAfter the maximum number of requests is made, the connection is closed.\n

\nClosing connections periodically is necessary to free per-connection memory\nallocations.\nTherefore, using too high maximum number of requests could result in\nexcessive memory usage and not recommended.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n js_fetch_keepalive_time time;
\n
\n Default:\n \n
js_fetch_keepalive_time 1h;
\n
\n Context:\n \n http, server, location
\n

This directive appeared in version 0.9.2.\n

\nLimits the maximum time during which requests can be processed through one\nkeepalive connection with Fetch API.\nAfter this time is reached, the connection is closed following the subsequent\nrequest processing.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n js_fetch_keepalive_timeout time;
\n
\n Default:\n \n
js_fetch_keepalive_timeout 60s;
\n
\n Context:\n \n http, server, location
\n

This directive appeared in version 0.9.2.\n

\nSets a timeout during which an idle keepalive connection to a destination server\nwill stay open with Fetch API.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n js_header_filter module.function;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n location, if in location, limit_except
\n

This directive appeared in version 0.5.1.\n

\nSets an njs function as a response header filter.\nThe directive allows changing arbitrary header fields of a response header.\n

\n

\nAs the js_header_filter handler\nreturns its result immediately, it supports\nonly synchronous operations.\nThus, asynchronous operations such as\nr.subrequest()\nor\nsetTimeout()\nare not supported.\n

\n

\n

\nThe directive can be specified inside the\nif block\nsince 0.7.7.\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n js_import module.js |\nexport_name from module.js;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n http, server, location
\n

This directive appeared in version 0.4.0.\n

\nImports a module that implements location and variable handlers in njs.\nThe export_name is used as a namespace\nto access module functions.\nIf the export_name is not specified,\nthe module name will be used as a namespace.\n

\njs_import http.js;\n

\nHere, the module name http is used as a namespace\nwhile accessing exports.\nIf the imported module exports foo(),\nhttp.foo is used to refer to it.\n

\nSeveral js_import directives can be specified.\n

\nWhen js_import is specified inside a\nlocation,\nthe imported modules are visible only if no JavaScript code\nhas been invoked earlier in the request.\nA single VM is created per request when a\njs_set variable is first accessed\nor when a js_content, js_header_filter,\njs_body_filter, or js_access handler\nis first invoked.\nThe VM is cloned from the configuration scope active at that moment,\nand all subsequent JavaScript invocations within the request reuse it.\nThus, if any of the above is referenced before the request is mapped\nto its final location, for example from a server-level\nset,\nthe VM is bound to the import set of the outer scope, and modules\nimported in the matched location will not be visible.\nTo avoid this, declare such imports in a common parent scope.\n

\n

\nThe directive can be specified on the\nserver and location level\nsince 0.7.7.\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n js_include file;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n http
\n

\nSpecifies a file that implements location and variable handlers in njs:\n

\nnginx.conf:\njs_include http.js;\nlocation   /version {\n    js_content version;\n}\n\nhttp.js:\nfunction version(r) {\n    r.return(200, njs.version);\n}\n

\n

\nThe directive was made obsolete in version\n0.4.0\nand was removed in version\n0.7.1.\nThe js_import directive should be used instead.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n js_load_http_native_module path [as name];
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n main
\n

This directive appeared in version 0.9.5.\n

\nLoads a native module\n(shared library) for use in HTTP JavaScript code.\nThe directive is\nQuickJS-only\nand is not available when using the njs built-in JavaScript engine.\n

\nThe path parameter\nspecifies the absolute path to the shared library file.\nThe optional as name parameter\nprovides an alias name for importing the module in JavaScript code.\nIf not specified, the module can be imported using its filename.\n

\nExample:\n

\njs_load_http_native_module /path/to/mylib.so;\njs_load_http_native_module /path/to/other.so as myalias;\n\nhttp {\n    js_import main.js;\n    # ... rest of http configuration\n}\n

\nIn JavaScript code:\n

\n// Import by filename\nimport * as mylib from 'mylib.so';\n\n// Import by alias\nimport * as myalias from 'myalias';\n\n// Use exported functions\nlet result = mylib.add(5, 10);\n

\n

\n

\nFor security reasons, this directive is only allowed\nin the main configuration context.\nNative modules run with full process privileges;\nuse absolute paths and ensure proper code review.\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n js_path \npath;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n http, server, location
\n

This directive appeared in version 0.3.0.\n

\nSets an additional path for njs modules.\n

\n

\nThe directive can be specified on the\nserver and location level\nsince 0.7.7.\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n js_periodic module.function\n [interval=time]\n [jitter=number]\n [worker_affinity=mask];
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n location
\n

This directive appeared in version 0.8.1.\n

\nSpecifies a content handler to run at regular interval.\nThe handler receives a\nsession object\nas its first argument,\nit also has access to global objects such as\nngx.\n

\nThe optional interval parameter\nsets the interval between two consecutive runs,\nby default, 5 seconds.\n

\nThe optional jitter parameter sets the time within which\nthe location content handler will be randomly delayed,\nby default, there is no delay.\n

\nBy default, the js_handler is executed on worker process 0.\nThe optional worker_affinity parameter\nallows specifying particular worker processes\nwhere the location content handler should be executed.\nEach worker process set is represented by a bitmask of allowed worker processes.\nThe all mask allows the handler to be executed\nin all worker processes.\n

\nExample:\n

\nexample.conf:\n\nlocation @periodics {\n    # to be run at 1 minute intervals in worker process 0\n    js_periodic main.handler interval=60s;\n\n    # to be run at 1 minute intervals in all worker processes\n    js_periodic main.handler interval=60s worker_affinity=all;\n\n    # to be run at 1 minute intervals in worker processes 1 and 3\n    js_periodic main.handler interval=60s worker_affinity=0101;\n\n    resolver 10.0.0.1;\n    js_fetch_trusted_certificate /path/to/ISRG_Root_X1.pem;\n}\n\nexample.js:\n\nasync function handler(s) {\n    let reply = await ngx.fetch('https://nginx.org/en/docs/njs/');\n    let body = await reply.text();\n\n    ngx.log(ngx.INFO, body);\n}\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n js_preload_object name.json |\nname from file.json;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n http, server, location
\n

This directive appeared in version 0.7.8.\n

\nPreloads an\nimmutable object\nat configure time.\nThe name is used as a name of the global variable\nthough which the object is available in njs code.\nIf the name is not specified,\nthe file name will be used instead.\n

\njs_preload_object map.json;\n

\nHere, the map is used as a name\nwhile accessing the preloaded object.\n

\nSeveral js_preload_object directives can be specified.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n js_set \n $variable\n module.function\n [nocache];
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n http, server, location
\n

\nSets an njs function\nfor the specified variable.\nSince 0.4.0,\na module function can be referenced.\n

\nThe function is called when\nthe variable is referenced for the first time for a given request.\nThe exact moment depends on a\nphase\nat which the variable is referenced.\nThis can be used to perform some logic\nnot related to variable evaluation.\nFor example, if the variable is referenced only in the\nlog_format directive,\nits handler will not be executed until the log phase.\nThis handler can be used to do some cleanup\nright before the request is freed.\n

\nSince 0.8.6,\nif an optional argument nocache is specified,\nthe handler is called every time it is referenced.\nDue to current limitations\nof the rewrite module,\nwhen a nocache variable is referenced by the\nset directive\nits handler should always return a fixed-length value.\n

\n

\nAs the js_set handler\nreturns its result immediately, it supports\nonly synchronous operations.\nThus, asynchronous operations such as\nr.subrequest()\nor\nsetTimeout()\nare not supported.\n

\n

\n

\nThe directive can be specified on the\nserver and location level\nsince 0.7.7.\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n js_shared_dict_zone \n zone=name:size\n [timeout=time]\n [type=string|number]\n [evict]\n [state=file];
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n http
\n

This directive appeared in version 0.8.0.\n

\nSets the name and size of the shared memory zone\nthat keeps the\nkey-value dictionary\nshared between worker processes.\n

\nBy default the shared dictionary uses a string as a key and a value.\nThe optional type parameter\nallows redefining the value type to number.\n

\nThe optional timeout parameter sets\nthe time in milliseconds\nafter which all shared dictionary entries are removed from the zone.\nIf some entries require a different removal time, it can be set\nwith the timeout argument of the\nadd,\nincr, and\nset\nmethods\n(0.8.5).\n

\nThe optional evict parameter removes the oldest\nkey-value pair when the zone storage is exhausted.\n

\nThe optional state parameter specifies a file\nthat keeps the shared dictionary state\nin JSON format and makes it persistent across nginx restarts\n(0.9.1).\n

\nExample:\n

\nexample.conf:\n    # Creates a 1Mb dictionary with string values,\n    # removes key-value pairs after 60 seconds of inactivity:\n    js_shared_dict_zone zone=foo:1M timeout=60s;\n\n    # Creates a 512Kb dictionary with string values,\n    # forcibly removes oldest key-value pairs when the zone is exhausted:\n    js_shared_dict_zone zone=bar:512K timeout=30s evict;\n\n    # Creates a 32Kb permanent dictionary with number values:\n    js_shared_dict_zone zone=num:32k type=number;\n\n    # Creates a 1Mb dictionary with string values and persistent state:\n    js_shared_dict_zone zone=persistent:1M state=/tmp/dict.json;\n\nexample.js:\n    function get(r) {\n        r.return(200, ngx.shared.foo.get(r.args.key));\n    }\n\n    function set(r) {\n        r.return(200, ngx.shared.foo.set(r.args.key, r.args.value));\n    }\n\n    function del(r) {\n        r.return(200, ngx.shared.bar.delete(r.args.key));\n    }\n\n    function increment(r) {\n        r.return(200, ngx.shared.num.incr(r.args.key, 2));\n    }\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n js_var $variable [value];
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n http, server, location
\n

This directive appeared in version 0.5.3.\n

\nDeclares\na writable\nvariable.\nThe value can contain text, variables, and their combination.\nThe variable is not overwritten after a redirect\nunlike variables created with the\nset directive.\n

\n

\nThe directive can be specified on the\nserver and location level\nsince 0.7.7.\n

\n

\n\n\n

Request Argument

\nEach HTTP njs handler receives one argument, a request\nobject.\n

\n\n
\n", "encoding": "utf-8"} +{"path": "en\\docs\\http\\ngx_http_keyval_module.html", "extension": ".html", "size_bytes": 8563, "content": "\nModule ngx_http_keyval_module
\n\nPlanning your ingress-nginx migration? Start here:\nkubernetes.nginx.org.\n\n

Module ngx_http_keyval_module

Example Configuration
Directives
     keyval
     keyval_zone
\n\n

\nThe ngx_http_keyval_module module (1.13.3) creates variables\nwith values taken from key-value pairs managed by the\nAPI\nor a variable (1.15.10) that can also be set with\nnjs.\n

\n

\nThis module is available as part of our\ncommercial subscription.\n

\n

\n\n\n

Example Configuration

\n

\nhttp {\n\n    keyval_zone zone=one:32k state=/var/lib/nginx/state/one.keyval;\n    keyval $arg_text $text zone=one;\n    ...\n    server {\n        ...\n        location / {\n            return 200 $text;\n        }\n\n        location /api {\n            api write=on;\n        }\n    }\n}\n

\n

\n\n\n

Directives

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n keyval \n key\n $variable\n zone=name;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n http
\n

\nCreates a new $variable whose value\nis looked up by the key in the key-value database.\nMatching rules are defined by the\ntype parameter of the\nkeyval_zone directive.\nThe database is stored in a shared memory zone\nspecified by the zone parameter.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n keyval_zone \n zone=name:size\n [state=file]\n [timeout=time]\n [type=string|ip|prefix]\n [sync];
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n http
\n

\nSets the name and size of the shared memory zone\nthat keeps the key-value database.\nKey-value pairs are managed by the\nAPI.\n

\nThe optional state parameter specifies a file\nthat keeps the current state of the key-value database in the JSON format\nand makes it persistent across nginx restarts.\nChanging the file content directly should be avoided.\n

\nExamples:\n

\nkeyval_zone zone=one:32k state=/var/lib/nginx/state/one.keyval; # path for Linux\nkeyval_zone zone=one:32k state=/var/db/nginx/state/one.keyval;  # path for FreeBSD\n

\n

\nThe optional timeout parameter (1.15.0) sets\nthe time after which key-value pairs are removed from the zone.\n

\nThe optional type parameter (1.17.1) activates\nan extra index optimized for matching the key of a certain type\nand defines matching rules when evaluating\na keyval $variable.\n

\nThe index is stored in the same shared memory zone\nand thus requires additional storage.\n

\n\n

\n\n
type=string
\n
\ndefault, no index is enabled;\nvariable lookup is performed using exact match\nof the record key and a search key\n
\n\n
type=ip
\n
\nthe search key is the textual representation of IPv4 or IPv6 address\nor CIDR range;\nto match a record key, the search key must belong to a subnet\nspecified by a record key or exactly match an IP address\n
\n\n
type=prefix
\n
\nvariable lookup is performed using prefix match\nof a record key and a search key (1.17.5);\nto match a record key, the record key must be a prefix of the search key\n
\n\n

\n

\nThe optional sync parameter (1.15.0) enables\nsynchronization\nof the shared memory zone.\nThe synchronization requires the\ntimeout parameter to be set.\n

\nIf the synchronization is enabled, removal of key-value pairs (no matter\none\nor\nall)\nwill be performed only on a target cluster node.\nThe same key-value pairs on other cluster nodes\nwill be removed upon timeout.\n

\n

\n\n
\n", "encoding": "utf-8"} +{"path": "en\\docs\\http\\ngx_http_limit_conn_module.html", "extension": ".html", "size_bytes": 13211, "content": "\nModule ngx_http_limit_conn_module
\n\nPlanning your ingress-nginx migration? Start here:\nkubernetes.nginx.org.\n\n

Module ngx_http_limit_conn_module

Example Configuration
Directives
     limit_conn
     limit_conn_dry_run
     limit_conn_log_level
     limit_conn_status
     limit_conn_zone
     limit_zone
Embedded Variables
\n\n

\nThe ngx_http_limit_conn_module module is used to\nlimit the number of connections per the defined key, in\nparticular, the number of connections from a single IP address.\n

\nNot all connections are counted.\nA connection is counted only if it has a request being processed by the server\nand the whole request header has already been read.\n

\n\n\n

Example Configuration

\n

\nhttp {\n    limit_conn_zone $binary_remote_addr zone=addr:10m;\n\n    ...\n\n    server {\n\n        ...\n\n        location /download/ {\n            limit_conn addr 1;\n        }\n

\n

\n\n\n

Directives

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n limit_conn zone number;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n http, server, location
\n

\nSets the shared memory zone\nand the maximum allowed number of connections for a given key value.\nWhen this limit is exceeded, the server will return the\nerror\nin reply to a request.\nFor example, the directives\n

\nlimit_conn_zone $binary_remote_addr zone=addr:10m;\n\nserver {\n    location /download/ {\n        limit_conn addr 1;\n    }\n

\nallow only one connection per an IP address at a time.\n

\nIn HTTP/2 and HTTP/3,\neach concurrent request is considered a separate connection.\n

\n

\nThere could be several limit_conn directives.\nFor example, the following configuration will limit the number\nof connections to the server per a client IP and, at the same time,\nthe total number of connections to the virtual server:\n

\nlimit_conn_zone $binary_remote_addr zone=perip:10m;\nlimit_conn_zone $server_name zone=perserver:10m;\n\nserver {\n    ...\n    limit_conn perip 10;\n    limit_conn perserver 100;\n}\n

\n\n

\nThese directives are inherited from the previous configuration level\nif and only if there are no limit_conn directives\ndefined on the current level.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n limit_conn_dry_run on | off;
\n
\n Default:\n \n
limit_conn_dry_run off;
\n
\n Context:\n \n http, server, location
\n

This directive appeared in version 1.17.6.\n

\nEnables the dry run mode.\nIn this mode, the number of connections is not limited, however,\nin the shared memory zone, the number of excessive connections is accounted\nas usual.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n limit_conn_log_level \ninfo |\nnotice |\nwarn |\nerror;
\n
\n Default:\n \n
limit_conn_log_level error;
\n
\n Context:\n \n http, server, location
\n

This directive appeared in version 0.8.18.\n

\nSets the desired logging level for cases when the server\nlimits the number of connections.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n limit_conn_status code;
\n
\n Default:\n \n
limit_conn_status 503;
\n
\n Context:\n \n http, server, location
\n

This directive appeared in version 1.3.15.\n

\nSets the status code to return in response to rejected requests.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n limit_conn_zone \n key\n zone=name:size;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n http
\n

\nSets parameters for a shared memory zone\nthat will keep states for various keys.\nIn particular, the state includes the current number of connections.\nThe key can contain text, variables, and their combination.\nRequests with an empty key value are not accounted.\n

\nPrior to version 1.7.6, a key could contain exactly one variable.\n

\nUsage example:\n

\nlimit_conn_zone $binary_remote_addr zone=addr:10m;\n

\nHere, a client IP address serves as a key.\nNote that instead of $remote_addr, the\n$binary_remote_addr variable is used here.\nThe $remote_addr variable’s size can\nvary from 7 to 15 bytes.\nThe stored state occupies either\n32 or 64 bytes of memory on 32-bit platforms and always 64\nbytes on 64-bit platforms.\nThe $binary_remote_addr variable’s size\nis always 4 bytes for IPv4 addresses or 16 bytes for IPv6 addresses.\nThe stored state always occupies 32 or 64 bytes\non 32-bit platforms and 64 bytes on 64-bit platforms.\nOne megabyte zone can keep about 32 thousand 32-byte states\nor about 16 thousand 64-byte states.\nIf the zone storage is exhausted, the server will return the\nerror\nto all further requests.\n

\n

\nAdditionally, as part of our\ncommercial subscription,\nthe\nstatus information\nfor each such shared memory zone can be\nobtained or\nreset\nwith the API since 1.17.7.\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n limit_zone \n name\n $variable\n size;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n http
\n

\nThis directive was made obsolete in version 1.1.8\nand was removed in version 1.7.6.\nAn equivalent limit_conn_zone directive\nwith a changed syntax should be used instead:\n

\nlimit_conn_zone\n$variable\nzone=name:size;\n

\n

\n\n\n

Embedded Variables

\n

\n\n
$limit_conn_status
\n
\nkeeps the result of limiting the number of connections (1.17.6):\nPASSED,\nREJECTED, or\nREJECTED_DRY_RUN\n
\n\n

\n

\n\n
\n", "encoding": "utf-8"} +{"path": "en\\docs\\http\\ngx_http_limit_req_module.html", "extension": ".html", "size_bytes": 13562, "content": "\nModule ngx_http_limit_req_module
\n\nPlanning your ingress-nginx migration? Start here:\nkubernetes.nginx.org.\n\n

Module ngx_http_limit_req_module

Example Configuration
Directives
     limit_req
     limit_req_dry_run
     limit_req_log_level
     limit_req_status
     limit_req_zone
Embedded Variables
\n\n

\nThe ngx_http_limit_req_module module (0.7.21) is used\nto limit the request processing rate per a defined key,\nin particular, the processing rate of requests coming\nfrom a single IP address.\nThe limitation is done using the “leaky bucket” method.\n

\n\n\n

Example Configuration

\n

\nhttp {\n    limit_req_zone $binary_remote_addr zone=one:10m rate=1r/s;\n\n    ...\n\n    server {\n\n        ...\n\n        location /search/ {\n            limit_req zone=one burst=5;\n        }\n

\n

\n\n\n

Directives

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n limit_req \n zone=name\n [burst=number]\n [nodelay |\n delay=number];
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n http, server, location
\n

\nSets the shared memory zone\nand the maximum burst size of requests.\nIf the requests rate exceeds the rate configured for a zone,\ntheir processing is delayed such that requests are processed\nat a defined rate.\nExcessive requests are delayed until their number exceeds the\nmaximum burst size\nin which case the request is terminated with an\nerror.\nBy default, the maximum burst size is equal to zero.\nFor example, the directives\n

\nlimit_req_zone $binary_remote_addr zone=one:10m rate=1r/s;\n\nserver {\n    location /search/ {\n        limit_req zone=one burst=5;\n    }\n

\nallow not more than 1 request per second at an average,\nwith bursts not exceeding 5 requests.\n

\nIf delaying of excessive requests while requests are being limited is not\ndesired, the parameter nodelay should be used:\n

\nlimit_req zone=one burst=5 nodelay;\n

\n

\nThe delay parameter (1.15.7) specifies a limit\nat which excessive requests become delayed.\nDefault value is zero, i.e. all excessive requests are delayed.\n

\nThere could be several limit_req directives.\nFor example, the following configuration will limit the processing rate\nof requests coming from a single IP address and, at the same time,\nthe request processing rate by the virtual server:\n

\nlimit_req_zone $binary_remote_addr zone=perip:10m rate=1r/s;\nlimit_req_zone $server_name zone=perserver:10m rate=10r/s;\n\nserver {\n    ...\n    limit_req zone=perip burst=5 nodelay;\n    limit_req zone=perserver burst=10;\n}\n

\n\n

\nThese directives are inherited from the previous configuration level\nif and only if there are no limit_req directives\ndefined on the current level.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n limit_req_dry_run on | off;
\n
\n Default:\n \n
limit_req_dry_run off;
\n
\n Context:\n \n http, server, location
\n

This directive appeared in version 1.17.1.\n

\nEnables the dry run mode.\nIn this mode, requests processing rate is not limited, however,\nin the shared memory zone, the number of excessive requests is accounted\nas usual.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n limit_req_log_level \ninfo |\nnotice |\nwarn |\nerror;
\n
\n Default:\n \n
limit_req_log_level error;
\n
\n Context:\n \n http, server, location
\n

This directive appeared in version 0.8.18.\n

\nSets the desired logging level\nfor cases when the server refuses to process requests\ndue to rate exceeding,\nor delays request processing.\nLogging level for delays is one point less than for refusals; for example,\nif “limit_req_log_level notice” is specified,\ndelays are logged with the info level.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n limit_req_status code;
\n
\n Default:\n \n
limit_req_status 503;
\n
\n Context:\n \n http, server, location
\n

This directive appeared in version 1.3.15.\n

\nSets the status code to return in response to rejected requests.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n limit_req_zone \n key\n zone=name:size\n rate=rate\n [sync];
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n http
\n

\nSets parameters for a shared memory zone\nthat will keep states for various keys.\nIn particular, the state stores the current number of excessive requests.\nThe key can contain text, variables, and their combination.\nRequests with an empty key value are not accounted.\n

\nPrior to version 1.7.6, a key could contain exactly one variable.\n

\nUsage example:\n

\nlimit_req_zone $binary_remote_addr zone=one:10m rate=1r/s;\n

\n

\nHere, the states are kept in a 10 megabyte zone “one”, and an\naverage request processing rate for this zone cannot exceed\n1 request per second.\n

\nA client IP address serves as a key.\nNote that instead of $remote_addr, the\n$binary_remote_addr variable is used here.\nThe $binary_remote_addr variable’s size\nis always 4 bytes for IPv4 addresses or 16 bytes for IPv6 addresses.\nThe stored state always occupies\n64 bytes on 32-bit platforms and 128 bytes on 64-bit platforms.\nOne megabyte zone can keep about 16 thousand 64-byte states\nor about 8 thousand 128-byte states.\n

\nIf the zone storage is exhausted, the least recently used state is removed.\nIf even after that a new state cannot be created, the request is terminated with\nan error.\n

\nThe rate is specified in requests per second (r/s).\nIf a rate of less than one request per second is desired,\nit is specified in request per minute (r/m).\nFor example, half-request per second is 30r/m.\n

\nThe sync parameter (1.15.3) enables\nsynchronization\nof the shared memory zone.\n

\nThe sync parameter is available as part of our\ncommercial subscription.\n

\n

\n

\nAdditionally, as part of our\ncommercial subscription,\nthe\nstatus information\nfor each such shared memory zone can be\nobtained or\nreset\nwith the API since 1.17.7.\n

\n

\n\n\n

Embedded Variables

\n

\n\n
$limit_req_status
\n
\nkeeps the result of limiting the request processing rate (1.17.6):\nPASSED,\nDELAYED,\nREJECTED,\nDELAYED_DRY_RUN, or\nREJECTED_DRY_RUN\n
\n\n

\n

\n\n
\n", "encoding": "utf-8"} +{"path": "en\\docs\\http\\ngx_http_log_module.html", "extension": ".html", "size_bytes": 15252, "content": "\nModule ngx_http_log_module
\n\nPlanning your ingress-nginx migration? Start here:\nkubernetes.nginx.org.\n\n

Module ngx_http_log_module

Example Configuration
Directives
     access_log
     log_format
     open_log_file_cache
\n\n

\nThe ngx_http_log_module module writes request logs\nin the specified format.\n

\nRequests are logged in the context of a location where processing ends.\nIt may be different from the original location, if an\ninternal\nredirect happens during request processing.\n

\n\n\n

Example Configuration

\n

\nlog_format compression '$remote_addr - $remote_user [$time_local] '\n                       '\"$request\" $status $bytes_sent '\n                       '\"$http_referer\" \"$http_user_agent\" \"$gzip_ratio\"';\n\naccess_log /spool/logs/nginx-access.log compression buffer=32k;\n

\n

\n\n\n

Directives

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n access_log \n path\n [format\n [buffer=size]\n [gzip[=level]]\n [flush=time]\n [if=condition]];
access_log off;
\n
\n Default:\n \n
access_log logs/access.log combined;
\n
\n Context:\n \n http, server, location, if in location, limit_except
\n

\nSets the path, format, and configuration for a buffered log write.\nSeveral logs can be specified on the same configuration level.\nLogging to syslog\ncan be configured by specifying\nthe “syslog:” prefix in the first parameter.\nThe special value off cancels all\naccess_log directives on the current level.\nIf the format is not specified then the predefined\n“combined” format is used.\n

\nIf either the buffer or gzip\n(1.3.10, 1.2.7)\nparameter is used, writes to log will be buffered.\n

\nThe buffer size must not exceed the size of an atomic write to a disk file.\nFor FreeBSD this size is unlimited.\n

\n

\nWhen buffering is enabled, the data will be written to the file:\n

\n

\nIf the gzip parameter is used, then the buffered data will\nbe compressed before writing to the file.\nThe compression level can be set between 1 (fastest, less compression)\nand 9 (slowest, best compression).\nBy default, the buffer size is equal to 64K bytes, and the compression level\nis set to 1.\nSince the data is compressed in atomic blocks, the log file can be decompressed\nor read by “zcat” at any time.\n

\nExample:\n

\naccess_log /path/to/log.gz combined gzip flush=5m;\n

\n

\n

\nFor gzip compression to work, nginx must be built with the zlib library.\n

\n

\nThe file path can contain variables (0.7.6+),\nbut such logs have some constraints:\n

\n

\nThe if parameter (1.7.0) enables conditional logging.\nA request will not be logged if the condition evaluates to “0”\nor an empty string.\nIn the following example, the requests with response codes 2xx and 3xx\nwill not be logged:\n

\nmap $status $loggable {\n    ~^[23]  0;\n    default 1;\n}\n\naccess_log /path/to/access.log combined if=$loggable;\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n log_format \n name\n [escape=default|json|none]\n string ...;
\n
\n Default:\n \n
log_format combined \"...\";
\n
\n Context:\n \n http
\n

\nSpecifies log format.\n

\nThe escape parameter (1.11.8) allows setting\njson or default characters escaping\nin variables, by default, default escaping is used.\nThe none value (1.13.10) disables escaping.\n

\nFor default escaping,\ncharacters “\"”, “\\”,\nand other characters with values less than 32 (0.7.0) or above 126 (1.1.6)\nare escaped as “\\xXX”.\nIf the variable value is not found,\na hyphen (“-”) will be logged.\n

\nFor json escaping,\nall characters not allowed\nin JSON strings\nwill be escaped:\ncharacters “\"” and\n“\\” are escaped as\n“\\\"” and “\\\\”,\ncharacters with values less than 32 are escaped as\n“\\n”,\n“\\r”,\n“\\t”,\n“\\b”,\n“\\f”, or\n“\\u00XX”.\n\n

\nThe log format can contain common variables, and variables that\nexist only at the time of a log write:\n

\n\n
$bytes_sent
\n
\nthe number of bytes sent to a client\n
\n\n
$connection
\n
\nconnection serial number\n
\n\n
$connection_requests\n
\n
\nthe current number of requests made through a connection (1.1.18)\n
\n\n
$msec
\n
\ntime in seconds with a milliseconds resolution at the time of the log write\n
\n\n
$pipe
\n
\n“p” if request was pipelined, “.”\notherwise\n
\n\n
$request_length
\n
\nrequest length (including request line, header, and request body)\n
\n\n
$request_time
\n
\nrequest processing time in seconds with a milliseconds resolution;\ntime elapsed between the first bytes were read from the client and\nthe log write after the last bytes were sent to the client\n
\n\n
$status
\n
\nresponse status\n
\n\n
$time_iso8601
\n
\nlocal time in the ISO 8601 standard format\n
\n\n
$time_local
\n
\nlocal time in the Common Log Format\n
\n\n

\n\n

\nIn the modern nginx versions variables\n$status\n(1.3.2, 1.2.2),\n$bytes_sent\n(1.3.8, 1.2.5),\n$connection\n(1.3.8, 1.2.5),\n$connection_requests\n(1.3.8, 1.2.5),\n$msec\n(1.3.9, 1.2.6),\n$request_time\n(1.3.9, 1.2.6),\n$pipe\n(1.3.12, 1.2.7),\n$request_length\n(1.3.12, 1.2.7),\n$time_iso8601\n(1.3.12, 1.2.7),\nand\n$time_local\n(1.3.12, 1.2.7)\nare also available as common variables.\n

\n\n

\nHeader lines sent to a client have the prefix\n“sent_http_”, for example,\n$sent_http_content_range.\n

\nThe configuration always includes the predefined\n“combined” format:\n

\nlog_format combined '$remote_addr - $remote_user [$time_local] '\n                    '\"$request\" $status $body_bytes_sent '\n                    '\"$http_referer\" \"$http_user_agent\"';\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n open_log_file_cache \nmax=N\n[inactive=time]\n[min_uses=N]\n[valid=time];
open_log_file_cache off;
\n
\n Default:\n \n
open_log_file_cache off;
\n
\n Context:\n \n http, server, location
\n

\nDefines a cache that stores the file descriptors of frequently used logs\nwhose names contain variables.\nThe directive has the following parameters:\n

\n\n
max
\n
\nsets the maximum number of descriptors in a cache;\nif the cache becomes full the least recently used (LRU)\ndescriptors are closed\n
\n\n
inactive
\n
\nsets the time after which the cached descriptor is closed\nif there were no access during this time;\nby default, 10 seconds\n
\n\n
min_uses
\n
\nsets the minimum number of file uses during the time\ndefined by the inactive parameter\nto let the descriptor stay open in a cache;\nby default, 1\n
\n\n
valid
\n
\nsets the time after which it should be checked that the file\nstill exists with the same name; by default, 60 seconds\n
\n\n
off
\n
\ndisables caching\n
\n\n

\n

\nUsage example:\n

\nopen_log_file_cache max=1000 inactive=20s valid=1m min_uses=2;\n

\n

\n\n
\n", "encoding": "utf-8"} +{"path": "en\\docs\\http\\ngx_http_map_module.html", "extension": ".html", "size_bytes": 8969, "content": "\nModule ngx_http_map_module
\n\nPlanning your ingress-nginx migration? Start here:\nkubernetes.nginx.org.\n\n

Module ngx_http_map_module

Example Configuration
Directives
     map
     map_hash_bucket_size
     map_hash_max_size
\n\n

\nThe ngx_http_map_module module creates variables\nwhose values depend on values of other variables.\n

\n\n\n

Example Configuration

\n

\nmap $http_host $name {\n    hostnames;\n\n    default       0;\n\n    example.com   1;\n    *.example.com 1;\n    example.org   2;\n    *.example.org 2;\n    .example.net  3;\n    wap.*         4;\n}\n\nmap $http_user_agent $mobile {\n    default       0;\n    \"~Opera Mini\" 1;\n}\n

\n

\n\n\n

Directives

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n map \n string\n $variable { ... }
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n http
\n

\nCreates a new variable whose value\ndepends on values of one or more of the source variables\nspecified in the first parameter.\n

\nBefore version 0.9.0 only a single variable could be\nspecified in the first parameter.\n

\n

\n

\nSince variables are evaluated only when they are used, the mere declaration\neven of a large number of “map” variables\ndoes not add any extra costs to request processing.\n

\n

\nParameters inside the map block specify a mapping\nbetween source and resulting values.\n

\nSource values are specified as strings or regular expressions (0.9.6).\n

\nStrings are matched ignoring the case.\n

\nA regular expression should either start from the “~”\nsymbol for a case-sensitive matching, or from the “~*”\nsymbols (1.0.4) for case-insensitive matching.\nA regular expression can contain named and positional captures\nthat can later be used in other directives along with the\nresulting variable.\n

\nIf a source value matches one of the names of special parameters\ndescribed below, it should be prefixed with the “\\” symbol.\n

\nThe resulting value can contain text,\nvariable (0.9.0), and their combination (1.11.0).\n

\nThe following special parameters are also supported:\n

\n
default value
\n
\nsets the resulting value if the source value matches none\nof the specified variants.\nWhen default is not specified, the default\nresulting value will be an empty string.\n
\n\n
hostnames
\n
\nindicates that source values can be hostnames with a prefix or suffix mask:\n
\n*.example.com 1;\nexample.*     1;\n
\nThe following two records\n
\nexample.com   1;\n*.example.com 1;\n
\ncan be combined:\n
\n.example.com  1;\n
\nThis parameter should be specified before the list of values.\n
\n\n
include file
\n
\nincludes a file with values.\nThere can be several inclusions.\n
\n\n
volatile
\n
\nindicates that the variable is not cacheable (1.11.7).\n
\n\n

\n

\nThe search is performed in the following order of priority\nand terminates on the first matching variant:\n

    \n\n
  1. \nthe string value without a mask\n
  2. \n\n
  3. \nthe longest string value with a prefix mask,\ne.g. “*.example.com”\n
  4. \n\n
  5. \nthe longest string value with a suffix mask,\ne.g. “mail.*”\n
  6. \n\n
  7. \nthe first matching regular expression\n(in order of appearance in the configuration file)\n
  8. \n\n
  9. \nthe default value\n
  10. \n\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n map_hash_bucket_size size;
\n
\n Default:\n \n
map_hash_bucket_size 32|64|128;
\n
\n Context:\n \n http
\n

\nSets the bucket size for the map variables hash tables.\nDefault value depends on the processor’s cache line size.\nThe details of setting up hash tables are provided in a separate\ndocument.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n map_hash_max_size size;
\n
\n Default:\n \n
map_hash_max_size 2048;
\n
\n Context:\n \n http
\n

\nSets the maximum size of the map variables\nhash tables.\nThe details of setting up hash tables are provided in a separate\ndocument.\n

\n\n
\n", "encoding": "utf-8"} +{"path": "en\\docs\\http\\ngx_http_memcached_module.html", "extension": ".html", "size_bytes": 22813, "content": "\nModule ngx_http_memcached_module
\n\nPlanning your ingress-nginx migration? Start here:\nkubernetes.nginx.org.\n\n

Module ngx_http_memcached_module

Example Configuration
Directives
     memcached_allow_upstream
     memcached_bind
     memcached_bind_dynamic
     memcached_buffer_size
     memcached_connect_timeout
  ��  memcached_gzip_flag
     memcached_next_upstream
     memcached_next_upstream_timeout
     memcached_next_upstream_tries
     memcached_pass
     memcached_read_timeout
     memcached_send_timeout
     memcached_socket_keepalive
Embedded Variables
\n\n

\nThe ngx_http_memcached_module module is used to obtain\nresponses from a memcached server.\nThe key is set in the $memcached_key variable.\nA response should be put in memcached in advance by means\nexternal to nginx.\n

\n\n\n

Example Configuration

\n

\nserver {\n    location / {\n        set            $memcached_key \"$uri?$args\";\n        memcached_pass host:11211;\n        error_page     404 502 504 = @fallback;\n    }\n\n    location @fallback {\n        proxy_pass     http://backend;\n    }\n}\n

\n

\n\n\n

Directives

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n memcached_allow_upstream string ...;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n http, server, location
\n

This directive appeared in version 1.29.3.\n

\nDefines conditions under which access to a memcached server\nis allowed or denied.\nIf all string parameters are not empty\nand not equal to “0” then the access is allowed.\nThe conditions are evaluated each time\nbefore a connection to a memcached server is established.\nParameter values can contain variables:\n

\ngeo $upstream_last_addr $allow {\n    volatile;\n    10.10.0.0/24        1;\n}\n\nserver {\n    listen 127.0.0.1:8080;\n\n    location / {\n        memcached_pass           host:11211;\n        memcached_allow_upstream $allow;\n        ...\n    }\n}\n

\n

\n

\nThis directive is available as part of our\ncommercial subscription.\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n memcached_bind \n address\n [transparent ] |\n off;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n http, server, location
\n

This directive appeared in version 0.8.22.\n

\nMakes outgoing connections to a memcached server originate\nfrom the specified local IP address with an optional port (1.11.2).\nParameter value can contain variables (1.3.12).\nThe special value off (1.3.12) cancels the effect\nof the memcached_bind directive\ninherited from the previous configuration level, which allows the\nsystem to auto-assign the local IP address and port.\n

\nThe transparent parameter (1.11.0) allows\noutgoing connections to a memcached server originate\nfrom a non-local IP address,\nfor example, from a real IP address of a client:\n

\nmemcached_bind $remote_addr transparent;\n

\nIn order for this parameter to work,\nit is usually necessary to run nginx worker processes with the\nsuperuser privileges.\nOn Linux it is not required (1.13.8) as if\nthe transparent parameter is specified, worker processes\ninherit the CAP_NET_RAW capability from the master process.\nIt is also necessary to configure kernel routing table\nto intercept network traffic from the memcached server.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n memcached_bind_dynamic on | off;
\n
\n Default:\n \n
memcached_bind_dynamic off;
\n
\n Context:\n \n http, server, location
\n

This directive appeared in version 1.29.3.\n

\nWhen enabled, makes the bind operation\nat each connection attempt.\n

\n

\nThis directive is available as part of our\ncommercial subscription.\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n memcached_buffer_size size;
\n
\n Default:\n \n
memcached_buffer_size 4k|8k;
\n
\n Context:\n \n http, server, location
\n

\nSets the size of the buffer used for reading the response\nreceived from the memcached server.\nThe response is passed to the client synchronously, as soon as it is received.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n memcached_connect_timeout time;
\n
\n Default:\n \n
memcached_connect_timeout 60s;
\n
\n Context:\n \n http, server, location
\n

\nDefines a timeout for establishing a connection with a memcached server.\nIt should be noted that this timeout cannot usually exceed 75 seconds.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n memcached_gzip_flag flag;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n http, server, location
\n

This directive appeared in version 1.3.6.\n

\nEnables the test for the flag presence in the memcached\nserver response and sets the “Content-Encoding”\nresponse header field to “gzip”\nif the flag is set.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n memcached_next_upstream \n error |\n timeout |\n denied |\n invalid_response |\n not_found |\n off\n ...;
\n
\n Default:\n \n
memcached_next_upstream error timeout;
\n
\n Context:\n \n http, server, location
\n

\nSpecifies in which cases a request should be passed to the next server:\n

\n\n
error
\n
an error occurred while establishing a connection with the\nserver, passing a request to it, or reading the response header;
\n\n
timeout
\n
a timeout has occurred while establishing a connection with the\nserver, passing a request to it, or reading the response header;
\n\n
denied
\n
the server denied\nthe connection (1.29.3);\n

\n

\nThis parameter is available as part of our\ncommercial subscription.\n

\n

\n
\n\n
invalid_response
\n
a server returned an empty or invalid response;
\n\n
not_found
\n
a response was not found on the server;
\n\n
off
\n
disables passing a request to the next server.
\n\n

\n

\nOne should bear in mind that passing a request to the next server is\nonly possible if nothing has been sent to a client yet.\nThat is, if an error or timeout occurs in the middle of the\ntransferring of a response, fixing this is impossible.\n

\nThe directive also defines what is considered an\nunsuccessful\nattempt of communication with a server.\nThe cases of error, timeout,\ndenied and\ninvalid_response are always considered unsuccessful attempts,\neven if they are not specified in the directive.\nThe case of not_found\nis never considered an unsuccessful attempt.\n

\nPassing a request to the next server can be limited by\nthe number of tries\nand by time.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n memcached_next_upstream_timeout time;
\n
\n Default:\n \n
memcached_next_upstream_timeout 0;
\n
\n Context:\n \n http, server, location
\n

This directive appeared in version 1.7.5.\n

\nLimits the time during which a request can be passed to the\nnext server.\nThe 0 value turns off this limitation.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n memcached_next_upstream_tries number;
\n
\n Default:\n \n
memcached_next_upstream_tries 0;
\n
\n Context:\n \n http, server, location
\n

This directive appeared in version 1.7.5.\n

\nLimits the number of possible tries for passing a request to the\nnext server.\nThe 0 value turns off this limitation.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n memcached_pass address;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n location, if in location
\n

\nSets the memcached server address.\nThe address can be specified as a domain name or IP address,\nand a port:\n

\nmemcached_pass localhost:11211;\n

\nor as a UNIX-domain socket path:\n

\nmemcached_pass unix:/tmp/memcached.socket;\n

\n

\nIf a domain name resolves to several addresses, all of them will be\nused in a round-robin fashion.\nIn addition, an address can be specified as a\nserver group.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n memcached_read_timeout time;
\n
\n Default:\n \n
memcached_read_timeout 60s;
\n
\n Context:\n \n http, server, location
\n

\nDefines a timeout for reading a response from the memcached server.\nThe timeout is set only between two successive read operations,\nnot for the transmission of the whole response.\nIf the memcached server does not transmit anything within this time,\nthe connection is closed.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n memcached_send_timeout time;
\n
\n Default:\n \n
memcached_send_timeout 60s;
\n
\n Context:\n \n http, server, location
\n

\nSets a timeout for transmitting a request to the memcached server.\nThe timeout is set only between two successive write operations,\nnot for the transmission of the whole request.\nIf the memcached server does not receive anything within this time,\nthe connection is closed.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n memcached_socket_keepalive on | off;
\n
\n Default:\n \n
memcached_socket_keepalive off;
\n
\n Context:\n \n http, server, location
\n

This directive appeared in version 1.15.6.\n

\nConfigures the “TCP keepalive” behavior\nfor outgoing connections to a memcached server.\nBy default, the operating system’s settings are in effect for the socket.\nIf the directive is set to the value “on”, the\nSO_KEEPALIVE socket option is turned on for the socket.\n

\n\n\n

Embedded Variables

\n

\n\n
$memcached_key
\n
\nDefines a key for obtaining response from a memcached server.\n
\n\n

\n

\n\n
\n", "encoding": "utf-8"} +{"path": "en\\docs\\http\\ngx_http_mirror_module.html", "extension": ".html", "size_bytes": 5880, "content": "\nModule ngx_http_mirror_module
\n\nPlanning your ingress-nginx migration? Start here:\nkubernetes.nginx.org.\n\n

Module ngx_http_mirror_module

Example Configuration
Directives
     mirror
     mirror_request_body
\n\n

\nThe ngx_http_mirror_module module (1.13.4) implements\nmirroring of an original request\nby creating background mirror subrequests.\nResponses to mirror subrequests are ignored.\n

\n\n\n

Example Configuration

\n

\nlocation / {\n    mirror /mirror;\n    proxy_pass http://backend;\n}\n\nlocation = /mirror {\n    internal;\n    proxy_pass http://test_backend$request_uri;\n}\n

\n

\n\n\n

Directives

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n mirror uri | off;
\n
\n Default:\n \n
mirror off;
\n
\n Context:\n \n http, server, location
\n

\nSets the URI to which an original request will be mirrored.\nSeveral mirrors can be specified on the same configuration level.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n mirror_request_body on | off;
\n
\n Default:\n \n
mirror_request_body on;
\n
\n Context:\n \n http, server, location
\n

\nIndicates whether the client request body is mirrored.\nWhen enabled, the client request body will be read\nprior to creating mirror subrequests.\nIn this case, unbuffered client request body proxying\nset by the\nproxy_request_buffering,\nfastcgi_request_buffering,\nscgi_request_buffering,\nand\nuwsgi_request_buffering\ndirectives will be disabled.\n

\nlocation / {\n    mirror /mirror;\n    mirror_request_body off;\n    proxy_pass http://backend;\n}\n\nlocation = /mirror {\n    internal;\n    proxy_pass http://log_backend;\n    proxy_pass_request_body off;\n    proxy_set_header Content-Length \"\";\n    proxy_set_header X-Original-URI $request_uri;\n}\n

\n

\n\n
\n", "encoding": "utf-8"} +{"path": "en\\docs\\http\\ngx_http_mp4_module.html", "extension": ".html", "size_bytes": 13603, "content": "\nModule ngx_http_mp4_module
\n\nPlanning your ingress-nginx migration? Start here:\nkubernetes.nginx.org.\n\n

Module ngx_http_mp4_module

Example Configuration
Directives
     mp4
     mp4_buffer_size
     mp4_max_buffer_size
     mp4_limit_rate
     mp4_limit_rate_after
     mp4_start_key_frame
\n\n

\nThe ngx_http_mp4_module module provides pseudo-streaming\nserver-side support for MP4 files.\nSuch files typically have the .mp4, .m4v,\nor .m4a filename extensions.\n

\nPseudo-streaming works in alliance with a compatible media player.\nThe player sends an HTTP request to the server with the start time\nspecified in the query string argument (named simply\nstart\nand specified in seconds), and the server responds with the stream\nsuch that its start position corresponds to the requested time,\nfor example:\n

\nhttp://example.com/elephants_dream.mp4?start=238.88\n

\nThis allows performing a random seeking at any time, or starting playback\nin the middle of the timeline.\n

\nTo support seeking, H.264-based formats store metadata\nin a so-called “moov atom”.\nIt is a part of the file that holds the index information for the\nwhole file.\n

\nTo start playback, the player first needs to read metadata.\nThis is done by sending a special request with the\nstart=0 argument.\nA lot of encoding software insert the metadata at\nthe end of the file.\nThis is suboptimal for pseudo-streaming, because the player\nhas to download the entire file before starting playback.\nIf the metadata are located at the beginning of the file,\nit is enough for nginx to simply start sending back the file contents.\nIf the metadata are located at the end of the file,\nnginx must read the entire file and prepare a new stream so that\nthe metadata come before the media data.\nThis involves some CPU, memory, and disk I/O overhead,\nso it is a good idea to\n\nprepare an original file for pseudo-streaming in advance,\nrather than having nginx do this on every such request.\n

\nThe module also supports the end argument of an HTTP request\n(1.5.13) which sets the end point of playback.\nThe end argument can be specified with the\nstart argument\nor separately:\n

\nhttp://example.com/elephants_dream.mp4?start=238.88&end=555.55\n

\n

\nFor a matching request with a non-zero\nstart or end\nargument, nginx will read the metadata from the file, prepare the\nstream with the requested time range, and send it to the client.\nThis has the same overhead as described above.\n

\nIf the start argument points to\na non-key video frame,\nthe beginning of such video will be broken.\nTo fix this issue, the video\ncan be prepended with\nthe key frame before start point\nand with all intermediate frames between them.\nThese frames will be hidden from playback\nusing an edit list (1.21.4).\n

\nIf a matching request does not include the\nstart and end\narguments, there is no overhead, and the file is sent simply as a static\nresource.\nSome players also support byte-range requests, and thus do not require\nthis module.\n

\nThis module is not built by default, it should be enabled with the\n--with-http_mp4_module\nconfiguration parameter.\n

\nIf a third-party mp4 module was previously used, it should be disabled.\n

\n

\nA similar pseudo-streaming support for FLV files is provided by the\nngx_http_flv_module module.\n

\n\n\n

Example Configuration

\n

\nlocation /video/ {\n    mp4;\n    mp4_buffer_size       1m;\n    mp4_max_buffer_size   5m;\n    mp4_limit_rate        on;\n    mp4_limit_rate_after  30s;\n}\n

\n

\n\n\n

Directives

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n mp4;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n location
\n

\nTurns on module processing in a surrounding location.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n mp4_buffer_size size;
\n
\n Default:\n \n
mp4_buffer_size 512K;
\n
\n Context:\n \n http, server, location
\n

\nSets the initial size of the buffer used for\nprocessing MP4 files.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n mp4_max_buffer_size size;
\n
\n Default:\n \n
mp4_max_buffer_size 10M;
\n
\n Context:\n \n http, server, location
\n

\nDuring metadata processing, a larger buffer may become necessary.\nIts size cannot exceed the specified size,\nor else nginx will return the\n500 (Internal Server Error) server error,\nand log the following message:\n

\n\"/some/movie/file.mp4\" mp4 moov atom is too large:\n12583268, you may want to increase mp4_max_buffer_size\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n mp4_limit_rate \n on |\n off |\n factor;
\n
\n Default:\n \n
mp4_limit_rate off;
\n
\n Context:\n \n http, server, location
\n

\nLimits the rate of response transmission to a client.\nThe rate is limited based on the average bitrate of the\nMP4 file served.\nTo calculate the rate, the bitrate is multiplied by the specified\nfactor.\nThe special value “on” corresponds to the factor of 1.1.\nThe special value “off” disables rate limiting.\nThe limit is set per a request, and so if a client simultaneously opens\ntwo connections, the overall rate will be twice as much\nas the specified limit.\n

\n

\nThis directive is available as part of our\ncommercial subscription.\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n mp4_limit_rate_after time;
\n
\n Default:\n \n
mp4_limit_rate_after 60s;
\n
\n Context:\n \n http, server, location
\n

\nSets the initial amount of media data (measured in playback time)\nafter which the further transmission of the response to a client\nwill be rate limited.\n

\n

\nThis directive is available as part of our\ncommercial subscription.\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n mp4_start_key_frame on | off;
\n
\n Default:\n \n
mp4_start_key_frame off;
\n
\n Context:\n \n http, server, location
\n

This directive appeared in version 1.21.4.\n

\nForces output video to always start with a key video frame.\nIf the start argument does not point to a key frame,\ninitial frames are hidden using an mp4 edit list.\nEdit lists are supported by major players and browsers such as\nChrome, Safari, QuickTime and ffmpeg,\npartially supported by Firefox.\n

\n\n
\n", "encoding": "utf-8"} +{"path": "en\\docs\\http\\ngx_http_num_map_module.html", "extension": ".html", "size_bytes": 4994, "content": "\nModule ngx_http_num_map_module
\n\nPlanning your ingress-nginx migration? Start here:\nkubernetes.nginx.org.\n\n

Module ngx_http_num_map_module

Example Configuration
Directives
     num_map
\n\n

\nThe ngx_http_num_map_module module (1.29.3)\ncreates variables whose values depend on numeric values\nor numeric value ranges.\n

\n

\nThis module is available as part of our\ncommercial subscription.\n

\n

\n\n\n

Example Configuration

\n

\nnum_map $remote_port $port_allow {\n    default    0;\n\n    80         1;\n    443        1;\n    <=1023     0;\n    8080-8090  1;\n}\n

\n

\n\n\n

Directives

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n num_map \n [$number]\n $variable { ... }
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n http
\n

\nDescribes how the values of the specified variable depend on numeric values\nor numeric value ranges.\n

\n

\nSince variables are evaluated only when used, the mere existence\nof even a large number of declared “num_map” variables\ndoes not cause any extra costs for request processing.\n

\n

\nParameters inside the num_map block specify a mapping\nbetween source and resulting values.\n

\nSource values are specified as numbers or as numeric ranges.\n

\nThe following special parameters are also supported:\n

\n\n
default
\n
\nsets the resulting value if the source value matches none\nof the specified variants.\nWhen default is not specified, the default\nresulting value will be an empty string.\n
\n\n
include
\n
\nincludes a file with values.\nThere can be several inclusions.\n
\n\n
volatile
\n
\nindicates that the variable is not cacheable.\n
\n\n

\n

\n\n
\n", "encoding": "utf-8"} +{"path": "en\\docs\\http\\ngx_http_oidc_module.html", "extension": ".html", "size_bytes": 27449, "content": "\nModule ngx_http_oidc_module
\n\nPlanning your ingress-nginx migration? Start here:\nkubernetes.nginx.org.\n\n

Module ngx_http_oidc_module

Example Configuration
Directives
     oidc_provider
     auth_oidc
     issuer
     client_id
     client_secret
     config_url
     cookie_name
     extra_auth_args
     frontchannel_logout_uri
     pkce
     redirect_uri
     logout_uri
     post_logout_uri
     logout_token_hint
     scope
     session_store
     session_timeout
     ssl_crl
     ssl_trusted_certificate
     userinfo
Embedded Variables
\n\n

\nThe ngx_http_oidc_module module (1.27.4)\nimplements authentication as a Relying Party in OpenID Connect using the\n\nAuthorization Code Flow.\n

\nThe module expects the OpenID Provider's configuration to be available via\n\nmetadata and requires dynamic\nresolver.\n

\nThe module can be combined with other access modules\nvia the satisfy directive.\nNote that the module may still block requests even with\nsatisfy any;\nas an OpenID Provider might not redirect the user back to nginx.\n

\n

\nThis module is available as part of our\ncommercial subscription.\n

\n

\n\n\n

Example Configuration

\n

\nhttp {\n    resolver 10.0.0.1;\n\n    oidc_provider my_idp {\n        issuer        \"https://provider.domain\";\n        client_id     \"unique_id\";\n        client_secret \"unique_secret\";\n    }\n\n    server {\n        location / {\n            auth_oidc my_idp;\n\n            proxy_set_header username $oidc_claim_sub;\n            proxy_pass       http://backend;\n        }\n    }\n}\n

\nThe example assumes that the\n“https://<nginx-host>/oidc_callback”\nRedirection URI is configured on the OpenID Provider's side.\nThe path can be customized with the redirect_uri directive.\n

\n\n\n

Directives

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n oidc_provider name { ... }
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n http
\n

\nDefines an OpenID Provider for use with the auth_oidc directive.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n auth_oidc name | off;
\n
\n Default:\n \n
auth_oidc off;
\n
\n Context:\n \n http, server, location
\n

\nEnables end user authentication with the\nspecified OpenID Provider.\n

\nParameter value can contain variables (1.29.0).\n

\nThe special value off cancels the effect\nof the auth_oidc directive\ninherited from the previous configuration level.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n issuer URL;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n oidc_provider
\n

\nSets the Issuer Identifier URL of the OpenID Provider;\nrequired directive.\nThe URL must exactly match the value of “issuer”\nin the OpenID Provider metadata\nand requires the “https” scheme.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n client_id string;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n oidc_provider
\n

\nSpecifies the client ID of the Relying Party;\nrequired directive.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n client_secret string;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n oidc_provider
\n

\nSpecifies a secret value\nused to authenticate the Relying Party with the OpenID Provider.\nThe supported\nauthentication\nmethods are\nclient_secret_basic and\nclient_secret_post (1.29.3).\nThe method is selected based on the OpenID Provider metadata\nwith a preference to client_secret_basic.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n config_url URL;
\n
\n Default:\n \n
config_url <issuer>/.well-known/openid-configuration;
\n
\n Context:\n \n oidc_provider
\n

\nSets a custom URL to retrieve the OpenID Provider metadata.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n cookie_name name;
\n
\n Default:\n \n
cookie_name NGX_OIDC_SESSION;
\n
\n Context:\n \n oidc_provider
\n

\nSets the name of a session cookie.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n extra_auth_args string;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n oidc_provider
\n

\nSets additional query arguments for the\nauthentication\nrequest URL.\n

\nextra_auth_args \"display=page&prompt=login\";\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n frontchannel_logout_uri uri;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n oidc_provider
\n

This directive appeared in version 1.29.3.\n

\nDefines the URI path for triggering\nfront-channel\nlogout.\nFor the logout request to be associated with a user session,\nit must either include the module session cookie or provide\nboth the “iss” and “sid” arguments.\nIt is recommended to configure the OpenID Provider to set the\n“iss” and “sid” arguments\nwhen invoking this endpoint.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n pkce on | off;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n oidc_provider
\n

This directive appeared in version 1.29.3.\n

\nExplicitly enables or disables PKCE.\nBy default, PKCE is automatically enabled\nbased on OpenID Provider metadata.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n redirect_uri uri;
\n
\n Default:\n \n
redirect_uri /oidc_callback;
\n
\n Context:\n \n oidc_provider
\n

\nDefines the Redirection URI path for post-authentication redirects\nexpected by the module from the OpenID Provider.\nThe uri must match the configuration on the Provider's side.\n

\nAbsolute “https” URIs are supported since 1.29.0.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n logout_uri uri;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n oidc_provider
\n

This directive appeared in version 1.29.0.\n

\nDefines the URI path for initiating session logout.\nUpon session termination, the user is redirected to\nProvider's\nLogout Endpoint\nor to the post logout page.\nIf neither is configured, the built-in post logout page is displayed.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n post_logout_uri uri;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n oidc_provider
\n

This directive appeared in version 1.29.0.\n

\nDefines the path or absolute URI\nto redirect the user to after the logout.\nThe uri must match the configuration on the Provider's side.\nIf the post logout page is served by NGINX,\nthe OIDC module shouldn't be enabled for this location:\n

\nhttp {\n    oidc_provider my_idp {\n        ...\n\n        logout_uri      /logout;\n        post_logout_uri /logged_out_page.html;\n    }\n\n    server {\n        auth_oidc my_idp;\n\n        location /logged_out_page.html {\n            auth_oidc off;\n        }\n    }\n}\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n logout_token_hint on | off;
\n
\n Default:\n \n
logout_token_hint off;
\n
\n Context:\n \n oidc_provider
\n

This directive appeared in version 1.29.0.\n

\nAdds the\nid_token_hint\nargument to the\nProvider's\nLogout Endpoint\nwhen redirecting user during logout.\nThis argument can be required by some OpenID Providers.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n scope scope ...;
\n
\n Default:\n \n
scope openid;
\n
\n Context:\n \n oidc_provider
\n

\nSets requested scopes.\nThe openid scope is always required by OIDC.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n session_store name;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n oidc_provider
\n

\nSpecifies a custom\nkey-value database\nthat stores session data.\nBy default, an 8-megabyte key-value database named \noidc_default_store_<provider name>\nis created automatically.\n

\nA separate key-value database should be configured for each Provider\nto prevent session reuse across providers.\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n session_timeout time;
\n
\n Default:\n \n
session_timeout 8h;
\n
\n Context:\n \n oidc_provider
\n

\nSets a timeout after which the session is deleted, unless it was\nrefreshed.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n ssl_crl file;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n oidc_provider
\n

\nSpecifies a file with revoked certificates (CRL)\nin the PEM format used to verify\nthe certificates of the OpenID Provider endpoints.\nWhen using intermediate certificates, their CRLs should be\nspecified in the same file.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n ssl_trusted_certificate file;
\n
\n Default:\n \n
ssl_trusted_certificate system CA bundle;
\n
\n Context:\n \n oidc_provider
\n

\nSpecifies a file with trusted CA certificates in the PEM format\nused to verify\nthe certificates of the OpenID Provider endpoints.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n userinfo on | off;
\n
\n Default:\n \n
userinfo off;
\n
\n Context:\n \n oidc_provider
\n

This directive appeared in version 1.29.0.\n

\nEnables downloading of the\nUserInfo\ndata and makes UserInfo claims available via the \n$oidc_claim_name variables.\n

\n\n\n

Embedded Variables

\nThe ngx_http_oidc_module module supports embedded variables:\n

\n

\n\n
$oidc_id_token
\n
\nID token\n
\n\n
$oidc_access_token
\n
\naccess token\n
\n\n
$oidc_claim_name
\n
\ntop-level ID token or UserInfo claim\n

\nNested claims can be fetched with the\nauth_jwt module:\n

\nhttp {\n    auth_jwt_claim_set $postal_code address postal_code;\n\n    server {\n        location / {\n            auth_oidc my_idp;\n            auth_jwt  off token=$oidc_id_token;\n\n            proxy_set_header x-postal_code $postal_code;\n            proxy_pass       http://backend;\n        }\n    }\n}\n

\n

\n\n
\n\n
$oidc_userinfo
\n
\nUserInfo data in the JSON format (1.29.0)\n
\n\n

\n

\n\n
\n", "encoding": "utf-8"} +{"path": "en\\docs\\http\\ngx_http_perl_module.html", "extension": ".html", "size_bytes": 15691, "content": "\nModule ngx_http_perl_module
\n\nPlanning your ingress-nginx migration? Start here:\nkubernetes.nginx.org.\n\n

Module ngx_http_perl_module

Known Issues
Example Configuration
Directives
     perl
     perl_modules
     perl_require
     perl_set
Calling Perl from SSI
The $r Request Object Methods
\n\n

\nThe ngx_http_perl_module module is used to implement\nlocation and variable handlers in Perl and insert Perl calls into SSI.\n

\nThis module is not built by default, it should be enabled with the\n--with-http_perl_module\nconfiguration parameter.\n

\nThis module requires\nPerl version 5.6.1 or higher.\nThe C compiler should be compatible with the one used to build Perl.\n

\n

\n\n\n

Known Issues

\nThe module is experimental, caveat emptor applies.\n

\nIn order for Perl to recompile the modified modules during\nreconfiguration, it should be built with the\n-Dusemultiplicity=yes or\n-Dusethreads=yes parameters.\nAlso, to make Perl leak less memory at run time,\nit should be built with the\n-Dusemymalloc=no parameter.\nTo check the values of these parameters in an already built\nPerl (preferred values are specified in the example), run:\n

\n$ perl -V:usemultiplicity -V:usemymalloc\nusemultiplicity='define';\nusemymalloc='n';\n

\n

\nNote that after rebuilding Perl with the new\n-Dusemultiplicity=yes or\n-Dusethreads=yes parameters,\nall binary Perl modules will have to be rebuilt as well —\nthey will just stop working with the new Perl.\n

\nThere is a possibility that the main process and then worker processes will\ngrow in size after every reconfiguration.\nIf the main process grows to an unacceptable size, the\nlive upgrade\nprocedure can be applied without changing the executable file.\n

\nWhile the Perl module is performing a long-running operation, such as\nresolving a domain name, connecting to another server, or querying a database,\nother requests assigned to the current worker process will not be processed.\nIt is thus recommended to perform only such operations\nthat have predictable and short execution time, such as\naccessing the local file system.\n

\n\n\n

Example Configuration

\n

\nhttp {\n\n    perl_modules perl/lib;\n    perl_require hello.pm;\n\n    perl_set $msie6 '\n\n        sub {\n            my $r = shift;\n            my $ua = $r->header_in(\"User-Agent\");\n\n            return \"\" if $ua =~ /Opera/;\n            return \"1\" if $ua =~ / MSIE [6-9]\\.\\d+/;\n            return \"\";\n        }\n\n    ';\n\n    server {\n        location / {\n            perl hello::handler;\n        }\n    }\n

\n

\nThe perl/lib/hello.pm module:\n

\npackage hello;\n\nuse nginx;\n\nsub handler {\n    my $r = shift;\n\n    $r->send_http_header(\"text/html\");\n    return OK if $r->header_only;\n\n    $r->print(\"hello!\\n<br/>\");\n\n    if (-f $r->filename or -d _) {\n        $r->print($r->uri, \" exists!\\n\");\n    }\n\n    return OK;\n}\n\n1;\n__END__\n

\n

\n\n\n

Directives

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n perl module::function|'sub { ... }';
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n location, limit_except
\n

\nSets a Perl handler for the given location.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n perl_modules path;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n http
\n

\nSets an additional path for Perl modules.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n perl_require module;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n http
\n

\nDefines the name of a module that will be loaded during each\nreconfiguration.\nSeveral perl_require directives can be present.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n perl_set \n $variable\n module::function|'sub { ... }';
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n http
\n

\nInstalls a Perl handler for the specified variable.\n

\n\n\n

Calling Perl from SSI

\nAn SSI command calling Perl has the following format:\n

\n<!--# perl sub=\"module::function\" arg=\"parameter1\" arg=\"parameter2\" ...\n-->\n

\n

\n\n\n

The $r Request Object Methods

\n

\n\n
$r->args
\n
\nreturns request arguments.\n
\n\n
$r->filename
\n
\nreturns a filename corresponding to the request URI.\n
\n\n
\n $r->has_request_body(handler)\n
\n
\nreturns 0 if there is no body in a request.\nIf there is a body, the specified handler is set for the request\nand 1 is returned.\nAfter reading the request body, nginx will call the specified handler.\nNote that the handler function should be passed by reference.\nExample:\n
\npackage hello;\n\nuse nginx;\n\nsub handler {\n    my $r = shift;\n\n    if ($r->request_method ne \"POST\") {\n        return DECLINED;\n    }\n\n    if ($r->has_request_body(\\&post)) {\n        return OK;\n    }\n\n    return HTTP_BAD_REQUEST;\n}\n\nsub post {\n    my $r = shift;\n\n    $r->send_http_header;\n\n    $r->print(\"request_body: \\\"\", $r->request_body, \"\\\"<br/>\");\n    $r->print(\"request_body_file: \\\"\", $r->request_body_file, \"\\\"<br/>\\n\");\n\n    return OK;\n}\n\n1;\n\n__END__\n
\n
\n\n
$r->allow_ranges
\n
\nenables the use of byte ranges when sending responses.\n
\n\n
$r->discard_request_body
\n
\ninstructs nginx to discard the request body.\n
\n\n
$r->header_in(field)
\n
\nreturns the value of the specified client request header field.\n
\n\n
$r->header_only
\n
\ndetermines whether the whole response or only its header should be sent to\nthe client.\n
\n\n
\n $r->header_out(field,\n value)\n
\n
\nsets a value for the specified response header field.\n
\n\n
\n $r->internal_redirect(uri)\n
\n
\ndoes an internal redirect to the specified uri.\nAn actual redirect happens after the Perl handler execution is completed.\n
\nSince version 1.17.2, the method accepts escaped URIs and\nsupports redirections to named locations.\n
\n
\n\n
$r->log_error(errno,\nmessage)
\n
\nwrites the specified message into the\nerror_log.\nIf errno is non-zero, an error code and its description\nwill be appended to the message.\n
\n\n
$r->print(text, ...)
\n
\npasses data to a client.\n
\n\n
$r->request_body
\n
\nreturns the client request body if it has not been\nwritten to a temporary file.\nTo ensure that the client request body is in memory,\nits size should be limited by\nclient_max_body_size,\nand a sufficient buffer size should be set using\nclient_body_buffer_size.\n
\n\n
$r->request_body_file
\n
\nreturns the name of the file with the client request body.\nAfter the processing, the file should be removed.\nTo always write a request body to a file,\nclient_body_in_file_only\nshould be enabled.\n
\n\n
$r->request_method
\n
\nreturns the client request HTTP method.\n
\n\n
$r->remote_addr
\n
\nreturns the client IP address.\n
\n\n
$r->flush
\n
\nimmediately sends data to the client.\n
\n\n
\n $r->sendfile(name[,\n offset[,\n length]])\n
\n
\nsends the specified file content to the client.\nOptional parameters\nspecify the initial offset and length of the data to be transmitted.\nThe actual data transmission happens after the Perl handler\nhas completed.\n
\n\n
\n $r->send_http_header([type])\n
\n
\nsends the response header to the client.\nThe optional type parameter sets the value of\nthe “Content-Type” response header field.\nIf the value is an empty string, the “Content-Type”\nheader field will not be sent.\n
\n\n
$r->status(code)
\n
\nsets a response code.\n
\n\n
\n $r->sleep(milliseconds,\n handler)\n
\n
\nsets the specified handler\nand stops request processing for the specified time.\nIn the meantime, nginx continues to process other requests.\nAfter the specified time has elapsed, nginx will call the installed handler.\nNote that the handler function should be passed by reference.\nIn order to pass data between handlers,\n$r->variable() should be used.\nExample:\n
\npackage hello;\n\nuse nginx;\n\nsub handler {\n    my $r = shift;\n\n    $r->discard_request_body;\n    $r->variable(\"var\", \"OK\");\n    $r->sleep(1000, \\&next);\n\n    return OK;\n}\n\nsub next {\n    my $r = shift;\n\n    $r->send_http_header;\n    $r->print($r->variable(\"var\"));\n\n    return OK;\n}\n\n1;\n\n__END__\n
\n
\n\n
$r->unescape(text)
\n
\ndecodes a text encoded in the “%XX” form.\n
\n\n
$r->uri
\n
\nreturns a request URI.\n
\n\n
\n $r->variable(name[,\n value])\n
\n
\nreturns or sets the value of the specified variable.\nVariables are local to each request.\n
\n\n

\n

\n\n
\n", "encoding": "utf-8"} +{"path": "en\\docs\\http\\ngx_http_proxy_module.html", "extension": ".html", "size_bytes": 133087, "content": "\nModule ngx_http_proxy_module
\n\nPlanning your ingress-nginx migration? Start here:\nkubernetes.nginx.org.\n\n

Module ngx_http_proxy_module

Example Configuration
Directives
     proxy_allow_upstream
     proxy_bind
     proxy_bind_dynamic
     proxy_buffer_size
     proxy_buffering
     proxy_buffers
     proxy_busy_buffers_size
     proxy_cache
     proxy_cache_background_update
     proxy_cache_bypass
     proxy_cache_convert_head
     proxy_cache_key
     proxy_cache_lock
     proxy_cache_lock_age
     proxy_cache_lock_timeout
     proxy_cache_max_range_offset
     proxy_cache_methods
     proxy_cache_min_uses
     proxy_cache_path
     proxy_cache_purge
     proxy_cache_revalidate
     proxy_cache_use_stale
     proxy_cache_valid
     proxy_connect_timeout
     proxy_cookie_domain
     proxy_cookie_flags
     proxy_cookie_path
     proxy_force_ranges
     proxy_headers_hash_bucket_size
     proxy_headers_hash_max_size
     proxy_hide_header
     proxy_http_version
     proxy_ignore_client_abort
     proxy_ignore_headers
     proxy_intercept_errors
     proxy_limit_rate
     proxy_max_temp_file_size
     proxy_method
     proxy_next_upstream
     proxy_next_upstream_timeout
     proxy_next_upstream_tries
     proxy_no_cache
     proxy_pass
     proxy_pass_header
     proxy_pass_request_body
     proxy_pass_request_headers
     proxy_pass_trailers
     proxy_read_timeout
     proxy_redirect
     proxy_request_buffering
     proxy_request_dynamic
     proxy_send_lowat
     proxy_send_timeout
     proxy_set_body
     proxy_set_header
     proxy_socket_keepalive
     proxy_ssl_certificate
     proxy_ssl_certificate_cache
     proxy_ssl_certificate_key
     proxy_ssl_ciphers
     proxy_ssl_conf_command
     proxy_ssl_crl
     proxy_ssl_key_log
     proxy_ssl_name
     proxy_ssl_password_file
     proxy_ssl_protocols
     proxy_ssl_server_name
     proxy_ssl_session_reuse
     proxy_ssl_trusted_certificate
     proxy_ssl_verify
     proxy_ssl_verify_depth
     proxy_store
     proxy_store_access
     proxy_temp_file_write_size
     proxy_temp_path
Embedded Variables
\n\n

\nThe ngx_http_proxy_module module allows passing\nrequests to another server.\n

\n\n\n

Example Configuration

\n

\nlocation / {\n    proxy_pass       http://localhost:8000;\n    proxy_set_header Host      $host;\n    proxy_set_header X-Real-IP $remote_addr;\n}\n

\n

\n\n\n

Directives

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n proxy_allow_upstream string ...;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n http, server, location
\n

This directive appeared in version 1.29.3.\n

\nDefines conditions under which access to a proxied server\nis allowed or denied.\nIf all string parameters are not empty\nand not equal to “0” then the access is allowed.\nThe conditions are evaluated each time\nbefore a connection to a proxied server is established.\nParameter values can contain variables:\n

\ngeo $upstream_last_addr $allow {\n    volatile;\n    10.10.0.0/24        1;\n}\n\nserver {\n    listen 127.0.0.1:8080;\n\n    location / {\n        proxy_pass           localhost:8000;\n        proxy_allow_upstream $allow;\n        ...\n    }\n}\n

\n

\n

\nThis directive is available as part of our\ncommercial subscription.\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n proxy_bind \n address\n [transparent] |\n off;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n http, server, location
\n

This directive appeared in version 0.8.22.\n

\nMakes outgoing connections to a proxied server originate\nfrom the specified local IP address with an optional port (1.11.2).\nParameter value can contain variables (1.3.12).\nThe special value off (1.3.12) cancels the effect\nof the proxy_bind directive\ninherited from the previous configuration level, which allows the\nsystem to auto-assign the local IP address and port.\n

\nThe transparent parameter (1.11.0) allows\noutgoing connections to a proxied server originate\nfrom a non-local IP address,\nfor example, from a real IP address of a client:\n

\nproxy_bind $remote_addr transparent;\n

\nIn order for this parameter to work,\nit is usually necessary to run nginx worker processes with the\nsuperuser privileges.\nOn Linux it is not required (1.13.8) as if\nthe transparent parameter is specified, worker processes\ninherit the CAP_NET_RAW capability from the master process.\nIt is also necessary to configure kernel routing table\nto intercept network traffic from the proxied server.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n proxy_bind_dynamic on | off;
\n
\n Default:\n \n
proxy_bind_dynamic off;
\n
\n Context:\n \n http, server, location
\n

This directive appeared in version 1.29.3.\n

\nWhen enabled, makes the bind operation\nat each connection attempt.\n

\n

\nThis directive is available as part of our\ncommercial subscription.\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n proxy_buffer_size size;
\n
\n Default:\n \n
proxy_buffer_size 4k|8k;
\n
\n Context:\n \n http, server, location
\n

\nSets the size of the buffer used for reading the first part\nof the response received from the proxied server.\nThis part usually contains a small response header;\nif it exceeds the buffer size, the response is considered\ninvalid.\nBy default, the buffer size is equal to one memory page.\nThis is either 4K or 8K, depending on a platform.\nIt can be made smaller, however.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n proxy_buffering on | off;
\n
\n Default:\n \n
proxy_buffering on;
\n
\n Context:\n \n http, server, location
\n

\nEnables or disables buffering of responses from the proxied server.\n

\nWhen buffering is enabled, nginx receives a response from the proxied server\nas soon as possible, saving it into the buffers set by the\nproxy_buffer_size and proxy_buffers directives.\nIf the whole response does not fit into memory, a part of it can be saved\nto a temporary file on the disk.\nWriting to temporary files is controlled by the\nproxy_max_temp_file_size and\nproxy_temp_file_write_size directives.\n

\nWhen buffering is disabled, the response is passed to a client synchronously,\nimmediately as it is received.\nnginx will not try to read the whole response from the proxied server.\nThe maximum size of the data that nginx can receive from the server\nat a time is set by the proxy_buffer_size directive.\n

\nBuffering can also be enabled or disabled by passing\n“yes” or “no” in the\n“X-Accel-Buffering” response header field.\nThis capability can be disabled using the\nproxy_ignore_headers directive.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n proxy_buffers number size;
\n
\n Default:\n \n
proxy_buffers 8 4k|8k;
\n
\n Context:\n \n http, server, location
\n

\nSets the number and size of the\nbuffers used for reading a response from the proxied server,\nfor a single connection.\nBy default, the buffer size is equal to one memory page.\nThis is either 4K or 8K, depending on a platform.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n proxy_busy_buffers_size size;
\n
\n Default:\n \n
proxy_busy_buffers_size 8k|16k;
\n
\n Context:\n \n http, server, location
\n

\nWhen buffering of responses from the proxied\nserver is enabled, limits the total size of buffers that\ncan be busy sending a response to the client while the response is not\nyet fully read.\nIn the meantime, the rest of the buffers can be used for reading the response\nand, if needed, buffering part of the response to a temporary file.\nBy default, size is limited by the size of two buffers set by the\nproxy_buffer_size and proxy_buffers directives.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n proxy_cache zone | off;
\n
\n Default:\n \n
proxy_cache off;
\n
\n Context:\n \n http, server, location
\n

\nDefines a shared memory zone used for caching.\nThe same zone can be used in several places.\nParameter value can contain variables (1.7.9).\nThe off parameter disables caching inherited\nfrom the previous configuration level.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n proxy_cache_background_update on | off;
\n
\n Default:\n \n
proxy_cache_background_update off;
\n
\n Context:\n \n http, server, location
\n

This directive appeared in version 1.11.10.\n

\nAllows starting a background subrequest\nto update an expired cache item,\nwhile a stale cached response is returned to the client.\nNote that it is necessary to\nallow\nthe usage of a stale cached response when it is being updated.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n proxy_cache_bypass string ...;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n http, server, location
\n

\nDefines conditions under which the response will not be taken from a cache.\nIf at least one value of the string parameters is not empty and is not\nequal to “0” then the response will not be taken from the cache:\n

\nproxy_cache_bypass $cookie_nocache $arg_nocache$arg_comment;\nproxy_cache_bypass $http_pragma    $http_authorization;\n

\nCan be used along with the proxy_no_cache directive.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n proxy_cache_convert_head on | off;
\n
\n Default:\n \n
proxy_cache_convert_head on;
\n
\n Context:\n \n http, server, location
\n

This directive appeared in version 1.9.7.\n

\nEnables or disables the conversion of the “HEAD” method\nto “GET” for caching.\nWhen the conversion is disabled, the\ncache key should be configured\nto include the $request_method.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n proxy_cache_key string;
\n
\n Default:\n \n
proxy_cache_key $scheme$proxy_host$request_uri;
\n
\n Context:\n \n http, server, location
\n

\nDefines a key for caching, for example\n

\nproxy_cache_key \"$host$request_uri $cookie_user\";\n

\nBy default, the directive’s value is close to the string\n

\nproxy_cache_key $scheme$proxy_host$uri$is_args$args;\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n proxy_cache_lock on | off;
\n
\n Default:\n \n
proxy_cache_lock off;
\n
\n Context:\n \n http, server, location
\n

This directive appeared in version 1.1.12.\n

\nWhen enabled, only one request at a time will be allowed to populate\na new cache element identified according to the proxy_cache_key\ndirective by passing a request to a proxied server.\nOther requests of the same cache element will either wait\nfor a response to appear in the cache or the cache lock for\nthis element to be released, up to the time set by the\nproxy_cache_lock_timeout directive.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n proxy_cache_lock_age time;
\n
\n Default:\n \n
proxy_cache_lock_age 5s;
\n
\n Context:\n \n http, server, location
\n

This directive appeared in version 1.7.8.\n

\nIf the last request passed to the proxied server\nfor populating a new cache element\nhas not completed for the specified time,\none more request may be passed to the proxied server.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n proxy_cache_lock_timeout time;
\n
\n Default:\n \n
proxy_cache_lock_timeout 5s;
\n
\n Context:\n \n http, server, location
\n

This directive appeared in version 1.1.12.\n

\nSets a timeout for proxy_cache_lock.\nWhen the time expires,\nthe request will be passed to the proxied server,\nhowever, the response will not be cached.\n

\nBefore 1.7.8, the response could be cached.\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n proxy_cache_max_range_offset number;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n http, server, location
\n

This directive appeared in version 1.11.6.\n

\nSets an offset in bytes for byte-range requests.\nIf the range is beyond the offset,\nthe range request will be passed to the proxied server\nand the response will not be cached.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n proxy_cache_methods \n GET |\n HEAD |\n POST\n ...;
\n
\n Default:\n \n
proxy_cache_methods GET HEAD;
\n
\n Context:\n \n http, server, location
\n

This directive appeared in version 0.7.59.\n

\nIf the client request method is listed in this directive then\nthe response will be cached.\n“GET” and “HEAD” methods are always\nadded to the list, though it is recommended to specify them explicitly.\nSee also the proxy_no_cache directive.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n proxy_cache_min_uses number;
\n
\n Default:\n \n
proxy_cache_min_uses 1;
\n
\n Context:\n \n http, server, location
\n

\nSets the number of requests after which the response\nwill be cached.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n proxy_cache_path \n path\n [levels=levels]\n [use_temp_path=on|off]\n keys_zone=name:size\n [inactive=time]\n [max_size=size]\n [min_free=size]\n [manager_files=number]\n [manager_sleep=time]\n [manager_threshold=time]\n [loader_files=number]\n [loader_sleep=time]\n [loader_threshold=time]\n [purger=on|off]\n [purger_files=number]\n [purger_sleep=time]\n [purger_threshold=time];
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n http
\n

\nSets the path and other parameters of a cache.\nCache data are stored in files.\nThe file name in a cache is a result of\napplying the MD5 function to the\ncache key.\nThe levels parameter defines hierarchy levels of a cache:\nfrom 1 to 3, each level accepts values 1 or 2.\nFor example, in the following configuration\n

\nproxy_cache_path /data/nginx/cache levels=1:2 keys_zone=one:10m;\n

\nfile names in a cache will look like this:\n

\n/data/nginx/cache/c/29/b7f54b2df7773722d382f4809d65029c\n

\n

\nA cached response is first written to a temporary file,\nand then the file is renamed.\nStarting from version 0.8.9, temporary files and the cache can be put on\ndifferent file systems.\nHowever, be aware that in this case a file is copied\nacross two file systems instead of the cheap renaming operation.\nIt is thus recommended that for any given location both cache and a directory\nholding temporary files\nare put on the same file system.\nThe directory for temporary files is set based on\nthe use_temp_path parameter (1.7.10).\nIf this parameter is omitted or set to the value on,\nthe directory set by the proxy_temp_path directive\nfor the given location will be used.\nIf the value is set to off,\ntemporary files will be put directly in the cache directory.\n

\nIn addition, all active keys and information about data are stored\nin a shared memory zone, whose name and size\nare configured by the keys_zone parameter.\nOne megabyte zone can store about 8 thousand keys.\n

\nAs part of\ncommercial subscription,\nthe shared memory zone also stores extended\ncache information,\nthus, it is required to specify a larger zone size for the same number of keys.\nFor example,\none megabyte zone can store about 4 thousand keys.\n

\n

\nCached data that are not accessed during the time specified by the\ninactive parameter get removed from the cache\nregardless of their freshness.\nBy default, inactive is set to 10 minutes.\n

\nThe special “cache manager” process monitors the maximum cache size set\nby the max_size parameter,\nand the minimum amount of free space set\nby the min_free (1.19.1) parameter\non the file system with cache.\nWhen the size is exceeded or there is not enough free space,\nit removes the least recently used data.\nThe data is removed in iterations configured by\nmanager_files,\nmanager_threshold, and\nmanager_sleep parameters (1.11.5).\nDuring one iteration no more than manager_files items\nare deleted (by default, 100).\nThe duration of one iteration is limited by the\nmanager_threshold parameter (by default, 200 milliseconds).\nBetween iterations, a pause configured by the manager_sleep\nparameter (by default, 50 milliseconds) is made.\n

\nA minute after the start the special “cache loader” process is activated.\nIt loads information about previously cached data stored on file system\ninto a cache zone.\nThe loading is also done in iterations.\nDuring one iteration no more than loader_files items\nare loaded (by default, 100).\nBesides, the duration of one iteration is limited by the\nloader_threshold parameter (by default, 200 milliseconds).\nBetween iterations, a pause configured by the loader_sleep\nparameter (by default, 50 milliseconds) is made.\n

\nAdditionally,\nthe following parameters are available as part of our\ncommercial subscription:\n

\n

\n\n
\npurger=on|off\n
\n
\nInstructs whether cache entries that match a\nwildcard key\nwill be removed from the disk by the cache purger (1.7.12).\nSetting the parameter to on\n(default is off)\nwill activate the “cache purger” process that\npermanently iterates through all cache entries\nand deletes the entries that match the wildcard key.\n
\n\n
\npurger_files=number\n
\n
\nSets the number of items that will be scanned during one iteration (1.7.12).\nBy default, purger_files is set to 10.\n
\n\n
\npurger_threshold=number\n
\n
\nSets the duration of one iteration (1.7.12).\nBy default, purger_threshold is set to 50 milliseconds.\n
\n\n
\npurger_sleep=number\n
\n
\nSets a pause between iterations (1.7.12).\nBy default, purger_sleep is set to 50 milliseconds.\n
\n\n

\n

\n

\nIn versions 1.7.3, 1.7.7, and 1.11.10 cache header format has been changed.\nPreviously cached responses will be considered invalid\nafter upgrading to a newer nginx version.\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n proxy_cache_purge string ...;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n http, server, location
\n

This directive appeared in version 1.5.7.\n

\nDefines conditions under which the request will be considered a cache\npurge request.\nIf at least one value of the string parameters is not empty and is not equal\nto “0” then the cache entry with a corresponding\ncache key is removed.\nThe result of successful operation is indicated by returning\nthe 204 (No Content) response.\n

\nIf the cache key of a purge request ends\nwith an asterisk (“*”), all cache entries matching the\nwildcard key will be removed from the cache.\nHowever, these entries will remain on the disk until they are deleted\nfor either inactivity,\nor processed by the cache purger (1.7.12),\nor a client attempts to access them.\n

\nExample configuration:\n

\nproxy_cache_path /data/nginx/cache keys_zone=cache_zone:10m;\n\nmap $request_method $purge_method {\n    PURGE   1;\n    default 0;\n}\n\nserver {\n    ...\n    location / {\n        proxy_pass http://backend;\n        proxy_cache cache_zone;\n        proxy_cache_key $uri;\n        proxy_cache_purge $purge_method;\n    }\n}\n

\n

\nThis functionality is available as part of our\ncommercial subscription.\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n proxy_cache_revalidate on | off;
\n
\n Default:\n \n
proxy_cache_revalidate off;
\n
\n Context:\n \n http, server, location
\n

This directive appeared in version 1.5.7.\n

\nEnables revalidation of expired cache items using conditional requests with\nthe “If-Modified-Since” and “If-None-Match”\nheader fields.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n proxy_cache_use_stale \n error |\n timeout |\n invalid_header |\n updating |\n http_500 |\n http_502 |\n http_503 |\n http_504 |\n http_403 |\n http_404 |\n http_429 |\n off\n ...;
\n
\n Default:\n \n
proxy_cache_use_stale off;
\n
\n Context:\n \n http, server, location
\n

\nDetermines in which cases a stale cached response can be used\nduring communication with the proxied server.\nThe directive’s parameters match the parameters of the\nproxy_next_upstream directive.\n

\nThe error parameter also permits\nusing a stale cached response if a proxied server to process a request\ncannot be selected.\n

\nAdditionally, the updating parameter permits\nusing a stale cached response if it is currently being updated.\nThis allows minimizing the number of accesses to proxied servers\nwhen updating cached data.\n

\nUsing a stale cached response\ncan also be enabled directly in the response header\nfor a specified number of seconds after the response became stale (1.11.10).\nThis has lower priority than using the directive parameters.\n

\n

\nTo minimize the number of accesses to proxied servers when\npopulating a new cache element, the proxy_cache_lock\ndirective can be used.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n proxy_cache_valid [code ...] time;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n http, server, location
\n

\nSets caching time for different response codes.\nFor example, the following directives\n

\nproxy_cache_valid 200 302 10m;\nproxy_cache_valid 404      1m;\n

\nset 10 minutes of caching for responses with codes 200 and 302\nand 1 minute for responses with code 404.\n

\nIf only caching time is specified\n

\nproxy_cache_valid 5m;\n

\nthen only 200, 301, and 302 responses are cached.\n

\nIn addition, the any parameter can be specified\nto cache any responses:\n

\nproxy_cache_valid 200 302 10m;\nproxy_cache_valid 301      1h;\nproxy_cache_valid any      1m;\n

\n

\nParameters of caching can also be set directly\nin the response header.\nThis has higher priority than setting of caching time using the directive.\n

\nProcessing of one or more of these response header fields can be disabled\nusing the proxy_ignore_headers directive.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n proxy_connect_timeout time;
\n
\n Default:\n \n
proxy_connect_timeout 60s;
\n
\n Context:\n \n http, server, location
\n

\nDefines a timeout for establishing a connection with a proxied server.\nIt should be noted that this timeout cannot usually exceed 75 seconds.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n proxy_cookie_domain off;
proxy_cookie_domain domain replacement;
\n
\n Default:\n \n
proxy_cookie_domain off;
\n
\n Context:\n \n http, server, location
\n

This directive appeared in version 1.1.15.\n

\nSets a text that should be changed in the domain\nattribute of the “Set-Cookie” header fields of a\nproxied server response.\nSuppose a proxied server returned the “Set-Cookie”\nheader field with the attribute\n“domain=localhost”.\nThe directive\n

\nproxy_cookie_domain localhost example.org;\n

\nwill rewrite this attribute to\n“domain=example.org”.\n

\nA dot at the beginning of the domain and\nreplacement strings and the domain\nattribute is ignored.\nMatching is case-insensitive.\n

\nThe domain and replacement strings\ncan contain variables:\n

\nproxy_cookie_domain www.$host $host;\n

\n

\nThe directive can also be specified using regular expressions.\nIn this case, domain should start from\nthe “~” symbol.\nA regular expression can contain named and positional captures,\nand replacement can reference them:\n

\nproxy_cookie_domain ~\\.(?P<sl_domain>[-0-9a-z]+\\.[a-z]+)$ $sl_domain;\n

\n

\nSeveral proxy_cookie_domain directives\ncan be specified on the same level:\n

\nproxy_cookie_domain localhost example.org;\nproxy_cookie_domain ~\\.([a-z]+\\.[a-z]+)$ $1;\n

\nIf several directives can be applied to the cookie,\nthe first matching directive will be chosen.\n

\nThe off parameter cancels the effect\nof the proxy_cookie_domain directives\ninherited from the previous configuration level.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n proxy_cookie_flags \n off |\n cookie\n [flag ...];
\n
\n Default:\n \n
proxy_cookie_flags off;
\n
\n Context:\n \n http, server, location
\n

This directive appeared in version 1.19.3.\n

\nSets one or more flags for the cookie.\nThe cookie can contain text, variables, and their combinations.\nThe flag\ncan contain text, variables, and their combinations (1.19.8).\nThe\nsecure,\nhttponly,\nsamesite=strict,\nsamesite=lax,\nsamesite=none\nparameters add the corresponding flags.\nThe\nnosecure,\nnohttponly,\nnosamesite\nparameters remove the corresponding flags.\n

\nThe cookie can also be specified using regular expressions.\nIn this case, cookie should start from\nthe “~” symbol.\n

\nSeveral proxy_cookie_flags directives\ncan be specified on the same configuration level:\n

\nproxy_cookie_flags one httponly;\nproxy_cookie_flags ~ nosecure samesite=strict;\n

\nIf several directives can be applied to the cookie,\nthe first matching directive will be chosen.\nIn the example, the httponly flag\nis added to the cookie one,\nfor all other cookies\nthe samesite=strict flag is added and\nthe secure flag is deleted.\n

\nThe off parameter cancels the effect\nof the proxy_cookie_flags directives\ninherited from the previous configuration level.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n proxy_cookie_path off;
proxy_cookie_path path replacement;
\n
\n Default:\n \n
proxy_cookie_path off;
\n
\n Context:\n \n http, server, location
\n

This directive appeared in version 1.1.15.\n

\nSets a text that should be changed in the path\nattribute of the “Set-Cookie” header fields of a\nproxied server response.\nSuppose a proxied server returned the “Set-Cookie”\nheader field with the attribute\n“path=/two/some/uri/”.\nThe directive\n

\nproxy_cookie_path /two/ /;\n

\nwill rewrite this attribute to\n“path=/some/uri/”.\n

\nThe path and replacement strings\ncan contain variables:\n

\nproxy_cookie_path $uri /some$uri;\n

\n

\nThe directive can also be specified using regular expressions.\nIn this case, path should either start from\nthe “~” symbol for a case-sensitive matching,\nor from the “~*” symbols for case-insensitive\nmatching.\nThe regular expression can contain named and positional captures,\nand replacement can reference them:\n

\nproxy_cookie_path ~*^/user/([^/]+) /u/$1;\n

\n

\nSeveral proxy_cookie_path directives\ncan be specified on the same level:\n

\nproxy_cookie_path /one/ /;\nproxy_cookie_path / /two/;\n

\nIf several directives can be applied to the cookie,\nthe first matching directive will be chosen.\n

\nThe off parameter cancels the effect\nof the proxy_cookie_path directives\ninherited from the previous configuration level.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n proxy_force_ranges on | off;
\n
\n Default:\n \n
proxy_force_ranges off;
\n
\n Context:\n \n http, server, location
\n

This directive appeared in version 1.7.7.\n

\nEnables byte-range support\nfor both cached and uncached responses from the proxied server\nregardless of the “Accept-Ranges” field in these responses.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n proxy_headers_hash_bucket_size size;
\n
\n Default:\n \n
proxy_headers_hash_bucket_size 64;
\n
\n Context:\n \n http, server, location
\n

\nSets the bucket size for hash tables\nused by the proxy_hide_header and proxy_set_header\ndirectives.\nThe details of setting up hash tables are provided in a separate\ndocument.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n proxy_headers_hash_max_size size;
\n
\n Default:\n \n
proxy_headers_hash_max_size 512;
\n
\n Context:\n \n http, server, location
\n

\nSets the maximum size of hash tables\nused by the proxy_hide_header and proxy_set_header\ndirectives.\nThe details of setting up hash tables are provided in a separate\ndocument.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n proxy_hide_header field;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n http, server, location
\n

\nBy default,\nnginx does not pass the header fields “Date”,\n“Server”, “X-Pad”, and\n“X-Accel-...” from the response of a proxied\nserver to a client.\nThe proxy_hide_header directive sets additional fields\nthat will not be passed.\nIf, on the contrary, the passing of fields needs to be permitted,\nthe proxy_pass_header directive can be used.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n proxy_http_version \n 1.0 | 1.1 |\n 2;
\n
\n Default:\n \n
proxy_http_version 1.1;
\n
\n Context:\n \n http, server, location
\n

This directive appeared in version 1.1.4.\n

\nSets the HTTP protocol version for proxying.\nSince 1.29.7, version 1.1 is used by default.\nBefore 1.29.7, version 1.0 was used by default.\nVersion 1.1 or 2 (1.29.4) is recommended for use with\nkeepalive\nconnections and\nNTLM authentication.\n

\nVersion 2 requires the\nngx_http_v2_module module.\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n proxy_ignore_client_abort on | off;
\n
\n Default:\n \n
proxy_ignore_client_abort off;
\n
\n Context:\n \n http, server, location
\n

\nDetermines whether the connection with a proxied server should be\nclosed when a client closes the connection without waiting\nfor a response.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n proxy_ignore_headers field ...;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n http, server, location
\n

\nDisables processing of certain response header fields from the proxied server.\nThe following fields can be ignored: “X-Accel-Redirect”,\n“X-Accel-Expires”, “X-Accel-Limit-Rate” (1.1.6),\n“X-Accel-Buffering” (1.1.6),\n“X-Accel-Charset” (1.1.6), “Expires”,\n“Cache-Control”, “Set-Cookie” (0.8.44),\nand “Vary” (1.7.7).\n

\nIf not disabled, processing of these header fields has the following\neffect:\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n proxy_intercept_errors on | off;
\n
\n Default:\n \n
proxy_intercept_errors off;
\n
\n Context:\n \n http, server, location
\n

\nDetermines whether proxied responses with codes greater than or equal\nto 300 should be passed to a client\nor be intercepted and redirected to nginx for processing\nwith the error_page directive.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n proxy_limit_rate rate;
\n
\n Default:\n \n
proxy_limit_rate 0;
\n
\n Context:\n \n http, server, location
\n

This directive appeared in version 1.7.7.\n

\nLimits the speed of reading the response from the proxied server.\nThe rate is specified in bytes per second.\nThe zero value disables rate limiting.\nThe limit is set per a request, and so if nginx simultaneously opens\ntwo connections to the proxied server,\nthe overall rate will be twice as much as the specified limit.\nThe limitation works only if\nbuffering of responses from the proxied\nserver is enabled.\nParameter value can contain variables (1.27.0).\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n proxy_max_temp_file_size size;
\n
\n Default:\n \n
proxy_max_temp_file_size 1024m;
\n
\n Context:\n \n http, server, location
\n

\nWhen buffering of responses from the proxied\nserver is enabled, and the whole response does not fit into the buffers\nset by the proxy_buffer_size and proxy_buffers\ndirectives, a part of the response can be saved to a temporary file.\nThis directive sets the maximum size of the temporary file.\nThe size of data written to the temporary file at a time is set\nby the proxy_temp_file_write_size directive.\n

\nThe zero value disables buffering of responses to temporary files.\n

\n

\nThis restriction does not apply to responses\nthat will be cached\nor stored on disk.\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n proxy_method method;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n http, server, location
\n

\nSpecifies the HTTP method to use in requests forwarded\nto the proxied server instead of the method from the client request.\nParameter value can contain variables (1.11.6).\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n proxy_next_upstream \n error |\n timeout |\n denied |\n invalid_header |\n http_500 |\n http_502 |\n http_503 |\n http_504 |\n http_403 |\n http_404 |\n http_429 |\n non_idempotent |\n off\n ...;
\n
\n Default:\n \n
proxy_next_upstream error timeout;
\n
\n Context:\n \n http, server, location
\n

\nSpecifies in which cases a request should be passed to the next server:\n

\n\n
error
\n
an error occurred while establishing a connection with the\nserver, passing a request to it, or reading the response header;
\n\n
timeout
\n
a timeout has occurred while establishing a connection with the\nserver, passing a request to it, or reading the response header;
\n\n
denied
\n
the server denied\nthe connection (1.29.3);\n

\n

\nThis parameter is available as part of our\ncommercial subscription.\n

\n

\n
\n\n
invalid_header
\n
a server returned an empty or invalid response;
\n\n
http_500
\n
a server returned a response with the code 500;
\n\n
http_502
\n
a server returned a response with the code 502;
\n\n
http_503
\n
a server returned a response with the code 503;
\n\n
http_504
\n
a server returned a response with the code 504;
\n\n
http_403
\n
a server returned a response with the code 403;
\n\n
http_404
\n
a server returned a response with the code 404;
\n\n
http_429
\n
a server returned a response with the code 429 (1.11.13);
\n\n
non_idempotent
\n
normally, requests with a\nnon-idempotent\nmethod\n(POST, LOCK, PATCH)\nare not passed to the next server\nif a request has been sent to an upstream server (1.9.13);\nenabling this option explicitly allows retrying such requests;\n
\n\n
off
\n
disables passing a request to the next server.
\n\n

\n

\nOne should bear in mind that passing a request to the next server is\nonly possible if nothing has been sent to a client yet.\nThat is, if an error or timeout occurs in the middle of the\ntransferring of a response, fixing this is impossible.\n

\nThe directive also defines what is considered an\nunsuccessful\nattempt of communication with a server.\nThe cases of error, timeout,\ndenied and\ninvalid_header are always considered unsuccessful attempts,\neven if they are not specified in the directive.\nThe cases of http_500, http_502,\nhttp_503, http_504,\nand http_429 are\nconsidered unsuccessful attempts only if they are specified in the directive.\nThe cases of http_403 and http_404\nare never considered unsuccessful attempts.\n

\nPassing a request to the next server can be limited by\nthe number of tries\nand by time.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n proxy_next_upstream_timeout time;
\n
\n Default:\n \n
proxy_next_upstream_timeout 0;
\n
\n Context:\n \n http, server, location
\n

This directive appeared in version 1.7.5.\n

\nLimits the time during which a request can be passed to the\nnext server.\nThe 0 value turns off this limitation.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n proxy_next_upstream_tries number;
\n
\n Default:\n \n
proxy_next_upstream_tries 0;
\n
\n Context:\n \n http, server, location
\n

This directive appeared in version 1.7.5.\n

\nLimits the number of possible tries for passing a request to the\nnext server.\nThe 0 value turns off this limitation.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n proxy_no_cache string ...;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n http, server, location
\n

\nDefines conditions under which the response will not be saved to a cache.\nIf at least one value of the string parameters is not empty and is not\nequal to “0” then the response will not be saved:\n

\nproxy_no_cache $cookie_nocache $arg_nocache$arg_comment;\nproxy_no_cache $http_pragma    $http_authorization;\n

\nCan be used along with the proxy_cache_bypass directive.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n proxy_pass URL;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n location, if in location, limit_except
\n

\nSets the protocol and address of a proxied server and an optional URI\nto which a location should be mapped.\nAs a protocol, “http” or “https”\ncan be specified.\nThe address can be specified as a domain name or IP address,\nand an optional port:\n

\nproxy_pass http://localhost:8000/uri/;\n

\nor as a UNIX-domain socket path specified after the word\n“unix” and enclosed in colons:\n

\nproxy_pass http://unix:/tmp/backend.socket:/uri/;\n

\n

\nIf a domain name resolves to several addresses, all of them will be\nused in a round-robin fashion.\nIn addition, an address can be specified as a\nserver group.\n

\nParameter value can contain variables.\nIn this case, if an address is specified as a domain name,\nthe name is searched among the described server groups,\nand, if not found, is determined using a\nresolver.\n

\nA request URI is passed to the server as follows:\n

\n

\nIn some cases, the part of a request URI to be replaced cannot be determined:\n

\n

\nWebSocket proxying requires special\nconfiguration and is supported since version 1.3.13.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n proxy_pass_header field;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n http, server, location
\n

\nPermits passing otherwise disabled header\nfields from a proxied server to a client.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n proxy_pass_request_body on | off;
\n
\n Default:\n \n
proxy_pass_request_body on;
\n
\n Context:\n \n http, server, location
\n

\nIndicates whether the original request body is passed\nto the proxied server.\n

\nlocation /x-accel-redirect-here/ {\n    proxy_method GET;\n    proxy_pass_request_body off;\n    proxy_set_header Content-Length \"\";\n\n    proxy_pass ...\n}\n

\nSee also the proxy_set_header and\nproxy_pass_request_headers directives.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n proxy_pass_request_headers on | off;
\n
\n Default:\n \n
proxy_pass_request_headers on;
\n
\n Context:\n \n http, server, location
\n

\nIndicates whether the header fields of the original request are passed\nto the proxied server.\n

\nlocation /x-accel-redirect-here/ {\n    proxy_method GET;\n    proxy_pass_request_headers off;\n    proxy_pass_request_body off;\n\n    proxy_pass ...\n}\n

\nSee also the proxy_set_header and\nproxy_pass_request_body directives.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n proxy_pass_trailers on | off;
\n
\n Default:\n \n
proxy_pass_trailers off;
\n
\n Context:\n \n http, server, location
\n

This directive appeared in version 1.27.2.\n

\nPermits passing trailer fields from a proxied server to a client.\n

\n

\nA trailer section should be\nexplicitly enabled:\n

\n

\nlocation / {\n    # proxy_http_version 1.1;  #for versions before 1.29.7\n    proxy_set_header     Connection \"te\";\n    proxy_set_header     TE \"trailers\";\n    proxy_pass_trailers  on;\n\n    proxy_pass ...\n}\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n proxy_read_timeout time;
\n
\n Default:\n \n
proxy_read_timeout 60s;
\n
\n Context:\n \n http, server, location
\n

\nDefines a timeout for reading a response from the proxied server.\nThe timeout is set only between two successive read operations,\nnot for the transmission of the whole response.\nIf the proxied server does not transmit anything within this time,\nthe connection is closed.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n proxy_redirect default;
proxy_redirect off;
proxy_redirect redirect replacement;
\n
\n Default:\n \n
proxy_redirect default;
\n
\n Context:\n \n http, server, location
\n

\nSets the text that should be changed in the “Location”\nand “Refresh” header fields of a proxied server response.\nSuppose a proxied server returned the header field\n“Location: http://localhost:8000/two/some/uri/”.\nThe directive\n

\nproxy_redirect http://localhost:8000/two/ http://frontend/one/;\n

\nwill rewrite this string to\n“Location: http://frontend/one/some/uri/”.\n

\nA server name may be omitted in the replacement string:\n

\nproxy_redirect http://localhost:8000/two/ /;\n

\nthen the primary server’s name and port, if different from 80,\nwill be inserted.\n

\nThe default replacement specified by the default parameter\nuses the parameters of the\nlocation and\nproxy_pass directives.\nHence, the two configurations below are equivalent:\n

\nlocation /one/ {\n    proxy_pass     http://upstream:port/two/;\n    proxy_redirect default;\n

\n\n

\nlocation /one/ {\n    proxy_pass     http://upstream:port/two/;\n    proxy_redirect http://upstream:port/two/ /one/;\n

\nThe default parameter is not permitted if\nproxy_pass is specified using variables.\n

\nA replacement string can contain variables:\n

\nproxy_redirect http://localhost:8000/ http://$host:$server_port/;\n

\n

\nA redirect can also contain (1.1.11) variables:\n

\nproxy_redirect http://$proxy_host:8000/ /;\n

\n

\nThe directive can be specified (1.1.11) using regular expressions.\nIn this case, redirect should either start with\nthe “~” symbol for a case-sensitive matching,\nor with the “~*” symbols for case-insensitive\nmatching.\nThe regular expression can contain named and positional captures,\nand replacement can reference them:\n

\nproxy_redirect ~^(http://[^:]+):\\d+(/.+)$ $1$2;\nproxy_redirect ~*/user/([^/]+)/(.+)$      http://$1.example.com/$2;\n

\n

\nSeveral proxy_redirect directives\ncan be specified on the same level:\n

\nproxy_redirect default;\nproxy_redirect http://localhost:8000/  /;\nproxy_redirect http://www.example.com/ /;\n

\nIf several directives can be applied to\nthe header fields of a proxied server response,\nthe first matching directive will be chosen.\n

\nThe off parameter cancels the effect\nof the proxy_redirect directives\ninherited from the previous configuration level.\n

\nUsing this directive, it is also possible to add host names to relative\nredirects issued by a proxied server:\n

\nproxy_redirect / /;\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n proxy_request_buffering on | off;
\n
\n Default:\n \n
proxy_request_buffering on;
\n
\n Context:\n \n http, server, location
\n

This directive appeared in version 1.7.11.\n

\nEnables or disables buffering of a client request body.\n

\nWhen buffering is enabled, the entire request body is\nread\nfrom the client before sending the request to a proxied server.\n

\nWhen buffering is disabled, the request body is sent to the proxied server\nimmediately as it is received.\nIn this case, the request cannot be passed to the\nnext server\nif nginx already started sending the request body.\n

\nWhen HTTP/1.1 chunked transfer encoding is used\nto send the original request body,\nthe request body will be buffered regardless of the directive value unless\nHTTP/1.1 or HTTP/2 is enabled for proxying.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n proxy_request_dynamic on | off;
\n
\n Default:\n \n
proxy_request_dynamic off;
\n
\n Context:\n \n http, server, location
\n

This directive appeared in version 1.29.3.\n

\nEnables or disables creation of a separate request instance\nfor each proxied server.\nBy default, a single request is used for all proxied servers.\nIf enabled, a separate request instance is created,\nallowing per-server request customization.\nFor example, the server-specific “Host” request header field\ncan be set:\n

\nproxy_request_dynamic on;\nproxy_set_header      Host $upstream_last_server_name;\n

\n

\n

\nThis directive is available as part of our\ncommercial subscription.\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n proxy_send_lowat size;
\n
\n Default:\n \n
proxy_send_lowat 0;
\n
\n Context:\n \n http, server, location
\n

\nIf the directive is set to a non-zero value, nginx will try to\nminimize the number\nof send operations on outgoing connections to a proxied server by using either\nNOTE_LOWAT flag of the\nkqueue method,\nor the SO_SNDLOWAT socket option,\nwith the specified size.\n

\nThis directive is ignored on Linux, Solaris, and Windows.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n proxy_send_timeout time;
\n
\n Default:\n \n
proxy_send_timeout 60s;
\n
\n Context:\n \n http, server, location
\n

\nSets a timeout for transmitting a request to the proxied server.\nThe timeout is set only between two successive write operations,\nnot for the transmission of the whole request.\nIf the proxied server does not receive anything within this time,\nthe connection is closed.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n proxy_set_body value;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n http, server, location
\n

\nAllows redefining the request body passed to the proxied server.\nThe value can contain text, variables, and their combination.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n proxy_set_header field value;
\n
\n Default:\n \n
proxy_set_header Host $proxy_host;
proxy_set_header Connection close;
\n
\n Context:\n \n http, server, location
\n

\nAllows redefining or appending fields to the request header\npassed to the proxied server.\nThe value can contain text, variables, and their combinations.\nThese directives are inherited from the previous configuration level\nif and only if there are no proxy_set_header directives\ndefined on the current level.\n

\nBy default, the header fields\n“Host”\nand\n“Connection”\nfrom the original request are not passed to the proxied server.\nIf HTTP/1.0 or HTTP/1.1 is\nenabled for proxying,\nthese fields are redefined:\n

\nproxy_set_header Host       $proxy_host;\nproxy_set_header Connection close;\n

\nFor HTTP/2, the\n“:authority”\npseudo-header field with the\n$proxy_host\nvalue is sent by default,\nunless it is replaced with an explicit “Host” header field.\n

\nIf caching is enabled, the header fields\n“If-Modified-Since”,\n“If-Unmodified-Since”,\n“If-None-Match”,\n“If-Match”,\n“Range”,\nand\n“If-Range”\nfrom the original request are not passed to the proxied server.\n

\nAn unchanged “Host” request header field can be passed like this:\n

\nproxy_set_header Host       $http_host;\n

\n

\nHowever, if this field is not present in a client request header then\nnothing will be passed.\nIn such a case it is better to use the $host variable - its\nvalue equals the server name in the “Host” request header\nfield or the primary server name if this field is not present:\n

\nproxy_set_header Host       $host;\n

\n

\nIn addition, the server name can be passed together with the port of the\nproxied server:\n

\nproxy_set_header Host       $host:$proxy_port;\n

\n

\nIf the value of a header field is an empty string then this\nfield will not be passed to a proxied server:\n

\nproxy_set_header Accept-Encoding \"\";\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n proxy_socket_keepalive on | off;
\n
\n Default:\n \n
proxy_socket_keepalive off;
\n
\n Context:\n \n http, server, location
\n

This directive appeared in version 1.15.6.\n

\nConfigures the “TCP keepalive” behavior\nfor outgoing connections to a proxied server.\nBy default, the operating system’s settings are in effect for the socket.\nIf the directive is set to the value “on”, the\nSO_KEEPALIVE socket option is turned on for the socket.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n proxy_ssl_certificate file;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n http, server, location
\n

This directive appeared in version 1.7.8.\n

\nSpecifies a file with the certificate in the PEM format\nused for authentication to a proxied HTTPS server.\n

\nSince version 1.21.0, variables can be used in the file name.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n proxy_ssl_certificate_cache off;
proxy_ssl_certificate_cache \n max=N\n [inactive=time]\n [valid=time];
\n
\n Default:\n \n
proxy_ssl_certificate_cache off;
\n
\n Context:\n \n http, server, location
\n

This directive appeared in version 1.27.4.\n

\nDefines a cache that stores\nSSL certificates and\nsecret keys\nspecified with variables.\n

\nThe directive has the following parameters:\n

\n\n
\nmax\n
\n
\nsets the maximum number of elements in the cache;\non cache overflow the least recently used (LRU) elements are removed;\n
\n\n
\ninactive\n
\n
\ndefines a time after which an element is removed from the cache\nif it has not been accessed during this time;\nby default, it is 10 seconds;\n
\n\n
\nvalid\n
\n
\ndefines a time during which\nan element in the cache is considered valid\nand can be reused;\nby default, it is 60 seconds.\nCertificates that exceed this time will be reloaded or revalidated;\n
\n\n
\noff\n
\n
\ndisables the cache.\n
\n\n

\n

\nExample:\n

\nproxy_ssl_certificate       $proxy_ssl_server_name.crt;\nproxy_ssl_certificate_key   $proxy_ssl_server_name.key;\nproxy_ssl_certificate_cache max=1000 inactive=20s valid=1m;\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n proxy_ssl_certificate_key file;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n http, server, location
\n

This directive appeared in version 1.7.8.\n

\nSpecifies a file with the secret key in the PEM format\nused for authentication to a proxied HTTPS server.\n

\nThe value\nengine:name:id\ncan be specified instead of the file (1.7.9),\nwhich loads a secret key with a specified id\nfrom the OpenSSL engine name.\n

\nThe value\nstore:scheme:id\ncan be specified instead of the file (1.29.0),\nwhich is used to load a secret key with a specified id\nand OpenSSL provider registered URI scheme, such as\npkcs11.\n

\nSince version 1.21.0, variables can be used in the file name.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n proxy_ssl_ciphers ciphers;
\n
\n Default:\n \n
proxy_ssl_ciphers DEFAULT;
\n
\n Context:\n \n http, server, location
\n

This directive appeared in version 1.5.6.\n

\nSpecifies the enabled ciphers for requests to a proxied HTTPS server.\nThe ciphers are specified in the format understood by the OpenSSL library.\n

\nThe full list can be viewed using the\n“openssl ciphers” command.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n proxy_ssl_conf_command name value;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n http, server, location
\n

This directive appeared in version 1.19.4.\n

\nSets arbitrary OpenSSL configuration\ncommands\nwhen establishing a connection with the proxied HTTPS server.\n

\nThe directive is supported when using OpenSSL 1.0.2 or higher.\n

\n

\nSeveral proxy_ssl_conf_command directives\ncan be specified on the same level.\nThese directives are inherited from the previous configuration level\nif and only if there are\nno proxy_ssl_conf_command directives\ndefined on the current level.\n

\n

\nNote that configuring OpenSSL directly\nmight result in unexpected behavior.\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n proxy_ssl_crl file;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n http, server, location
\n

This directive appeared in version 1.7.0.\n

\nSpecifies a file with revoked certificates (CRL)\nin the PEM format used to verify\nthe certificate of the proxied HTTPS server.\nWhen using intermediate certificates, their CRLs should be\nspecified in the same file.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n proxy_ssl_key_log path;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n http, server, location
\n

This directive appeared in version 1.27.2.\n

\nEnables logging of proxied HTTPS server connection SSL keys\nand specifies the path to the key log file.\nKeys are logged in the\nSSLKEYLOGFILE\nformat compatible with Wireshark.\n

\n

\nThis directive is available as part of our\ncommercial subscription.\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n proxy_ssl_name name;
\n
\n Default:\n \n
proxy_ssl_name $proxy_host;
\n
\n Context:\n \n http, server, location
\n

This directive appeared in version 1.7.0.\n

\nAllows overriding the server name used to\nverify\nthe certificate of the proxied HTTPS server and to be\npassed through SNI\nwhen establishing a connection with the proxied HTTPS server.\n

\nBy default, the host part of the proxy_pass URL is used.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n proxy_ssl_password_file file;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n http, server, location
\n

This directive appeared in version 1.7.8.\n

\nSpecifies a file with passphrases for\nsecret keys\nwhere each passphrase is specified on a separate line.\nPassphrases are tried in turn when loading the key.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n proxy_ssl_protocols \n [SSLv2]\n [SSLv3]\n [TLSv1]\n [TLSv1.1]\n [TLSv1.2]\n [TLSv1.3];
\n
\n Default:\n \n
proxy_ssl_protocols TLSv1.2 TLSv1.3;
\n
\n Context:\n \n http, server, location
\n

This directive appeared in version 1.5.6.\n

\nEnables the specified protocols for requests to a proxied HTTPS server.\n

\n

\nThe TLSv1.3 parameter is used by default\nsince 1.23.4.\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n proxy_ssl_server_name on | off;
\n
\n Default:\n \n
proxy_ssl_server_name off;
\n
\n Context:\n \n http, server, location
\n

This directive appeared in version 1.7.0.\n

\nEnables or disables passing of the server name through\nTLS\nServer Name Indication extension (SNI, RFC 6066)\nwhen establishing a connection with the proxied HTTPS server.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n proxy_ssl_session_reuse on | off;
\n
\n Default:\n \n
proxy_ssl_session_reuse on;
\n
\n Context:\n \n http, server, location
\n

\nDetermines whether SSL sessions can be reused when working with\nthe proxied server.\nIf the errors\n“digest check failed”\nappear in the logs, try disabling session reuse.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n proxy_ssl_trusted_certificate file;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n http, server, location
\n

This directive appeared in version 1.7.0.\n

\nSpecifies a file with trusted CA certificates in the PEM format\nused to verify\nthe certificate of the proxied HTTPS server.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n proxy_ssl_verify on | off;
\n
\n Default:\n \n
proxy_ssl_verify off;
\n
\n Context:\n \n http, server, location
\n

This directive appeared in version 1.7.0.\n

\nEnables or disables verification of the proxied HTTPS server certificate.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n proxy_ssl_verify_depth number;
\n
\n Default:\n \n
proxy_ssl_verify_depth 1;
\n
\n Context:\n \n http, server, location
\n

This directive appeared in version 1.7.0.\n

\nSets the verification depth in the proxied HTTPS server certificates chain.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n proxy_store \n on |\n off |\n string;
\n
\n Default:\n \n
proxy_store off;
\n
\n Context:\n \n http, server, location
\n

\nEnables saving of files to a disk.\nThe on parameter saves files with paths\ncorresponding to the directives\nalias or\nroot.\nThe off parameter disables saving of files.\nIn addition, the file name can be set explicitly using the\nstring with variables:\n

\nproxy_store /data/www$original_uri;\n

\n

\nThe modification time of files is set according to the received\n“Last-Modified” response header field.\nThe response is first written to a temporary file,\nand then the file is renamed.\nStarting from version 0.8.9, temporary files and the persistent store\ncan be put on different file systems.\nHowever, be aware that in this case a file is copied\nacross two file systems instead of the cheap renaming operation.\nIt is thus recommended that for any given location both saved files and a\ndirectory holding temporary files, set by the proxy_temp_path\ndirective, are put on the same file system.\n

\nThis directive can be used to create local copies of static unchangeable\nfiles, e.g.:\n

\nlocation /images/ {\n    root               /data/www;\n    error_page         404 = /fetch$uri;\n}\n\nlocation /fetch/ {\n    internal;\n\n    proxy_pass         http://backend/;\n    proxy_store        on;\n    proxy_store_access user:rw group:rw all:r;\n    proxy_temp_path    /data/temp;\n\n    alias              /data/www/;\n}\n

\n

\nor like this:\n

\nlocation /images/ {\n    root               /data/www;\n    error_page         404 = @fetch;\n}\n\nlocation @fetch {\n    internal;\n\n    proxy_pass         http://backend;\n    proxy_store        on;\n    proxy_store_access user:rw group:rw all:r;\n    proxy_temp_path    /data/temp;\n\n    root               /data/www;\n}\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n proxy_store_access users:permissions ...;
\n
\n Default:\n \n
proxy_store_access user:rw;
\n
\n Context:\n \n http, server, location
\n

\nSets access permissions for newly created files and directories, e.g.:\n

\nproxy_store_access user:rw group:rw all:r;\n

\n

\nIf any group or all access permissions\nare specified then user permissions may be omitted:\n

\nproxy_store_access group:rw all:r;\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n proxy_temp_file_write_size size;
\n
\n Default:\n \n
proxy_temp_file_write_size 8k|16k;
\n
\n Context:\n \n http, server, location
\n

\nLimits the size of data written to a temporary file\nat a time, when buffering of responses from the proxied server\nto temporary files is enabled.\nBy default, size is limited by two buffers set by the\nproxy_buffer_size and proxy_buffers directives.\nThe maximum size of a temporary file is set by the\nproxy_max_temp_file_size directive.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n proxy_temp_path \n path\n [level1\n [level2\n [level3]]];
\n
\n Default:\n \n
proxy_temp_path proxy_temp;
\n
\n Context:\n \n http, server, location
\n

\nDefines a directory for storing temporary files\nwith data received from proxied servers.\nUp to three-level subdirectory hierarchy can be used underneath the specified\ndirectory.\nFor example, in the following configuration\n

\nproxy_temp_path /spool/nginx/proxy_temp 1 2;\n

\na temporary file might look like this:\n

\n/spool/nginx/proxy_temp/7/45/00000123457\n

\n

\nSee also the use_temp_path parameter of the\nproxy_cache_path directive.\n

\n\n\n

Embedded Variables

\nThe ngx_http_proxy_module module supports embedded variables\nthat can be used to compose headers using the\nproxy_set_header directive:\n

\n\n
$proxy_host
\n
name and port of a proxied server as specified in the\nproxy_pass directive;
\n\n
$proxy_port
\n
port of a proxied server as specified in the\nproxy_pass directive, or the protocol’s default port;
\n\n
\n$proxy_add_x_forwarded_for
\n
the “X-Forwarded-For” client request header field\nwith the $remote_addr variable appended to it, separated by a comma.\nIf the “X-Forwarded-For” field is not present in the client\nrequest header, the $proxy_add_x_forwarded_for variable is equal\nto the $remote_addr variable.
\n

\n

\n\n
\n", "encoding": "utf-8"} +{"path": "en\\docs\\http\\ngx_http_proxy_protocol_vendor_module.html", "extension": ".html", "size_bytes": 4724, "content": "\nModule ngx_http_proxy_protocol_vendor_module
\n\nPlanning your ingress-nginx migration? Start here:\nkubernetes.nginx.org.\n\n

Module ngx_http_proxy_protocol_vendor_module

Example Configuration
Embedded Variables
\n\n

\nThe ngx_http_proxy_protocol_vendor_module module (1.23.3)\nallows obtaining additional information about a connection in\ncloud platforms from application-specific TLVs of the\nPROXY\nprotocol\nheader.\n

\nSupported cloud platforms:\n

\n

\nThe PROXY protocol must be previously enabled by setting the\nproxy_protocol parameter\nin the listen directive.\n

\n

\nThis module is available as part of our\ncommercial subscription.\n

\n

\n\n\n

Example Configuration

\n

\nproxy_set_header X-Conn-ID $proxy_protocol_tlv_gcp_conn_id;\n\nserver {\n    listen 80   proxy_protocol;\n    listen 443  ssl proxy_protocol;\n    ...\n}\n

\n

\n\n\n

Embedded Variables

\n

\n\n
$proxy_protocol_tlv_aws_vpce_id
\n
\nTLV value from the PROXY Protocol header representing the\nID\nof AWS VPC endpoint\n
\n\n
$proxy_protocol_tlv_azure_pel_id
\n
\nTLV value from the PROXY Protocol header representing the\nLinkID\nof Azure private endpoint\n
\n\n
$proxy_protocol_tlv_gcp_conn_id
\n
\nTLV value from the PROXY Protocol header representing\nGoogle Cloud PSC\nconnection ID\n
\n\n

\n

\n\n
\n", "encoding": "utf-8"} +{"path": "en\\docs\\http\\ngx_http_random_index_module.html", "extension": ".html", "size_bytes": 4107, "content": "\nModule ngx_http_random_index_module
\n\nPlanning your ingress-nginx migration? Start here:\nkubernetes.nginx.org.\n\n

Module ngx_http_random_index_module

Example Configuration
Directives
     random_index
\n\n

\nThe ngx_http_random_index_module module processes requests\nending with the slash character (‘/’) and picks a random\nfile in a directory to serve as an index file.\nThe module is processed before the\nngx_http_index_module\nmodule.\n

\nThis module is not built by default, it should be enabled with the\n--with-http_random_index_module\nconfiguration parameter.\n

\n\n\n

Example Configuration

\n

\nlocation / {\n    random_index on;\n}\n

\n

\n\n\n

Directives

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n random_index on | off;
\n
\n Default:\n \n
random_index off;
\n
\n Context:\n \n location
\n

\nEnables or disables module processing in a surrounding location.\n

\n\n
\n", "encoding": "utf-8"} +{"path": "en\\docs\\http\\ngx_http_realip_module.html", "extension": ".html", "size_bytes": 8013, "content": "\nModule ngx_http_realip_module
\n\nPlanning your ingress-nginx migration? Start here:\nkubernetes.nginx.org.\n\n

Module ngx_http_realip_module

Example Configuration
Directives
     set_real_ip_from
     real_ip_header
     real_ip_recursive
Embedded Variables
\n\n

\nThe ngx_http_realip_module module is used\nto change the client address and optional port\nto those sent in the specified header field.\n

\nThis module is not built by default, it should be enabled with the\n--with-http_realip_module\nconfiguration parameter.\n

\n\n\n

Example Configuration

\n

\nset_real_ip_from  192.168.1.0/24;\nset_real_ip_from  192.168.2.1;\nset_real_ip_from  2001:0db8::/32;\nreal_ip_header    X-Forwarded-For;\nreal_ip_recursive on;\n

\n

\n\n\n

Directives

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n set_real_ip_from \n address |\n CIDR |\n unix:;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n http, server, location
\n

\nDefines trusted addresses that are known to send correct\nreplacement addresses.\nIf the special value unix: is specified,\nall UNIX-domain sockets will be trusted.\nTrusted addresses may also be specified using a hostname (1.13.1).\n

\nIPv6 addresses are supported starting from versions 1.3.0 and 1.2.1.\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n real_ip_header \n field |\n X-Real-IP |\n X-Forwarded-For |\n proxy_protocol;
\n
\n Default:\n \n
real_ip_header X-Real-IP;
\n
\n Context:\n \n http, server, location
\n

\nDefines the request header field\nwhose value will be used to replace the client address.\n

\nThe request header field value that contains an optional port\nis also used to replace the client port (1.11.0).\nThe address and port should be specified according to\nRFC 3986.\n

\nThe proxy_protocol parameter (1.5.12) changes\nthe client address to the one from the PROXY protocol header.\nThe PROXY protocol must be previously enabled by setting the\nproxy_protocol parameter\nin the listen directive.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n real_ip_recursive on | off;
\n
\n Default:\n \n
real_ip_recursive off;
\n
\n Context:\n \n http, server, location
\n
\n

\n This directive appeared in versions 1.3.0 and 1.2.1.\n \n

\n

\nIf recursive search is disabled, the original client address that\nmatches one of the trusted addresses is replaced by the last\naddress sent in the request header field defined by the\nreal_ip_header directive.\nIf recursive search is enabled, the original client address that\nmatches one of the trusted addresses is replaced by the last\nnon-trusted address sent in the request header field.\n

\n\n\n

Embedded Variables

\n

\n\n
$realip_remote_addr
\n
\nkeeps the original client address (1.9.7)\n
\n\n
$realip_remote_port
\n
\nkeeps the original client port (1.11.0)\n
\n\n

\n

\n\n
\n", "encoding": "utf-8"} +{"path": "en\\docs\\http\\ngx_http_referer_module.html", "extension": ".html", "size_bytes": 8579, "content": "\nModule ngx_http_referer_module
\n\nPlanning your ingress-nginx migration? Start here:\nkubernetes.nginx.org.\n\n

Module ngx_http_referer_module

Example Configuration
Directives
     referer_hash_bucket_size
     referer_hash_max_size
     valid_referers
Embedded Variables
\n\n

\nThe ngx_http_referer_module module is used to block\naccess to a site for requests with invalid values in the\n“Referer” header field.\nIt should be kept in mind that fabricating a request with an appropriate\n“Referer” field value is quite easy, and so the intended\npurpose of this module is not to block such requests thoroughly but to block\nthe mass flow of requests sent by regular browsers.\nIt should also be taken into consideration that regular browsers may\nnot send the “Referer” field even for valid requests.\n

\n\n\n

Example Configuration

\n

\nvalid_referers none blocked server_names\n               *.example.com example.* www.example.org/galleries/\n               ~\\.google\\.;\n\nif ($invalid_referer) {\n    return 403;\n}\n

\n

\n\n\n

Directives

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n referer_hash_bucket_size size;
\n
\n Default:\n \n
referer_hash_bucket_size 64;
\n
\n Context:\n \n server, location
\n

This directive appeared in version 1.0.5.\n

\nSets the bucket size for the valid referers hash tables.\nThe details of setting up hash tables are provided in a separate\ndocument.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n referer_hash_max_size size;
\n
\n Default:\n \n
referer_hash_max_size 2048;
\n
\n Context:\n \n server, location
\n

This directive appeared in version 1.0.5.\n

\nSets the maximum size of the valid referers hash tables.\nThe details of setting up hash tables are provided in a separate\ndocument.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n valid_referers \n none |\n blocked |\n server_names |\n string\n ...;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n server, location
\n

\nSpecifies the “Referer” request header field values\nthat will cause the embedded $invalid_referer variable to\nbe set to an empty string.\nOtherwise, the variable will be set to “1”.\nSearch for a match is case-insensitive.\n

\nParameters can be as follows:\n

\n\n
none
\n
\nthe “Referer” field is missing in the request header;\n
\n\n
blocked
\n
\nthe “Referer” field is present in the request header,\nbut its value has been deleted by a firewall or proxy server;\nsuch values are strings that do not start with\n“http://” or “https://”;\n
\n\n
server_names
\n
\nthe “Referer” request header field contains\none of the server names;\n
\n\n
arbitrary string
\n
\ndefines a server name and an optional URI prefix.\nA server name can have an “*” at the beginning or end.\nDuring the checking, the server’s port in the “Referer” field\nis ignored;\n
\n\n
regular expression
\n
\nthe first symbol should be a “~”.\nIt should be noted that an expression will be matched against\nthe text starting after the “http://”\nor “https://”.\n
\n\n

\n

\nExample:\n

\nvalid_referers none blocked server_names\n               *.example.com example.* www.example.org/galleries/\n               ~\\.google\\.;\n

\n

\n\n\n

Embedded Variables

\n

\n\n
$invalid_referer
\n
\nEmpty string, if the “Referer” request header field\nvalue is considered\nvalid, otherwise “1”.\n
\n\n

\n

\n\n
\n", "encoding": "utf-8"} +{"path": "en\\docs\\http\\ngx_http_rewrite_module.html", "extension": ".html", "size_bytes": 19634, "content": "\nModule ngx_http_rewrite_module
\n\nPlanning your ingress-nginx migration? Start here:\nkubernetes.nginx.org.\n\n

Module ngx_http_rewrite_module

Directives
     break
     if
     return
     rewrite
     rewrite_log
     set
     uninitialized_variable_warn
Internal Implementation
\n\n

\nThe ngx_http_rewrite_module module is used to\nchange request URI using PCRE regular expressions, return redirects, and\nconditionally select configurations.\n

\nThe break, if, return,\nrewrite, and set directives are\nprocessed in the following order:\n

\n

\n\n\n

Directives

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n break;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n server, location, if
\n

\nStops processing the current set of\nngx_http_rewrite_module directives.\n

\nIf a directive is specified inside the\nlocation,\nfurther processing of the request continues in this location.\n

\nExample:\n

\nif ($slow) {\n    limit_rate 10k;\n    break;\n}\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n if (condition) { ... }
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n server, location
\n

\nThe specified condition is evaluated.\nIf true, this module directives specified inside the braces are\nexecuted, and the request is assigned the configuration inside the\nif directive.\nConfigurations inside the if directives are\ninherited from the previous configuration level.\n

\nA condition may be any of the following:\n

\n

\nExamples:\n

\nif ($http_user_agent ~ MSIE) {\n    rewrite ^(.*)$ /msie/$1 break;\n}\n\nif ($http_cookie ~* \"id=([^;]+)(?:;|$)\") {\n    set $id $1;\n}\n\nif ($request_method = POST) {\n    return 405;\n}\n\nif ($slow) {\n    limit_rate 10k;\n}\n\nif ($invalid_referer) {\n    return 403;\n}\n

\n

\nA value of the $invalid_referer embedded variable is set by the\nvalid_referers directive.\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n return code [text];
return code URL;
return URL;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n server, location, if
\n

\nStops processing and returns the specified code to a client.\nThe non-standard code 444 closes a connection without sending\na response header.\n

\nStarting from version 0.8.42, it is possible to specify\neither a redirect URL (for codes 301, 302, 303, 307, and 308)\nor the response body text (for other codes).\nA response body text and redirect URL can contain variables.\nAs a special case, a redirect URL can be specified as a URI\nlocal to this server, in which case the full redirect URL\nis formed according to the request scheme ($scheme) and the\nserver_name_in_redirect and\nport_in_redirect directives.\n

\nIn addition, a URL for temporary redirect with the code 302\ncan be specified as the sole parameter.\nSuch a parameter should start with the “http://”,\n“https://”, or “$scheme” string.\nA URL can contain variables.\n

\n

\nOnly the following codes could be returned before version 0.7.51:\n204, 400, 402 — 406, 408, 410, 411, 413, 416, and 500 — 504.\n

\n\n

\nThe code 307 was not treated as a redirect until versions 1.1.16 and 1.0.13.\n

\n\n

\nThe code 308 was not treated as a redirect until version 1.13.0.\n

\n

\nSee also the error_page directive.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n rewrite \n regex\n replacement\n [flag];
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n server, location, if
\n

\nIf the specified regular expression matches a request URI, URI is changed\nas specified in the replacement string.\nThe rewrite directives are executed sequentially\nin order of their appearance in the configuration file.\nIt is possible to terminate further processing of the directives using flags.\nIf a replacement string starts with “http://”,\n“https://”, or “$scheme”,\nthe processing stops and the redirect is returned to a client.\n

\nAn optional flag parameter can be one of:\n

\n\n
last
\n
\nstops processing the current set of\nngx_http_rewrite_module directives and starts\na search for a new location matching the changed URI;\n
\n\n
break
\n
\nstops processing the current set of\nngx_http_rewrite_module directives\nas with the break directive;\n
\n\n
redirect
\n
\nreturns a temporary redirect with the 302 code;\nused if a replacement string does not start with\n“http://”, “https://”,\nor “$scheme”;\n
\n\n
permanent
\n
\nreturns a permanent redirect with the 301 code.\n
\n\n

\nThe full redirect URL is formed according to the\nrequest scheme ($scheme) and the\nserver_name_in_redirect and\nport_in_redirect directives.\n

\nExample:\n

\nserver {\n    ...\n    rewrite ^(/download/.*)/media/(.*)\\..*$ $1/mp3/$2.mp3 last;\n    rewrite ^(/download/.*)/audio/(.*)\\..*$ $1/mp3/$2.ra  last;\n    return  403;\n    ...\n}\n

\n

\nBut if these directives are put inside the “/download/”\nlocation, the last flag should be replaced by\nbreak, or otherwise nginx will make 10 cycles and\nreturn the 500 error:\n

\nlocation /download/ {\n    rewrite ^(/download/.*)/media/(.*)\\..*$ $1/mp3/$2.mp3 break;\n    rewrite ^(/download/.*)/audio/(.*)\\..*$ $1/mp3/$2.ra  break;\n    return  403;\n}\n

\n

\nIf a replacement string includes the new request arguments,\nthe previous request arguments are appended after them.\nIf this is undesired, putting a question mark at the end of a replacement\nstring avoids having them appended, for example:\n

\nrewrite ^/users/(.*)$ /show?user=$1? last;\n

\n

\nIf a regular expression includes the “}”\nor “;” characters, the whole expressions should be enclosed\nin single or double quotes.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n rewrite_log on | off;
\n
\n Default:\n \n
rewrite_log off;
\n
\n Context:\n \n http, server, location, if
\n

\nEnables or disables logging of ngx_http_rewrite_module\nmodule directives processing results\ninto the error_log at\nthe notice level.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n set $variable value;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n server, location, if
\n

\nSets a value for the specified variable.\nThe value can contain text, variables, and their combination.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n uninitialized_variable_warn on | off;
\n
\n Default:\n \n
uninitialized_variable_warn on;
\n
\n Context:\n \n http, server, location, if
\n

\nControls whether warnings about uninitialized variables are logged.\n

\n\n\n

Internal Implementation

\nThe ngx_http_rewrite_module module directives\nare compiled at the configuration stage into internal instructions\nthat are interpreted during request processing.\nAn interpreter is a simple virtual stack machine.\n

\nFor example, the directives\n

\nlocation /download/ {\n    if ($forbidden) {\n        return 403;\n    }\n\n    if ($slow) {\n        limit_rate 10k;\n    }\n\n    rewrite ^/(download/.*)/media/(.*)\\..*$ /$1/mp3/$2.mp3 break;\n}\n

\nwill be translated into these instructions:\n

\nvariable $forbidden\ncheck against zero\n    return 403\n    end of code\nvariable $slow\ncheck against zero\nmatch of regular expression\ncopy \"/\"\ncopy $1\ncopy \"/mp3/\"\ncopy $2\ncopy \".mp3\"\nend of regular expression\nend of code\n

\n

\nNote that there are no instructions for the\nlimit_rate\ndirective above as it is unrelated to the\nngx_http_rewrite_module module.\nA separate configuration is created for the if block.\nIf the condition holds true, a request is assigned this configuration\nwhere limit_rate equals to 10k.\n

\nThe directive\n

\nrewrite ^/(download/.*)/media/(.*)\\..*$ /$1/mp3/$2.mp3 break;\n

\ncan be made smaller by one instruction if the first slash in the regular expression\nis put inside the parentheses:\n

\nrewrite ^(/download/.*)/media/(.*)\\..*$ $1/mp3/$2.mp3 break;\n

\nThe corresponding instructions will then look like this:\n

\nmatch of regular expression\ncopy $1\ncopy \"/mp3/\"\ncopy $2\ncopy \".mp3\"\nend of regular expression\nend of code\n

\n

\n\n
\n", "encoding": "utf-8"} +{"path": "en\\docs\\http\\ngx_http_scgi_module.html", "extension": ".html", "size_bytes": 82327, "content": "\nModule ngx_http_scgi_module
\n\nPlanning your ingress-nginx migration? Start here:\nkubernetes.nginx.org.\n\n

Module ngx_http_scgi_module

Example Configuration
Directives
     scgi_allow_upstream
     scgi_bind
     scgi_bind_dynamic
     scgi_buffer_size
     scgi_buffering
     scgi_buffers
     scgi_busy_buffers_size
     scgi_cache
     scgi_cache_background_update
     scgi_cache_bypass
     scgi_cache_key
     scgi_cache_lock
     scgi_cache_lock_age
     scgi_cache_lock_timeout
     scgi_cache_max_range_offset
     scgi_cache_methods
     scgi_cache_min_uses
     scgi_cache_path
     scgi_cache_purge
     scgi_cache_revalidate
     scgi_cache_use_stale
     scgi_cache_valid
     scgi_connect_timeout
     scgi_force_ranges
     scgi_hide_header
     scgi_ignore_client_abort
     scgi_ignore_headers
     scgi_intercept_errors
     scgi_limit_rate
     scgi_max_temp_file_size
     scgi_next_upstream
     scgi_next_upstream_timeout
     scgi_next_upstream_tries
     scgi_no_cache
     scgi_param
     scgi_pass
     scgi_pass_header
     scgi_pass_request_body
     scgi_pass_request_headers
     scgi_read_timeout
     scgi_request_buffering
     scgi_request_dynamic
     scgi_send_timeout
     scgi_socket_keepalive
     scgi_store
     scgi_store_access
     scgi_temp_file_write_size
     scgi_temp_path
\n\n

\nThe ngx_http_scgi_module module allows passing\nrequests to an SCGI server.\n

\n\n\n

Example Configuration

\n

\nlocation / {\n    include   scgi_params;\n    scgi_pass localhost:9000;\n}\n

\n

\n\n\n

Directives

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n scgi_allow_upstream string ...;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n http, server, location
\n

This directive appeared in version 1.29.3.\n

\nDefines conditions under which access to an SCGI server\nis allowed or denied.\nIf all string parameters are not empty\nand not equal to “0” then the access is allowed.\nThe conditions are evaluated each time\nbefore a connection to an SCGI server is established.\nParameter values can contain variables:\n

\ngeo $upstream_last_addr $allow {\n    volatile;\n    10.10.0.0/24        1;\n}\n\nserver {\n    listen 127.0.0.1:8080;\n\n    location / {\n        scgi_pass           localhost:9000;\n        scgi_allow_upstream $allow;\n        ...\n    }\n}\n

\n

\n

\nThis directive is available as part of our\ncommercial subscription.\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n scgi_bind \n address\n [transparent] |\n off;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n http, server, location
\n

\nMakes outgoing connections to an SCGI server originate\nfrom the specified local IP address with an optional port (1.11.2).\nParameter value can contain variables (1.3.12).\nThe special value off (1.3.12) cancels the effect\nof the scgi_bind directive\ninherited from the previous configuration level, which allows the\nsystem to auto-assign the local IP address and port.\n

\nThe transparent parameter (1.11.0) allows\noutgoing connections to an SCGI server originate\nfrom a non-local IP address,\nfor example, from a real IP address of a client:\n

\nscgi_bind $remote_addr transparent;\n

\nIn order for this parameter to work,\nit is usually necessary to run nginx worker processes with the\nsuperuser privileges.\nOn Linux it is not required (1.13.8) as if\nthe transparent parameter is specified, worker processes\ninherit the CAP_NET_RAW capability from the master process.\nIt is also necessary to configure kernel routing table\nto intercept network traffic from the SCGI server.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n scgi_bind_dynamic on | off;
\n
\n Default:\n \n
scgi_bind_dynamic off;
\n
\n Context:\n \n http, server, location
\n

This directive appeared in version 1.29.3.\n

\nWhen enabled, makes the bind operation\nat each connection attempt.\n

\n

\nThis directive is available as part of our\ncommercial subscription.\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n scgi_buffer_size size;
\n
\n Default:\n \n
scgi_buffer_size 4k|8k;
\n
\n Context:\n \n http, server, location
\n

\nSets the size of the buffer used for reading the first part\nof the response received from the SCGI server.\nThis part usually contains a small response header;\nif it exceeds the buffer size, the response is considered\ninvalid.\nBy default, the buffer size is equal to one memory page.\nThis is either 4K or 8K, depending on a platform.\nIt can be made smaller, however.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n scgi_buffering on | off;
\n
\n Default:\n \n
scgi_buffering on;
\n
\n Context:\n \n http, server, location
\n

\nEnables or disables buffering of responses from the SCGI server.\n

\nWhen buffering is enabled, nginx receives a response from the SCGI server\nas soon as possible, saving it into the buffers set by the\nscgi_buffer_size and scgi_buffers directives.\nIf the whole response does not fit into memory, a part of it can be saved\nto a temporary file on the disk.\nWriting to temporary files is controlled by the\nscgi_max_temp_file_size and\nscgi_temp_file_write_size directives.\n

\nWhen buffering is disabled, the response is passed to a client synchronously,\nimmediately as it is received.\nnginx will not try to read the whole response from the SCGI server.\nThe maximum size of the data that nginx can receive from the server\nat a time is set by the scgi_buffer_size directive.\n

\nBuffering can also be enabled or disabled by passing\n“yes” or “no” in the\n“X-Accel-Buffering” response header field.\nThis capability can be disabled using the\nscgi_ignore_headers directive.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n scgi_buffers number size;
\n
\n Default:\n \n
scgi_buffers 8 4k|8k;
\n
\n Context:\n \n http, server, location
\n

\nSets the number and size of the\nbuffers used for reading a response from the SCGI server,\nfor a single connection.\nBy default, the buffer size is equal to one memory page.\nThis is either 4K or 8K, depending on a platform.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n scgi_busy_buffers_size size;
\n
\n Default:\n \n
scgi_busy_buffers_size 8k|16k;
\n
\n Context:\n \n http, server, location
\n

\nWhen buffering of responses from the SCGI\nserver is enabled, limits the total size of buffers that\ncan be busy sending a response to the client while the response is not\nyet fully read.\nIn the meantime, the rest of the buffers can be used for reading the response\nand, if needed, buffering part of the response to a temporary file.\nBy default, size is limited by the size of two buffers set by the\nscgi_buffer_size and scgi_buffers directives.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n scgi_cache zone | off;
\n
\n Default:\n \n
scgi_cache off;
\n
\n Context:\n \n http, server, location
\n

\nDefines a shared memory zone used for caching.\nThe same zone can be used in several places.\nParameter value can contain variables (1.7.9).\nThe off parameter disables caching inherited\nfrom the previous configuration level.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n scgi_cache_background_update on | off;
\n
\n Default:\n \n
scgi_cache_background_update off;
\n
\n Context:\n \n http, server, location
\n

This directive appeared in version 1.11.10.\n

\nAllows starting a background subrequest\nto update an expired cache item,\nwhile a stale cached response is returned to the client.\nNote that it is necessary to\nallow\nthe usage of a stale cached response when it is being updated.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n scgi_cache_bypass string ...;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n http, server, location
\n

\nDefines conditions under which the response will not be taken from a cache.\nIf at least one value of the string parameters is not empty and is not\nequal to “0” then the response will not be taken from the cache:\n

\nscgi_cache_bypass $cookie_nocache $arg_nocache$arg_comment;\nscgi_cache_bypass $http_pragma    $http_authorization;\n

\nCan be used along with the scgi_no_cache directive.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n scgi_cache_key string;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n http, server, location
\n

\nDefines a key for caching, for example\n

\nscgi_cache_key localhost:9000$request_uri;\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n scgi_cache_lock on | off;
\n
\n Default:\n \n
scgi_cache_lock off;
\n
\n Context:\n \n http, server, location
\n

This directive appeared in version 1.1.12.\n

\nWhen enabled, only one request at a time will be allowed to populate\na new cache element identified according to the scgi_cache_key\ndirective by passing a request to an SCGI server.\nOther requests of the same cache element will either wait\nfor a response to appear in the cache or the cache lock for\nthis element to be released, up to the time set by the\nscgi_cache_lock_timeout directive.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n scgi_cache_lock_age time;
\n
\n Default:\n \n
scgi_cache_lock_age 5s;
\n
\n Context:\n \n http, server, location
\n

This directive appeared in version 1.7.8.\n

\nIf the last request passed to the SCGI server\nfor populating a new cache element\nhas not completed for the specified time,\none more request may be passed to the SCGI server.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n scgi_cache_lock_timeout time;
\n
\n Default:\n \n
scgi_cache_lock_timeout 5s;
\n
\n Context:\n \n http, server, location
\n

This directive appeared in version 1.1.12.\n

\nSets a timeout for scgi_cache_lock.\nWhen the time expires,\nthe request will be passed to the SCGI server,\nhowever, the response will not be cached.\n

\nBefore 1.7.8, the response could be cached.\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n scgi_cache_max_range_offset number;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n http, server, location
\n

This directive appeared in version 1.11.6.\n

\nSets an offset in bytes for byte-range requests.\nIf the range is beyond the offset,\nthe range request will be passed to the SCGI server\nand the response will not be cached.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n scgi_cache_methods \n GET |\n HEAD |\n POST\n ...;
\n
\n Default:\n \n
scgi_cache_methods GET HEAD;
\n
\n Context:\n \n http, server, location
\n

\nIf the client request method is listed in this directive then\nthe response will be cached.\n“GET” and “HEAD” methods are always\nadded to the list, though it is recommended to specify them explicitly.\nSee also the scgi_no_cache directive.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n scgi_cache_min_uses number;
\n
\n Default:\n \n
scgi_cache_min_uses 1;
\n
\n Context:\n \n http, server, location
\n

\nSets the number of requests after which the response\nwill be cached.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n scgi_cache_path \n path\n [levels=levels]\n [use_temp_path=on|off]\n keys_zone=name:size\n [inactive=time]\n [max_size=size]\n [min_free=size]\n [manager_files=number]\n [manager_sleep=time]\n [manager_threshold=time]\n [loader_files=number]\n [loader_sleep=time]\n [loader_threshold=time]\n [purger=on|off]\n [purger_files=number]\n [purger_sleep=time]\n [purger_threshold=time];
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n http
\n

\nSets the path and other parameters of a cache.\nCache data are stored in files.\nThe file name in a cache is a result of\napplying the MD5 function to the\ncache key.\nThe levels parameter defines hierarchy levels of a cache:\nfrom 1 to 3, each level accepts values 1 or 2.\nFor example, in the following configuration\n

\nscgi_cache_path /data/nginx/cache levels=1:2 keys_zone=one:10m;\n

\nfile names in a cache will look like this:\n

\n/data/nginx/cache/c/29/b7f54b2df7773722d382f4809d65029c\n

\n

\nA cached response is first written to a temporary file,\nand then the file is renamed.\nStarting from version 0.8.9, temporary files and the cache can be put on\ndifferent file systems.\nHowever, be aware that in this case a file is copied\nacross two file systems instead of the cheap renaming operation.\nIt is thus recommended that for any given location both cache and a directory\nholding temporary files\nare put on the same file system.\nA directory for temporary files is set based on\nthe use_temp_path parameter (1.7.10).\nIf this parameter is omitted or set to the value on,\nthe directory set by the scgi_temp_path directive\nfor the given location will be used.\nIf the value is set to off,\ntemporary files will be put directly in the cache directory.\n

\nIn addition, all active keys and information about data are stored\nin a shared memory zone, whose name and size\nare configured by the keys_zone parameter.\nOne megabyte zone can store about 8 thousand keys.\n

\nAs part of\ncommercial subscription,\nthe shared memory zone also stores extended\ncache information,\nthus, it is required to specify a larger zone size for the same number of keys.\nFor example,\none megabyte zone can store about 4 thousand keys.\n

\n

\nCached data that are not accessed during the time specified by the\ninactive parameter get removed from the cache\nregardless of their freshness.\nBy default, inactive is set to 10 minutes.\n

\nThe special “cache manager” process monitors the maximum cache size set\nby the max_size parameter,\nand the minimum amount of free space set\nby the min_free (1.19.1) parameter\non the file system with cache.\nWhen the size is exceeded or there is not enough free space,\nit removes the least recently used data.\nThe data is removed in iterations configured by\nmanager_files,\nmanager_threshold, and\nmanager_sleep parameters (1.11.5).\nDuring one iteration no more than manager_files items\nare deleted (by default, 100).\nThe duration of one iteration is limited by the\nmanager_threshold parameter (by default, 200 milliseconds).\nBetween iterations, a pause configured by the manager_sleep\nparameter (by default, 50 milliseconds) is made.\n

\nA minute after the start the special “cache loader” process is activated.\nIt loads information about previously cached data stored on file system\ninto a cache zone.\nThe loading is also done in iterations.\nDuring one iteration no more than loader_files items\nare loaded (by default, 100).\nBesides, the duration of one iteration is limited by the\nloader_threshold parameter (by default, 200 milliseconds).\nBetween iterations, a pause configured by the loader_sleep\nparameter (by default, 50 milliseconds) is made.\n

\nAdditionally,\nthe following parameters are available as part of our\ncommercial subscription:\n

\n

\n\n
\npurger=on|off\n
\n
\nInstructs whether cache entries that match a\nwildcard key\nwill be removed from the disk by the cache purger (1.7.12).\nSetting the parameter to on\n(default is off)\nwill activate the “cache purger” process that\npermanently iterates through all cache entries\nand deletes the entries that match the wildcard key.\n
\n\n
\npurger_files=number\n
\n
\nSets the number of items that will be scanned during one iteration (1.7.12).\nBy default, purger_files is set to 10.\n
\n\n
\npurger_threshold=number\n
\n
\nSets the duration of one iteration (1.7.12).\nBy default, purger_threshold is set to 50 milliseconds.\n
\n\n
\npurger_sleep=number\n
\n
\nSets a pause between iterations (1.7.12).\nBy default, purger_sleep is set to 50 milliseconds.\n
\n\n

\n

\n

\nIn versions 1.7.3, 1.7.7, and 1.11.10 cache header format has been changed.\nPreviously cached responses will be considered invalid\nafter upgrading to a newer nginx version.\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n scgi_cache_purge string ...;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n http, server, location
\n

This directive appeared in version 1.5.7.\n

\nDefines conditions under which the request will be considered a cache\npurge request.\nIf at least one value of the string parameters is not empty and is not equal\nto “0” then the cache entry with a corresponding\ncache key is removed.\nThe result of successful operation is indicated by returning\nthe 204 (No Content) response.\n

\nIf the cache key of a purge request ends\nwith an asterisk (“*”), all cache entries matching the\nwildcard key will be removed from the cache.\nHowever, these entries will remain on the disk until they are deleted\nfor either inactivity,\nor processed by the cache purger (1.7.12),\nor a client attempts to access them.\n

\nExample configuration:\n

\nscgi_cache_path /data/nginx/cache keys_zone=cache_zone:10m;\n\nmap $request_method $purge_method {\n    PURGE   1;\n    default 0;\n}\n\nserver {\n    ...\n    location / {\n        scgi_pass        backend;\n        scgi_cache       cache_zone;\n        scgi_cache_key   $uri;\n        scgi_cache_purge $purge_method;\n    }\n}\n

\n

\nThis functionality is available as part of our\ncommercial subscription.\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n scgi_cache_revalidate on | off;
\n
\n Default:\n \n
scgi_cache_revalidate off;
\n
\n Context:\n \n http, server, location
\n

This directive appeared in version 1.5.7.\n

\nEnables revalidation of expired cache items using conditional requests with\nthe “If-Modified-Since” and “If-None-Match”\nheader fields.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n scgi_cache_use_stale \n error |\n timeout |\n invalid_header |\n updating |\n http_500 |\n http_503 |\n http_403 |\n http_404 |\n http_429 |\n off\n ...;
\n
\n Default:\n \n
scgi_cache_use_stale off;
\n
\n Context:\n \n http, server, location
\n

\nDetermines in which cases a stale cached response can be used\nwhen an error occurs during communication with the SCGI server.\nThe directive’s parameters match the parameters of the\nscgi_next_upstream directive.\n

\nThe error parameter also permits\nusing a stale cached response if an SCGI server to process a request\ncannot be selected.\n

\nAdditionally, the updating parameter permits\nusing a stale cached response if it is currently being updated.\nThis allows minimizing the number of accesses to SCGI servers\nwhen updating cached data.\n

\nUsing a stale cached response\ncan also be enabled directly in the response header\nfor a specified number of seconds after the response became stale (1.11.10).\nThis has lower priority than using the directive parameters.\n

\n

\nTo minimize the number of accesses to SCGI servers when\npopulating a new cache element, the scgi_cache_lock\ndirective can be used.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n scgi_cache_valid [code ...] time;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n http, server, location
\n

\nSets caching time for different response codes.\nFor example, the following directives\n

\nscgi_cache_valid 200 302 10m;\nscgi_cache_valid 404      1m;\n

\nset 10 minutes of caching for responses with codes 200 and 302\nand 1 minute for responses with code 404.\n

\nIf only caching time is specified\n

\nscgi_cache_valid 5m;\n

\nthen only 200, 301, and 302 responses are cached.\n

\nIn addition, the any parameter can be specified\nto cache any responses:\n

\nscgi_cache_valid 200 302 10m;\nscgi_cache_valid 301      1h;\nscgi_cache_valid any      1m;\n

\n

\nParameters of caching can also be set directly\nin the response header.\nThis has higher priority than setting of caching time using the directive.\n

\nProcessing of one or more of these response header fields can be disabled\nusing the scgi_ignore_headers directive.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n scgi_connect_timeout time;
\n
\n Default:\n \n
scgi_connect_timeout 60s;
\n
\n Context:\n \n http, server, location
\n

\nDefines a timeout for establishing a connection with an SCGI server.\nIt should be noted that this timeout cannot usually exceed 75 seconds.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n scgi_force_ranges on | off;
\n
\n Default:\n \n
scgi_force_ranges off;
\n
\n Context:\n \n http, server, location
\n

This directive appeared in version 1.7.7.\n

\nEnables byte-range support\nfor both cached and uncached responses from the SCGI server\nregardless of the “Accept-Ranges” field in these responses.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n scgi_hide_header field;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n http, server, location
\n

\nBy default,\nnginx does not pass the header fields “Status” and\n“X-Accel-...” from the response of an SCGI\nserver to a client.\nThe scgi_hide_header directive sets additional fields\nthat will not be passed.\nIf, on the contrary, the passing of fields needs to be permitted,\nthe scgi_pass_header directive can be used.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n scgi_ignore_client_abort on | off;
\n
\n Default:\n \n
scgi_ignore_client_abort off;
\n
\n Context:\n \n http, server, location
\n

\nDetermines whether the connection with an SCGI server should be\nclosed when a client closes the connection without waiting\nfor a response.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n scgi_ignore_headers field ...;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n http, server, location
\n

\nDisables processing of certain response header fields from the SCGI server.\nThe following fields can be ignored: “X-Accel-Redirect”,\n“X-Accel-Expires”, “X-Accel-Limit-Rate” (1.1.6),\n“X-Accel-Buffering” (1.1.6),\n“X-Accel-Charset” (1.1.6), “Expires”,\n“Cache-Control”, “Set-Cookie” (0.8.44),\nand “Vary” (1.7.7).\n

\nIf not disabled, processing of these header fields has the following\neffect:\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n scgi_intercept_errors on | off;
\n
\n Default:\n \n
scgi_intercept_errors off;
\n
\n Context:\n \n http, server, location
\n

\nDetermines whether an SCGI server responses with codes greater than or equal\nto 300 should be passed to a client\nor be intercepted and redirected to nginx for processing\nwith the error_page directive.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n scgi_limit_rate rate;
\n
\n Default:\n \n
scgi_limit_rate 0;
\n
\n Context:\n \n http, server, location
\n

This directive appeared in version 1.7.7.\n

\nLimits the speed of reading the response from the SCGI server.\nThe rate is specified in bytes per second.\nThe zero value disables rate limiting.\nThe limit is set per a request, and so if nginx simultaneously opens\ntwo connections to the SCGI server,\nthe overall rate will be twice as much as the specified limit.\nThe limitation works only if\nbuffering of responses from the SCGI\nserver is enabled.\nParameter value can contain variables (1.27.0).\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n scgi_max_temp_file_size size;
\n
\n Default:\n \n
scgi_max_temp_file_size 1024m;
\n
\n Context:\n \n http, server, location
\n

\nWhen buffering of responses from the SCGI\nserver is enabled, and the whole response does not fit into the buffers\nset by the scgi_buffer_size and scgi_buffers\ndirectives, a part of the response can be saved to a temporary file.\nThis directive sets the maximum size of the temporary file.\nThe size of data written to the temporary file at a time is set\nby the scgi_temp_file_write_size directive.\n

\nThe zero value disables buffering of responses to temporary files.\n

\n

\nThis restriction does not apply to responses\nthat will be cached\nor stored on disk.\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n scgi_next_upstream \n error |\n timeout |\n denied |\n invalid_header |\n http_500 |\n http_503 |\n http_403 |\n http_404 |\n http_429 |\n non_idempotent |\n off\n ...;
\n
\n Default:\n \n
scgi_next_upstream error timeout;
\n
\n Context:\n \n http, server, location
\n

\nSpecifies in which cases a request should be passed to the next server:\n

\n\n
error
\n
an error occurred while establishing a connection with the\nserver, passing a request to it, or reading the response header;
\n\n
timeout
\n
a timeout has occurred while establishing a connection with the\nserver, passing a request to it, or reading the response header;
\n\n
denied
\n
the server denied\nthe connection (1.29.3);\n

\n

\nThis parameter is available as part of our\ncommercial subscription.\n

\n

\n
\n\n
invalid_header
\n
a server returned an empty or invalid response;
\n\n
http_500
\n
a server returned a response with the code 500;
\n\n
http_503
\n
a server returned a response with the code 503;
\n\n
http_403
\n
a server returned a response with the code 403;
\n\n
http_404
\n
a server returned a response with the code 404;
\n\n
http_429
\n
a server returned a response with the code 429 (1.11.13);
\n\n
non_idempotent
\n
normally, requests with a\nnon-idempotent\nmethod\n(POST, LOCK, PATCH)\nare not passed to the next server\nif a request has been sent to an upstream server (1.9.13);\nenabling this option explicitly allows retrying such requests;\n
\n\n
off
\n
disables passing a request to the next server.
\n\n

\n

\nOne should bear in mind that passing a request to the next server is\nonly possible if nothing has been sent to a client yet.\nThat is, if an error or timeout occurs in the middle of the\ntransferring of a response, fixing this is impossible.\n

\nThe directive also defines what is considered an\nunsuccessful\nattempt of communication with a server.\nThe cases of error, timeout,\ndenied and\ninvalid_header are always considered unsuccessful attempts,\neven if they are not specified in the directive.\nThe cases of http_500, http_503,\nand http_429 are\nconsidered unsuccessful attempts only if they are specified in the directive.\nThe cases of http_403 and http_404\nare never considered unsuccessful attempts.\n

\nPassing a request to the next server can be limited by\nthe number of tries\nand by time.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n scgi_next_upstream_timeout time;
\n
\n Default:\n \n
scgi_next_upstream_timeout 0;
\n
\n Context:\n \n http, server, location
\n

This directive appeared in version 1.7.5.\n

\nLimits the time during which a request can be passed to the\nnext server.\nThe 0 value turns off this limitation.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n scgi_next_upstream_tries number;
\n
\n Default:\n \n
scgi_next_upstream_tries 0;
\n
\n Context:\n \n http, server, location
\n

This directive appeared in version 1.7.5.\n

\nLimits the number of possible tries for passing a request to the\nnext server.\nThe 0 value turns off this limitation.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n scgi_no_cache string ...;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n http, server, location
\n

\nDefines conditions under which the response will not be saved to a cache.\nIf at least one value of the string parameters is not empty and is not\nequal to “0” then the response will not be saved:\n

\nscgi_no_cache $cookie_nocache $arg_nocache$arg_comment;\nscgi_no_cache $http_pragma    $http_authorization;\n

\nCan be used along with the scgi_cache_bypass directive.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n scgi_param \n parameter value\n [if_not_empty];
\n
\n Default:\n \n
scgi_param HTTP_HOST $host$is_request_port$request_port;
\n
\n Context:\n \n http, server, location
\n

\nSets a parameter that should be passed to the SCGI server.\nThe value can contain text, variables, and their combination.\nThese directives are inherited from the previous configuration level\nif and only if there are no scgi_param directives\ndefined on the current level.\n

\nStandard\nCGI\nenvironment variables\nshould be provided as SCGI headers, see the scgi_params file\nprovided in the distribution:\n

\nlocation / {\n    include scgi_params;\n    ...\n}\n

\n

\nIf the directive is specified with if_not_empty (1.1.11) then\nsuch a parameter will be passed to the server only if its value is not empty:\n

\nscgi_param HTTPS $https if_not_empty;\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n scgi_pass address;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n location, if in location
\n

\nSets the address of an SCGI server.\nThe address can be specified as a domain name or IP address,\nand a port:\n

\nscgi_pass localhost:9000;\n

\nor as a UNIX-domain socket path:\n

\nscgi_pass unix:/tmp/scgi.socket;\n

\n

\nIf a domain name resolves to several addresses, all of them will be\nused in a round-robin fashion.\nIn addition, an address can be specified as a\nserver group.\n

\nParameter value can contain variables.\nIn this case, if an address is specified as a domain name,\nthe name is searched among the described\nserver groups,\nand, if not found, is determined using a\nresolver.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n scgi_pass_header field;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n http, server, location
\n

\nPermits passing otherwise disabled header\nfields from an SCGI server to a client.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n scgi_pass_request_body on | off;
\n
\n Default:\n \n
scgi_pass_request_body on;
\n
\n Context:\n \n http, server, location
\n

\nIndicates whether the original request body is passed\nto the SCGI server.\nSee also the scgi_pass_request_headers directive.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n scgi_pass_request_headers on | off;
\n
\n Default:\n \n
scgi_pass_request_headers on;
\n
\n Context:\n \n http, server, location
\n

\nIndicates whether the header fields of the original request are passed\nto the SCGI server.\nSee also the scgi_pass_request_body directive.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n scgi_read_timeout time;
\n
\n Default:\n \n
scgi_read_timeout 60s;
\n
\n Context:\n \n http, server, location
\n

\nDefines a timeout for reading a response from the SCGI server.\nThe timeout is set only between two successive read operations,\nnot for the transmission of the whole response.\nIf the SCGI server does not transmit anything within this time,\nthe connection is closed.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n scgi_request_buffering on | off;
\n
\n Default:\n \n
scgi_request_buffering on;
\n
\n Context:\n \n http, server, location
\n

This directive appeared in version 1.7.11.\n

\nEnables or disables buffering of a client request body.\n

\nWhen buffering is enabled, the entire request body is\nread\nfrom the client before sending the request to an SCGI server.\n

\nWhen buffering is disabled, the request body is sent to the SCGI server\nimmediately as it is received.\nIn this case, the request cannot be passed to the\nnext server\nif nginx already started sending the request body.\n

\nWhen HTTP/1.1 chunked transfer encoding is used\nto send the original request body,\nthe request body will be buffered regardless of the directive value.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n scgi_request_dynamic on | off;
\n
\n Default:\n \n
scgi_request_dynamic off;
\n
\n Context:\n \n http, server, location
\n

This directive appeared in version 1.29.3.\n

\nEnables or disables creation of a separate request instance\nfor each SCGI server.\nBy default, a single request is used for all SCGI servers.\nIf enabled, a separate request instance is created,\nallowing per-server request customization.\n

\n

\nThis directive is available as part of our\ncommercial subscription.\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n scgi_send_timeout time;
\n
\n Default:\n \n
scgi_send_timeout 60s;
\n
\n Context:\n \n http, server, location
\n

\nSets a timeout for transmitting a request to the SCGI server.\nThe timeout is set only between two successive write operations,\nnot for the transmission of the whole request.\nIf the SCGI server does not receive anything within this time,\nthe connection is closed.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n scgi_socket_keepalive on | off;
\n
\n Default:\n \n
scgi_socket_keepalive off;
\n
\n Context:\n \n http, server, location
\n

This directive appeared in version 1.15.6.\n

\nConfigures the “TCP keepalive” behavior\nfor outgoing connections to an SCGI server.\nBy default, the operating system’s settings are in effect for the socket.\nIf the directive is set to the value “on”, the\nSO_KEEPALIVE socket option is turned on for the socket.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n scgi_store \n on |\n off |\n string;
\n
\n Default:\n \n
scgi_store off;
\n
\n Context:\n \n http, server, location
\n

\nEnables saving of files to a disk.\nThe on parameter saves files with paths\ncorresponding to the directives\nalias or\nroot.\nThe off parameter disables saving of files.\nIn addition, the file name can be set explicitly using the\nstring with variables:\n

\nscgi_store /data/www$original_uri;\n

\n

\nThe modification time of files is set according to the received\n“Last-Modified” response header field.\nThe response is first written to a temporary file,\nand then the file is renamed.\nStarting from version 0.8.9, temporary files and the persistent store\ncan be put on different file systems.\nHowever, be aware that in this case a file is copied\nacross two file systems instead of the cheap renaming operation.\nIt is thus recommended that for any given location both saved files and a\ndirectory holding temporary files, set by the scgi_temp_path\ndirective, are put on the same file system.\n

\nThis directive can be used to create local copies of static unchangeable\nfiles, e.g.:\n

\nlocation /images/ {\n    root              /data/www;\n    error_page        404 = /fetch$uri;\n}\n\nlocation /fetch/ {\n    internal;\n\n    scgi_pass         backend:9000;\n    ...\n\n    scgi_store        on;\n    scgi_store_access user:rw group:rw all:r;\n    scgi_temp_path    /data/temp;\n\n    alias             /data/www/;\n}\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n scgi_store_access users:permissions ...;
\n
\n Default:\n \n
scgi_store_access user:rw;
\n
\n Context:\n \n http, server, location
\n

\nSets access permissions for newly created files and directories, e.g.:\n

\nscgi_store_access user:rw group:rw all:r;\n

\n

\nIf any group or all access permissions\nare specified then user permissions may be omitted:\n

\nscgi_store_access group:rw all:r;\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n scgi_temp_file_write_size size;
\n
\n Default:\n \n
scgi_temp_file_write_size 8k|16k;
\n
\n Context:\n \n http, server, location
\n

\nLimits the size of data written to a temporary file\nat a time, when buffering of responses from the SCGI server\nto temporary files is enabled.\nBy default, size is limited by two buffers set by the\nscgi_buffer_size and scgi_buffers directives.\nThe maximum size of a temporary file is set by the\nscgi_max_temp_file_size directive.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n scgi_temp_path \n path\n [level1\n [level2\n [level3]]];
\n
\n Default:\n \n
scgi_temp_path scgi_temp;
\n
\n Context:\n \n http, server, location
\n

\nDefines a directory for storing temporary files\nwith data received from SCGI servers.\nUp to three-level subdirectory hierarchy can be used underneath the specified\ndirectory.\nFor example, in the following configuration\n

\nscgi_temp_path /spool/nginx/scgi_temp 1 2;\n

\na temporary file might look like this:\n

\n/spool/nginx/scgi_temp/7/45/00000123457\n

\n

\nSee also the use_temp_path parameter of the\nscgi_cache_path directive.\n

\n\n
\n", "encoding": "utf-8"} +{"path": "en\\docs\\http\\ngx_http_secure_link_module.html", "extension": ".html", "size_bytes": 10964, "content": "\nModule ngx_http_secure_link_module
\n\nPlanning your ingress-nginx migration? Start here:\nkubernetes.nginx.org.\n\n

Module ngx_http_secure_link_module

Directives
     secure_link
     secure_link_md5
     secure_link_secret
Embedded Variables
\n\n

\nThe ngx_http_secure_link_module module (0.7.18)\nis used to check authenticity of requested links,\nprotect resources from unauthorized access,\nand limit link lifetime.\n

\nThe authenticity of a requested link is verified by comparing the\nchecksum value passed in a request with the value computed\nfor the request.\nIf a link has a limited lifetime and the time has expired,\nthe link is considered outdated.\nThe status of these checks is made available in the\n$secure_link variable.\n

\nThe module provides two alternative operation modes.\nThe first mode is enabled by the secure_link_secret\ndirective and is used to check authenticity of requested links\nas well as protect resources from unauthorized access.\nThe second mode (0.8.50) is enabled by the\nsecure_link and secure_link_md5\ndirectives and is also used to limit lifetime of links.\n

\nThis module is not built by default, it should be enabled with the\n--with-http_secure_link_module\nconfiguration parameter.\n

\n\n\n

Directives

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n secure_link expression;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n http, server, location
\n

\nDefines a string with variables from which the\nchecksum value and lifetime of a link will be extracted.\n

\nVariables used in an expression are usually associated\nwith a request; see example below.\n

\nThe checksum value extracted from the string is compared with\nthe MD5 hash value of the expression defined by the\nsecure_link_md5 directive.\nIf the checksums are different, the $secure_link variable\nis set to an empty string.\nIf the checksums are the same, the link lifetime is checked.\nIf the link has a limited lifetime and the time has expired,\nthe $secure_link variable is set to “0”.\nOtherwise, it is set to “1”.\nThe MD5 hash value passed in a request is encoded in\nbase64url.\n

\nIf a link has a limited lifetime, the expiration time\nis set in seconds since Epoch (Thu, 01 Jan 1970 00:00:00 GMT).\nThe value is specified in the expression after the MD5 hash,\nand is separated by a comma.\nThe expiration time passed in a request is available through\nthe $secure_link_expires variable for a use in\nthe secure_link_md5 directive.\nIf the expiration time is not specified, a link has the unlimited\nlifetime.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n secure_link_md5 expression;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n http, server, location
\n

\nDefines an expression for which the MD5 hash value will\nbe computed and compared with the value passed in a request.\n

\nThe expression should contain the secured part of a link (resource)\nand a secret ingredient.\nIf the link has a limited lifetime,\nthe expression should also contain $secure_link_expires.\n

\nTo prevent unauthorized access, the expression may contain some\ninformation about the client, such as its address and browser version.\n

\nExample:\n

\nlocation /s/ {\n    secure_link $arg_md5,$arg_expires;\n    secure_link_md5 \"$secure_link_expires$uri$remote_addr secret\";\n\n    if ($secure_link = \"\") {\n        return 403;\n    }\n\n    if ($secure_link = \"0\") {\n        return 410;\n    }\n\n    ...\n}\n

\nThe\n“/s/link?md5=_e4Nc3iduzkWRm01TBBNYw&expires=2147483647”\nlink\nrestricts access to “/s/link” for the client with the\nIP address 127.0.0.1.\nThe link also has the limited lifetime until January 19, 2038 (GMT).\n

\nOn UNIX, the md5 request argument value can be obtained as:\n

\necho -n '2147483647/s/link127.0.0.1 secret' | \\\n    openssl md5 -binary | openssl base64 | tr +/ -_ | tr -d =\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n secure_link_secret word;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n location
\n

\nDefines a secret word used to check authenticity\nof requested links.\n

\nThe full URI of a requested link looks as follows:\n

\n/prefix/hash/link\n

\nwhere hash is a hexadecimal representation of the\nMD5 hash computed for the concatenation of the link and secret word,\nand prefix is an arbitrary string without slashes.\n

\nIf the requested link passes the authenticity check,\nthe $secure_link variable is set to the link\nextracted from the request URI.\nOtherwise, the $secure_link variable\nis set to an empty string.\n

\nExample:\n

\nlocation /p/ {\n    secure_link_secret secret;\n\n    if ($secure_link = \"\") {\n        return 403;\n    }\n\n    rewrite ^ /secure/$secure_link;\n}\n\nlocation /secure/ {\n    internal;\n}\n

\nA request of “/p/5e814704a28d9bc1914ff19fa0c4a00a/link”\nwill be internally redirected to\n“/secure/link”.\n

\nOn UNIX, the hash value for this example can be obtained as:\n

\necho -n 'linksecret' | openssl md5 -hex\n

\n

\n\n\n

Embedded Variables

\n

\n\n
$secure_link
\n
\nThe status of a link check.\nThe specific value depends on the selected operation mode.\n
\n\n\n
\nThe lifetime of a link passed in a request;\nintended to be used only in the\nsecure_link_md5 directive.\n
\n\n

\n

\n\n
\n", "encoding": "utf-8"} +{"path": "en\\docs\\http\\ngx_http_session_log_module.html", "extension": ".html", "size_bytes": 8388, "content": "\nModule ngx_http_session_log_module
\n\nPlanning your ingress-nginx migration? Start here:\nkubernetes.nginx.org.\n\n

Module ngx_http_session_log_module

Example Configuration
Directives
     session_log
     session_log_format
     session_log_zone
Embedded Variables
\n\n

\nThe ngx_http_session_log_module module enables logging\nsessions (that is, aggregates of multiple HTTP requests) instead of\nindividual HTTP requests.\n

\n

\nThis module is available as part of our\ncommercial subscription.\n

\n

\n\n\n

Example Configuration

\nThe following configuration sets up a session log and maps requests to\nsessions according to the request client address and “User-Agent”\nrequest header field:\n

\n    session_log_zone /path/to/log format=combined\n                     zone=one:1m timeout=30s\n                     md5=$binary_remote_addr$http_user_agent;\n\n    location /media/ {\n        session_log one;\n    }\n

\n

\n\n\n

Directives

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n session_log name | off;
\n
\n Default:\n \n
session_log off;
\n
\n Context:\n \n http, server, location
\n

\nEnables the use of the specified session log.\nThe special value off cancels the effect\nof the session_log directives\ninherited from the previous configuration level.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n session_log_format \n name\n string ...;
\n
\n Default:\n \n
session_log_format combined \"...\";
\n
\n Context:\n \n http
\n

\nSpecifies the output format of a log.\nThe value of the $body_bytes_sent variable is aggregated across\nall requests in a session.\nThe values of all other variables available for logging correspond to the\nfirst request in a session.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n session_log_zone \n path\n zone=name:size\n [format=format]\n [timeout=time]\n [id=id]\n [md5=md5]\n;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n http
\n

\nSets the path to a log file and configures the shared memory zone that is used\nto store currently active sessions.\n

\nA session is considered active for as long as the time elapsed since\nthe last request in the session does not exceed the specified\ntimeout (by default, 30 seconds).\nOnce a session is no longer active, it is written to the log.\n

\nThe id parameter identifies the\nsession to which a request is mapped.\nThe id parameter is set to the hexadecimal representation\nof an MD5 hash (for example, obtained from a cookie using variables).\nIf this parameter is not specified or does not represent the valid\nMD5 hash, nginx computes the MD5 hash from the value of\nthe md5 parameter and creates a new session using this hash.\nBoth the id and md5 parameters\ncan contain variables.\n

\nThe format parameter sets the custom session log\nformat configured by the session_log_format directive.\nIf format is not specified, the predefined\n“combined” format is used.\n

\n\n\n

Embedded Variables

\nThe ngx_http_session_log_module module supports\ntwo embedded variables:\n\n

\n\n
$session_log_id
\n
\ncurrent session ID;\n
\n\n
$session_log_binary_id\n
\n
\ncurrent session ID in binary form (16 bytes).\n
\n\n

\n

\n\n
\n", "encoding": "utf-8"} +{"path": "en\\docs\\http\\ngx_http_slice_module.html", "extension": ".html", "size_bytes": 5880, "content": "\nModule ngx_http_slice_module
\n\nPlanning your ingress-nginx migration? Start here:\nkubernetes.nginx.org.\n\n

Module ngx_http_slice_module

Known Issues
Example Configuration
Directives
     slice
Embedded Variables
\n\n

\nThe ngx_http_slice_module module (1.9.8) is a filter\nthat splits a request into subrequests,\neach returning a certain range of response.\nThe filter provides more effective caching of big responses.\n

\nThis module is not built by default, it should be enabled with the\n--with-http_slice_module\nconfiguration parameter.\n

\n\n\n

Known Issues

\nCurrently, the module does not work as expected in subrequests such as\n\nbackground cache update.\nIn this case, a request is constructed without byte-range support.\n

\n\n\n

Example Configuration

\n

\nlocation / {\n    slice             1m;\n    proxy_cache       cache;\n    proxy_cache_key   $uri$is_args$args$slice_range;\n    proxy_set_header  Range $slice_range;\n    proxy_cache_valid 200 206 1h;\n    proxy_pass        http://localhost:8000;\n}\n

\nIn this example,\nthe response is split into 1-megabyte cacheable slices.\n

\n\n\n

Directives

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n slice size;
\n
\n Default:\n \n
slice 0;
\n
\n Context:\n \n http, server, location
\n

\nSets the size of the slice.\nThe zero value disables splitting responses into slices.\nNote that a too low value may result in excessive memory usage\nand opening a large number of files.\n

\nIn order for a subrequest to return the required range,\nthe $slice_range variable should be\npassed to\nthe proxied server as the Range request header field.\nIf\ncaching\nis enabled, $slice_range should be added to the\ncache key\nand caching of responses with 206 status code should be\nenabled.\n

\n\n\n

Embedded Variables

\nThe ngx_http_slice_module module\nsupports the following embedded variables:\n

\n\n
$slice_range
\n
\nthe current slice range in\nHTTP\nbyte range format,\nfor example, bytes=0-1048575.\n
\n\n

\n

\n\n
\n", "encoding": "utf-8"} +{"path": "en\\docs\\http\\ngx_http_split_clients_module.html", "extension": ".html", "size_bytes": 4672, "content": "\nModule ngx_http_split_clients_module
\n\nPlanning your ingress-nginx migration? Start here:\nkubernetes.nginx.org.\n\n

Module ngx_http_split_clients_module

Example Configuration
Directives
     split_clients
\n\n

\nThe ngx_http_split_clients_module module creates\nvariables suitable for A/B testing, also known as split testing.\n

\n\n\n

Example Configuration

\n

\nhttp {\n    split_clients \"${remote_addr}AAA\" $variant {\n                   0.5%               .one;\n                   2.0%               .two;\n                   *                  \"\";\n    }\n\n    server {\n        location / {\n            index index${variant}.html;\n

\n

\n\n\n

Directives

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n split_clients \n string\n $variable { ... }
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n http
\n

\nCreates a variable for A/B testing, for example:\n

\nsplit_clients \"${remote_addr}AAA\" $variant {\n               0.5%               .one;\n               2.0%               .two;\n               *                  \"\";\n}\n

\nThe value of the original string is hashed using MurmurHash2.\nIn the example given, hash values from 0 to 21474835 (0.5%)\ncorrespond to the\nvalue \".one\" of the $variant variable,\nhash values from 21474836 to 107374180 (2%) correspond to\nthe value \".two\",\nand hash values from 107374181 to 4294967295 correspond to\nthe value \"\" (an empty string).\n

\n\n
\n", "encoding": "utf-8"} +{"path": "en\\docs\\http\\ngx_http_ssi_module.html", "extension": ".html", "size_bytes": 17310, "content": "\nModule ngx_http_ssi_module
\n\nPlanning your ingress-nginx migration? Start here:\nkubernetes.nginx.org.\n\n

Module ngx_http_ssi_module

Example Configuration
Directives
     ssi
     ssi_last_modified
     ssi_min_file_chunk
     ssi_silent_errors
     ssi_types
     ssi_value_length
SSI Commands
Embedded Variables
\n\n

\nThe ngx_http_ssi_module module is a filter\nthat processes SSI (Server Side Includes) commands in responses\npassing through it.\nCurrently, the list of supported SSI commands is incomplete.\n

\n\n\n

Example Configuration

\n

\nlocation / {\n    ssi on;\n    ...\n}\n

\n

\n\n\n

Directives

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n ssi on | off;
\n
\n Default:\n \n
ssi off;
\n
\n Context:\n \n http, server, location, if in location
\n

\nEnables or disables processing of SSI commands in responses.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n ssi_last_modified on | off;
\n
\n Default:\n \n
ssi_last_modified off;
\n
\n Context:\n \n http, server, location
\n

This directive appeared in version 1.5.1.\n

\nAllows preserving the “Last-Modified” header field\nfrom the original response during SSI processing\nto facilitate response caching.\n

\nBy default, the header field is removed as contents of the response\nare modified during processing and may contain dynamically generated elements\nor parts that are changed independently of the original response.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n ssi_min_file_chunk size;
\n
\n Default:\n \n
ssi_min_file_chunk 1k;
\n
\n Context:\n \n http, server, location
\n

\nSets the minimum size for parts of a response stored on disk,\nstarting from which it makes sense to send them using\nsendfile.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n ssi_silent_errors on | off;
\n
\n Default:\n \n
ssi_silent_errors off;
\n
\n Context:\n \n http, server, location
\n

\nIf enabled, suppresses the output of the\n“[an error occurred while processing the directive]”\nstring if an error occurred during SSI processing.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n ssi_types mime-type ...;
\n
\n Default:\n \n
ssi_types text/html;
\n
\n Context:\n \n http, server, location
\n

\nEnables processing of SSI commands in responses with the specified MIME types\nin addition to “text/html”.\nThe special value “*” matches any MIME type (0.8.29).\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n ssi_value_length length;
\n
\n Default:\n \n
ssi_value_length 256;
\n
\n Context:\n \n http, server, location
\n

\nSets the maximum length of parameter values in SSI commands.\n

\n\n\n

SSI Commands

\nSSI commands have the following generic format:\n

\n<!--# command parameter1=value1 parameter2=value2 ... -->\n

\n

\nThe following commands are supported:\n

\n\n
block
\n
\nDefines a block that can be used as a stub\nin the include command.\nThe block can contain other SSI commands.\nThe command has the following parameter:\n\n
\n
name
\n
\nblock name.\n
\n
\n\nExample:\n
\n<!--# block name=\"one\" -->\nstub\n<!--# endblock -->\n
\n\n
\n\n\n
config
\n
\nSets some parameters used during SSI processing, namely:\n\n
\n
errmsg
\n
\na string that is output if an error occurs during SSI processing.\nBy default, the following string is output:\n
\n[an error occurred while processing the directive]\n
\n
\n\n
timefmt
\n
\na format string passed to the strftime() function\nused to output date and time.\nBy default, the following format is used:\n
\n\"%A, %d-%b-%Y %H:%M:%S %Z\"\n
\nThe “%s” format is suitable to output time in seconds.\n
\n
\n\n
\n\n\n
echo
\n
\nOutputs the value of a variable.\nThe command has the following parameters:\n\n
\n
var
\n
\nthe variable name.\n
\n\n
encoding
\n
\nthe encoding method.\nPossible values include none, url, and\nentity.\nBy default, entity is used.\n
\n\n
default
\n
\na non-standard parameter that sets a string to be output\nif a variable is undefined.\nBy default, “(none)” is output.\nThe command\n
\n<!--# echo var=\"name\" default=\"no\" -->\n
\nreplaces the following sequence of commands:\n
\n<!--# if expr=\"$name\" --><!--# echo var=\"name\" --><!--#\n       else -->no<!--# endif -->\n
\n
\n
\n\n
\n\n\n
if
\n
\nPerforms a conditional inclusion.\nThe following commands are supported:\n
\n<!--# if expr=\"...\" -->\n...\n<!--# elif expr=\"...\" -->\n...\n<!--# else -->\n...\n<!--# endif -->\n
\nOnly one level of nesting is currently supported.\nThe command has the following parameter:\n\n
\n
expr
\n
\nexpression.\nAn expression can be:\n\n
    \n\n
  • \nvariable existence check:\n
    \n<!--# if expr=\"$name\" -->\n
    \n
  • \n\n
  • \ncomparison of a variable with a text:\n
    \n<!--# if expr=\"$name = text\" -->\n<!--# if expr=\"$name != text\" -->\n
    \n
  • \n\n
  • \ncomparison of a variable with a regular expression:\n
    \n<!--# if expr=\"$name = /text/\" -->\n<!--# if expr=\"$name != /text/\" -->\n
    \n
  • \n
\n\nIf a text contains variables,\ntheir values are substituted.\nA regular expression can contain positional and named captures\nthat can later be used through variables, for example:\n
\n<!--# if expr=\"$name = /(.+)@(?P<domain>.+)/\" -->\n    <!--# echo var=\"1\" -->\n    <!--# echo var=\"domain\" -->\n<!--# endif -->\n
\n
\n
\n\n
\n\n\n
include
\n
\nIncludes the result of another request into a response.\nThe command has the following parameters:\n\n
\n
file
\n
\nspecifies an included file, for example:\n
\n<!--# include file=\"footer.html\" -->\n
\n
\n\n
virtual
\n
\nspecifies an included request, for example:\n
\n<!--# include virtual=\"/remote/body.php?argument=value\" -->\n
\nSeveral requests specified on one page and processed by proxied or\nFastCGI/uwsgi/SCGI/gRPC servers run in parallel.\nIf sequential processing is desired, the wait\nparameter should be used.\n
\n\n
stub
\n
\na non-standard parameter that names the block whose\ncontent will be output if the included request results in an empty\nbody or if an error occurs during the request processing, for example:\n
\n<!--# block name=\"one\" -->&nbsp;<!--# endblock -->\n<!--# include virtual=\"/remote/body.php?argument=value\" stub=\"one\" -->\n
\nThe replacement block content is processed in the included request context.\n
\n\n
wait
\n
\na non-standard parameter that instructs to wait for a request to fully\ncomplete before continuing with SSI processing, for example:\n
\n<!--# include virtual=\"/remote/body.php?argument=value\" wait=\"yes\" -->\n
\n
\n\n
set
\n
\na non-standard parameter that instructs to write a successful result\nof request processing to the specified variable,\nfor example:\n
\n<!--# include virtual=\"/remote/body.php?argument=value\" set=\"one\" -->\n
\nThe maximum size of the response is set by the\nsubrequest_output_buffer_size\ndirective (1.13.10):\n
\nlocation /remote/ {\n    subrequest_output_buffer_size 64k;\n    ...\n}\n
\nPrior to version 1.13.10, only the results of responses obtained using the\nngx_http_proxy_module,\nngx_http_memcached_module,\nngx_http_fastcgi_module (1.5.6),\nngx_http_uwsgi_module (1.5.6),\nand ngx_http_scgi_module (1.5.6)\nmodules could be written into variables.\nThe maximum size of the response was set with the\nproxy_buffer_size,\nmemcached_buffer_size,\nfastcgi_buffer_size,\nuwsgi_buffer_size,\nand scgi_buffer_size\ndirectives.\n
\n\n
\n\n
\n\n\n
set
\n
\nSets a value of a variable.\nThe command has the following parameters:\n\n
\n
var
\n
\nthe variable name.\n
\n\n
value
\n
\nthe variable value.\nIf an assigned value contains variables,\ntheir values are substituted.\n
\n
\n\n
\n\n

\n

\n\n\n

Embedded Variables

\nThe ngx_http_ssi_module module supports\ntwo embedded variables:\n

\n\n
$date_local
\n
\ncurrent time in the local time zone.\nThe format is set by the config command\nwith the timefmt parameter.\n
\n\n
$date_gmt
\n
\ncurrent time in GMT.\nThe format is set by the config command\nwith the timefmt parameter.\n
\n\n

\n

\n\n
\n", "encoding": "utf-8"} +{"path": "en\\docs\\http\\ngx_http_ssl_module.html", "extension": ".html", "size_bytes": 64441, "content": "\nModule ngx_http_ssl_module
\n\nPlanning your ingress-nginx migration? Start here:\nkubernetes.nginx.org.\n\n

Module ngx_http_ssl_module

Example Configuration
Directives
     ssl
     ssl_buffer_size
     ssl_certificate
     ssl_certificate_cache
     ssl_certificate_compression
     ssl_certificate_key
     ssl_ciphers
     ssl_client_certificate
     ssl_conf_command
     ssl_crl
     ssl_dhparam
     ssl_early_data
     ssl_ecdh_curve
     ssl_ech_file
     ssl_key_log
     ssl_ocsp
     ssl_ocsp_cache
     ssl_ocsp_responder
     ssl_password_file
     ssl_prefer_server_ciphers
     ssl_protocols
     ssl_reject_handshake
     ssl_session_cache
     ssl_session_ticket_key
     ssl_session_tickets
     ssl_session_timeout
     ssl_stapling
     ssl_stapling_file
     ssl_stapling_responder
     ssl_stapling_verify
     ssl_trusted_certificate
     ssl_verify_client
     ssl_verify_depth
Error Processing
Embedded Variables
\n\n

\nThe ngx_http_ssl_module module provides the\nnecessary support for HTTPS.\n

\nThis module is not built by default, it should be enabled with the\n--with-http_ssl_module\nconfiguration parameter.\n

\nThis module requires the\nOpenSSL library.\n

\n

\n\n\n

Example Configuration

\nTo reduce the processor load, it is recommended to\n

\n\n

\nworker_processes auto;\n\nhttp {\n\n    ...\n\n    server {\n        listen              443 ssl;\n        keepalive_timeout   70;\n\n        ssl_protocols       TLSv1.2 TLSv1.3;\n        ssl_ciphers         AES128-SHA:AES256-SHA:RC4-SHA:DES-CBC3-SHA:RC4-MD5;\n        ssl_certificate     /usr/local/nginx/conf/cert.pem;\n        ssl_certificate_key /usr/local/nginx/conf/cert.key;\n        ssl_session_cache   shared:SSL:10m;\n        ssl_session_timeout 10m;\n\n        ...\n    }\n

\n

\n\n\n

Directives

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n ssl on | off;
\n
\n Default:\n \n
ssl off;
\n
\n Context:\n \n http, server
\n

\nThis directive was made obsolete in version 1.15.0\nand was removed in version 1.25.1.\nThe ssl parameter\nof the listen directive\nshould be used instead.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n ssl_buffer_size size;
\n
\n Default:\n \n
ssl_buffer_size 16k;
\n
\n Context:\n \n http, server
\n

This directive appeared in version 1.5.9.\n

\nSets the size of the buffer used for sending data.\n

\nBy default, the buffer size is 16k, which corresponds to minimal\noverhead when sending big responses.\nTo minimize Time To First Byte it may be beneficial to use smaller values,\nfor example:\n

\nssl_buffer_size 4k;\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n ssl_certificate file;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n http, server
\n

\nSpecifies a file with the certificate in the PEM format\nfor the given virtual server.\nIf intermediate certificates should be specified in addition to a primary\ncertificate, they should be specified in the same file in the following\norder: the primary certificate comes first, then the intermediate certificates.\nA secret key in the PEM format may be placed in the same file.\n

\nSince version 1.11.0,\nthis directive can be specified multiple times\nto load certificates of different types, for example, RSA and ECDSA:\n

\nserver {\n    listen              443 ssl;\n    server_name         example.com;\n\n    ssl_certificate     example.com.rsa.crt;\n    ssl_certificate_key example.com.rsa.key;\n\n    ssl_certificate     example.com.ecdsa.crt;\n    ssl_certificate_key example.com.ecdsa.key;\n\n    ...\n}\n

\n

\nOnly OpenSSL 1.0.2 or higher supports separate\ncertificate chains\nfor different certificates.\nWith older versions, only one certificate chain can be used.\n

\n

\nSince version 1.15.9, variables can be used in the file name\nwhen using OpenSSL 1.0.2 or higher:\n

\nssl_certificate     $ssl_server_name.crt;\nssl_certificate_key $ssl_server_name.key;\n

\nNote that using variables implies that\na certificate will be loaded for each SSL handshake,\nand this may have a negative impact on performance.\n

\nThe value\ndata:$variable\ncan be specified instead of the file (1.15.10),\nwhich loads a certificate from a variable\nwithout using intermediate files.\nNote that inappropriate use of this syntax may have its security implications,\nsuch as writing secret key data to\nerror log.\n

\nIt should be kept in mind that due to the SSL/TLS protocol limitations,\nfor maximum interoperability with clients that do not use\nSNI,\nvirtual servers with different certificates should listen on\ndifferent\nIP addresses.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n ssl_certificate_cache off;
ssl_certificate_cache \n max=N\n [inactive=time]\n [valid=time];
\n
\n Default:\n \n
ssl_certificate_cache off;
\n
\n Context:\n \n http, server
\n

This directive appeared in version 1.27.4.\n

\nDefines a cache that stores\nSSL certificates and\nsecret keys\nspecified with variables.\n

\nThe directive has the following parameters:\n

\n\n
\nmax\n
\n
\nsets the maximum number of elements in the cache;\non cache overflow the least recently used (LRU) elements are removed;\n
\n\n
\ninactive\n
\n
\ndefines a time after which an element is removed from the cache\nif it has not been accessed during this time;\nby default, it is 10 seconds;\n
\n\n
\nvalid\n
\n
\ndefines a time during which\nan element in the cache is considered valid\nand can be reused;\nby default, it is 60 seconds.\nCertificates that exceed this time will be reloaded or revalidated;\n
\n\n
\noff\n
\n
\ndisables the cache.\n
\n\n

\n

\nExample:\n

\nssl_certificate       $ssl_server_name.crt;\nssl_certificate_key   $ssl_server_name.key;\nssl_certificate_cache max=1000 inactive=20s valid=1m;\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n ssl_certificate_compression on | off;
\n
\n Default:\n \n
ssl_certificate_compression off;
\n
\n Context:\n \n http, server
\n

This directive appeared in version 1.29.1.\n

\nEnables TLS 1.3\ncompression\nof server certificates.\n

\nThe directive is supported when using OpenSSL 3.2 or higher;\nthe list of supported compression algorithms is provided by the library.\n

\n

\nThe directive is supported when using BoringSSL;\nthe list of supported compression algorithms includes\nzlib (1.29.3).\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n ssl_certificate_key file;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n http, server
\n

\nSpecifies a file with the secret key in the PEM format\nfor the given virtual server.\n

\nThe value\nengine:name:id\ncan be specified instead of the file (1.7.9),\nwhich loads a secret key with a specified id\nfrom the OpenSSL engine name.\n

\nThe value\nstore:scheme:id\ncan be specified instead of the file (1.29.0),\nwhich is used to load a secret key with a specified id\nand OpenSSL provider registered URI scheme, such as\npkcs11.\n

\nThe value\ndata:$variable\ncan be specified instead of the file (1.15.10),\nwhich loads a secret key from a variable without using intermediate files.\nNote that inappropriate use of this syntax may have its security implications,\nsuch as writing secret key data to\nerror log.\n

\nSince version 1.15.9, variables can be used in the file name\nwhen using OpenSSL 1.0.2 or higher.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n ssl_ciphers ciphers;
\n
\n Default:\n \n
ssl_ciphers HIGH:!aNULL:!MD5;
\n
\n Context:\n \n http, server
\n

\nSpecifies the enabled ciphers.\nThe ciphers are specified in the format understood by the\nOpenSSL library, for example:\n

\nssl_ciphers ALL:!aNULL:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP;\n

\n

\nThe full list can be viewed using the\n“openssl ciphers” command.\n

\n

\nThe previous versions of nginx used\ndifferent\nciphers by default.\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n ssl_client_certificate file;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n http, server
\n

\nSpecifies a file with trusted CA certificates in the PEM format\nused to verify client certificates and\nOCSP responses if ssl_stapling is enabled.\n

\nThe list of certificates will be sent to clients.\nIf this is not desired, the ssl_trusted_certificate\ndirective can be used.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n ssl_conf_command name value;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n http, server
\n

This directive appeared in version 1.19.4.\n

\nSets arbitrary OpenSSL configuration\ncommands.\n

\nThe directive is supported when using OpenSSL 1.0.2 or higher.\n

\n

\nSeveral ssl_conf_command directives\ncan be specified on the same level:\n

\nssl_conf_command Options PrioritizeChaCha;\nssl_conf_command Ciphersuites TLS_CHACHA20_POLY1305_SHA256;\n

\nThese directives are inherited from the previous configuration level\nif and only if there are no ssl_conf_command directives\ndefined on the current level.\n

\n

\nNote that configuring OpenSSL directly\nmight result in unexpected behavior.\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n ssl_crl file;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n http, server
\n

This directive appeared in version 0.8.7.\n

\nSpecifies a file with revoked certificates (CRL)\nin the PEM format used to verify\nclient certificates.\nWhen using intermediate certificates, their CRLs should be\nspecified in the same file.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n ssl_dhparam file;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n http, server
\n

This directive appeared in version 0.7.2.\n

\nSpecifies a file with DH parameters for DHE ciphers.\n

\nBy default no parameters are set,\nand therefore DHE ciphers will not be used.\n

\nPrior to version 1.11.0, builtin parameters were used by default.\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n ssl_early_data on | off;
\n
\n Default:\n \n
ssl_early_data off;
\n
\n Context:\n \n http, server
\n

This directive appeared in version 1.15.3.\n

\nEnables or disables TLS 1.3\nearly data.\n

\nThe directive is supported when using OpenSSL 1.1.1 or higher (1.15.4) and\nBoringSSL.\n

\n

\n

\nRequests sent within early data are subject to\nreplay attacks.\nTo protect against such attacks at the application layer,\nthe $ssl_early_data variable\nshould be used.\n

\n

\nproxy_set_header Early-Data $ssl_early_data;\n

\n

\n

\nOpenSSL built-in replay protection is disabled,\nbecause it interferes with session resumption.\nIt can be turned back if deemed necessary.\n

\n

\nssl_conf_command Options AntiReplay;\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n ssl_ecdh_curve curve;
\n
\n Default:\n \n
ssl_ecdh_curve auto;
\n
\n Context:\n \n http, server
\n
\n

\n This directive appeared in versions 1.1.0 and 1.0.6.\n \n

\n

\nSpecifies a curve for ECDHE ciphers.\n

\nWhen using OpenSSL 1.0.2 or higher,\nit is possible to specify multiple curves (1.11.0), for example:\n

\nssl_ecdh_curve prime256v1:secp384r1;\n

\n

\nThe special value auto (1.11.0) instructs nginx to use\na list built into the OpenSSL library when using OpenSSL 1.0.2 or higher,\nor prime256v1 with older versions.\n

\n

\nPrior to version 1.11.0,\nthe prime256v1 curve was used by default.\n

\n

\n

\nWhen using OpenSSL 1.0.2 or higher,\nthis directive sets the list of curves supported by the server.\nThus, in order for ECDSA certificates to work,\nit is important to include the curves used in the certificates.\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n ssl_ech_file file;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n http, server
\n

This directive appeared in version 1.29.4.\n

\nSpecifies a file with encrypted ClientHello configuration\n(ECHConfig) in the\nPEM\nformat used to enable TLS 1.3\nECH\nin shared mode.\n

\n

\nThe directive is currently supported only when using OpenSSL\nECH\nfeature branch.\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n ssl_key_log path;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n http, server
\n

This directive appeared in version 1.27.2.\n

\nEnables logging of client connection SSL keys\nand specifies the path to the key log file.\nKeys are logged in the\nSSLKEYLOGFILE\nformat compatible with Wireshark.\n

\n

\nThis directive is available as part of our\ncommercial subscription.\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n ssl_ocsp on |\n off |\n leaf;
\n
\n Default:\n \n
ssl_ocsp off;
\n
\n Context:\n \n http, server
\n

This directive appeared in version 1.19.0.\n

\nEnables OCSP validation of the client certificate chain.\nThe leaf parameter\nenables validation of the client certificate only.\n

\nFor the OCSP validation to work,\nthe ssl_verify_client directive should be set to\non or optional.\n

\nTo resolve the OCSP responder hostname,\nthe resolver directive\nshould also be specified.\n

\nExample:\n

\nssl_verify_client on;\nssl_ocsp          on;\nresolver          192.0.2.1;\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n ssl_ocsp_cache \n off |\n [shared:name:size];
\n
\n Default:\n \n
ssl_ocsp_cache off;
\n
\n Context:\n \n http, server
\n

This directive appeared in version 1.19.0.\n

\nSets name and size of the cache\nthat stores client certificates status for OCSP validation.\nThe cache is shared between all worker processes.\nA cache with the same name can be used in several\nvirtual servers.\n

\nThe off parameter prohibits the use of the cache.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n ssl_ocsp_responder url;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n http, server
\n

This directive appeared in version 1.19.0.\n

\nOverrides the URL of the OCSP responder specified in the\n“Authority\nInformation Access” certificate extension\nfor validation of client certificates.\n

\nOnly “http://” OCSP responders are supported:\n

\nssl_ocsp_responder http://ocsp.example.com/;\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n ssl_password_file file;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n http, server
\n

This directive appeared in version 1.7.3.\n

\nSpecifies a file with passphrases for\nsecret keys\nwhere each passphrase is specified on a separate line.\nPassphrases are tried in turn when loading the key.\n

\nExample:\n

\nhttp {\n    ssl_password_file /etc/keys/global.pass;\n    ...\n\n    server {\n        server_name www1.example.com;\n        ssl_certificate_key /etc/keys/first.key;\n    }\n\n    server {\n        server_name www2.example.com;\n\n        # named pipe can also be used instead of a file\n        ssl_password_file /etc/keys/fifo;\n        ssl_certificate_key /etc/keys/second.key;\n    }\n}\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n ssl_prefer_server_ciphers on | off;
\n
\n Default:\n \n
ssl_prefer_server_ciphers off;
\n
\n Context:\n \n http, server
\n

\nSpecifies that server ciphers should be preferred over client ciphers\nwhen the SSLv3 and TLS protocols are used.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n ssl_protocols \n [SSLv2]\n [SSLv3]\n [TLSv1]\n [TLSv1.1]\n [TLSv1.2]\n [TLSv1.3];
\n
\n Default:\n \n
ssl_protocols TLSv1.2 TLSv1.3;
\n
\n Context:\n \n http, server
\n

\nEnables the specified protocols.\n

\nIf the directive is specified\non the server level,\nthe value from the default server can be used.\nDetails are provided in the\n“Virtual\nserver selection” section.\n

\n

\nThe TLSv1.1 and TLSv1.2 parameters\n(1.1.13, 1.0.12) work only when OpenSSL 1.0.1 or higher is used.\n

\n

\nThe TLSv1.3 parameter (1.13.0) works only when\nOpenSSL 1.1.1 or higher is used.\n

\n

\nThe TLSv1.3 parameter is used by default\nsince 1.23.4.\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n ssl_reject_handshake on | off;
\n
\n Default:\n \n
ssl_reject_handshake off;
\n
\n Context:\n \n http, server
\n

This directive appeared in version 1.19.4.\n

\nIf enabled, SSL handshakes in\nthe server block will be rejected.\n

\nFor example, in the following configuration, SSL handshakes with\nserver names other than example.com are rejected:\n

\nserver {\n    listen               443 ssl default_server;\n    ssl_reject_handshake on;\n}\n\nserver {\n    listen              443 ssl;\n    server_name         example.com;\n    ssl_certificate     example.com.crt;\n    ssl_certificate_key example.com.key;\n}\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n ssl_session_cache \n off |\n none |\n [builtin[:size]]\n [shared:name:size];
\n
\n Default:\n \n
ssl_session_cache none;
\n
\n Context:\n \n http, server
\n

\nSets the types and sizes of caches that store session parameters.\nA cache can be of any of the following types:\n

\n\n
off
\n
\nthe use of a session cache is strictly prohibited:\nnginx explicitly tells a client that sessions may not be reused.\n
\n\n
none
\n
\nthe use of a session cache is gently disallowed:\nnginx tells a client that sessions may be reused, but does not\nactually store session parameters in the cache.\n
\n\n
builtin
\n
\na cache built in OpenSSL; used by one worker process only.\nThe cache size is specified in sessions.\nIf size is not given, it is equal to 20480 sessions.\nUse of the built-in cache can cause memory fragmentation.\n
\n\n
shared
\n
\na cache shared between all worker processes.\nThe cache size is specified in bytes; one megabyte can store\nabout 4000 sessions.\nEach shared cache should have an arbitrary name.\nA cache with the same name can be used in several\nvirtual servers.\nIt is also used to automatically generate, store, and\nperiodically rotate TLS session ticket keys (1.23.2)\nunless configured explicitly\nusing the ssl_session_ticket_key directive.\n
\n\n

\n

\nBoth cache types can be used simultaneously, for example:\n

\nssl_session_cache builtin:1000 shared:SSL:10m;\n

\nbut using only shared cache without the built-in cache should\nbe more efficient.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n ssl_session_ticket_key file;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n http, server
\n

This directive appeared in version 1.5.7.\n

\nSets a file with the secret key used to encrypt\nand decrypt TLS session tickets.\nThe directive is necessary if the same key has to be shared between\nmultiple servers.\nBy default, a randomly generated key is used.\n

\nIf several keys are specified, only the first key is\nused to encrypt TLS session tickets.\nThis allows configuring key rotation, for example:\n

\nssl_session_ticket_key current.key;\nssl_session_ticket_key previous.key;\n

\n

\nThe file must contain 80 or 48 bytes\nof random data and can be created using the following command:\n

\nopenssl rand 80 > ticket.key\n

\nDepending on the file size either AES256 (for 80-byte keys, 1.11.8)\nor AES128 (for 48-byte keys) is used for encryption.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n ssl_session_tickets on | off;
\n
\n Default:\n \n
ssl_session_tickets on;
\n
\n Context:\n \n http, server
\n

This directive appeared in version 1.5.9.\n

\nEnables or disables session resumption through\nTLS session tickets.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n ssl_session_timeout time;
\n
\n Default:\n \n
ssl_session_timeout 5m;
\n
\n Context:\n \n http, server
\n

\nSpecifies a time during which a client may reuse the\nsession parameters.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n ssl_stapling on | off;
\n
\n Default:\n \n
ssl_stapling off;
\n
\n Context:\n \n http, server
\n

This directive appeared in version 1.3.7.\n

\nEnables or disables\nstapling\nof OCSP responses by the server.\nExample:\n

\nssl_stapling on;\nresolver 192.0.2.1;\n

\n

\nFor the OCSP stapling to work, the certificate of the server certificate\nissuer should be known.\nIf the ssl_certificate file does\nnot contain intermediate certificates,\nthe certificate of the server certificate issuer should be\npresent in the\nssl_trusted_certificate file.\n

\nFor a resolution of the OCSP responder hostname,\nthe resolver directive\nshould also be specified.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n ssl_stapling_file file;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n http, server
\n

This directive appeared in version 1.3.7.\n

\nWhen set, the stapled OCSP response will be taken from the\nspecified file instead of querying\nthe OCSP responder specified in the server certificate.\n

\nThe file should be in the DER format as produced by the\n“openssl ocsp” command.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n ssl_stapling_responder url;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n http, server
\n

This directive appeared in version 1.3.7.\n

\nOverrides the URL of the OCSP responder specified in the\n“Authority\nInformation Access” certificate extension.\n

\nOnly “http://” OCSP responders are supported:\n

\nssl_stapling_responder http://ocsp.example.com/;\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n ssl_stapling_verify on | off;
\n
\n Default:\n \n
ssl_stapling_verify off;
\n
\n Context:\n \n http, server
\n

This directive appeared in version 1.3.7.\n

\nEnables or disables verification of OCSP responses by the server.\n

\nFor verification to work, the certificate of the server certificate\nissuer, the root certificate, and all intermediate certificates\nshould be configured as trusted using the\nssl_trusted_certificate directive.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n ssl_trusted_certificate file;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n http, server
\n

This directive appeared in version 1.3.7.\n

\nSpecifies a file with trusted CA certificates in the PEM format\nused to verify client certificates and\nOCSP responses if ssl_stapling is enabled.\n

\nIn contrast to the certificate set by ssl_client_certificate,\nthe list of these certificates will not be sent to clients.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n ssl_verify_client \n on | off |\n optional | optional_no_ca;
\n
\n Default:\n \n
ssl_verify_client off;
\n
\n Context:\n \n http, server
\n

\nEnables verification of client certificates.\nThe verification result is stored in the\n$ssl_client_verify variable.\n

\nThe optional parameter (0.8.7+) requests the client\ncertificate and verifies it if the certificate is present.\n

\nThe optional_no_ca parameter (1.3.8, 1.2.5)\nrequests the client\ncertificate but does not require it to be signed by a trusted CA certificate.\nThis is intended for the use in cases when a service that is external to nginx\nperforms the actual certificate verification.\nThe contents of the certificate is accessible through the\n$ssl_client_cert variable.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n ssl_verify_depth number;
\n
\n Default:\n \n
ssl_verify_depth 1;
\n
\n Context:\n \n http, server
\n

\nSets the verification depth in the client certificates chain.\n

\n\n\n

Error Processing

\nThe ngx_http_ssl_module module supports several\nnon-standard error codes that can be used for redirects using the\nerror_page directive:\n

\n\n
495
\n
\nan error has occurred during the client certificate verification;\n
\n\n
496
\n
\na client has not presented the required certificate;\n
\n\n
497
\n
\na regular request has been sent to the HTTPS port.\n
\n\n

\n

\nThe redirection happens after the request is fully parsed and\nthe variables, such as $request_uri,\n$uri, $args and others, are available.\n

\n\n\n

Embedded Variables

\nThe ngx_http_ssl_module module supports\nembedded variables:\n

\n\n
$ssl_alpn_protocol
\n
\nreturns the protocol selected by ALPN during the SSL handshake,\nor an empty string otherwise (1.21.4);\n
\n\n
$ssl_cipher
\n
\nreturns the name of the cipher used\nfor an established SSL connection;\n
\n\n
$ssl_ciphers
\n
\nreturns the list of ciphers supported by the client (1.11.7).\nKnown ciphers are listed by names, unknown are shown in hexadecimal,\nfor example:\n
\nAES128-SHA:AES256-SHA:0x00ff\n
\n
\nThe variable is fully supported only when using OpenSSL version 1.0.2 or higher.\nWith older versions, the variable is available\nonly for new sessions and lists only known ciphers.\n
\n
\n\n
$ssl_client_escaped_cert
\n
\nreturns the client certificate in the PEM format (urlencoded)\nfor an established SSL connection (1.13.5);\n
\n\n
$ssl_client_cert
\n
\nreturns the client certificate in the PEM format\nfor an established SSL connection, with each line except the first\nprepended with the tab character;\nthis is intended for the use in the\nproxy_set_header directive;\n
\nThe variable is deprecated,\nthe $ssl_client_escaped_cert variable should be used instead.\n
\n
\n\n
$ssl_client_fingerprint
\n
\nreturns the SHA1 fingerprint of the client certificate\nfor an established SSL connection (1.7.1);\n
\n\n
$ssl_client_i_dn
\n
\nreturns the “issuer DN” string of the client certificate\nfor an established SSL connection according to\nRFC 2253 (1.11.6);\n
\n\n
$ssl_client_i_dn_legacy
\n
\nreturns the “issuer DN” string of the client certificate\nfor an established SSL connection;\n
\nPrior to version 1.11.6, the variable name was $ssl_client_i_dn.\n
\n
\n\n
$ssl_client_raw_cert\n
\n
\nreturns the client certificate in the PEM format\nfor an established SSL connection;\n
\n\n
$ssl_client_s_dn
\n
\nreturns the “subject DN” string of the client certificate\nfor an established SSL connection according to\nRFC 2253 (1.11.6);\n
\n\n
$ssl_client_s_dn_legacy
\n
\nreturns the “subject DN” string of the client certificate\nfor an established SSL connection;\n
\nPrior to version 1.11.6, the variable name was $ssl_client_s_dn.\n
\n
\n\n
$ssl_client_serial
\n
\nreturns the serial number of the client certificate\nfor an established SSL connection;\n
\n\n
$ssl_client_sigalg
\n
\nreturns the\nsignature algorithm\nfor the client certificate for an established SSL connection (1.29.3).\n
\nThe variable is supported only when using OpenSSL version 3.5 or higher.\nWith older versions, the variable value will be an empty string.\n
\n
\nThe variable is available only for new sessions.\n
\n
\n\n
$ssl_client_v_end
\n
\nreturns the end date of the client certificate (1.11.7);\n
\n\n
$ssl_client_v_remain
\n
\nreturns the number of days\nuntil the client certificate expires (1.11.7);\n
\n\n
$ssl_client_v_start
\n
\nreturns the start date of the client certificate (1.11.7);\n
\n\n
$ssl_client_verify
\n
\nreturns the result of client certificate verification:\n“SUCCESS”, “FAILED:reason”,\nand “NONE” if a certificate was not present;\n
\nPrior to version 1.11.7, the “FAILED” result\ndid not contain the reason string.\n
\n
\n\n
$ssl_curve
\n
\nreturns the negotiated curve used for\nSSL handshake key exchange process (1.21.5).\nKnown curves are listed by names, unknown are shown in hexadecimal,\nfor example:\n
\nprime256v1\n
\n
\nThe variable is supported only when using OpenSSL version 3.0 or higher.\nWith older versions, the variable value will be an empty string.\n
\n
\n\n
$ssl_curves
\n
\nreturns the list of curves supported by the client (1.11.7).\nKnown curves are listed by names, unknown are shown in hexadecimal,\nfor example:\n
\n0x001d:prime256v1:secp521r1:secp384r1\n
\n
\nThe variable is supported only when using OpenSSL version 1.0.2 or higher.\nWith older versions, the variable value will be an empty string.\n
\n
\nThe variable is available only for new sessions.\n
\n
\n\n
$ssl_early_data
\n
\nreturns “1” if\nTLS 1.3 early data is used\nand the handshake is not complete, otherwise “” (1.15.3).\n
\n\n
$ssl_ech_outer_server_name
\n
\nreturns the public server name requested through\nSNI\nif TLS 1.3 ECH was accepted,\notherwise “” (1.29.4);\n
\n\n
$ssl_ech_status
\n
\nreturns the result of TLS 1.3 ECH processing:\n“FAILED”,\n“BACKEND”,\n“GREASE”,\n“SUCCESS”, or\n“NOT_TRIED” (1.29.4);\n
\nThe variable is currently supported only when using OpenSSL\nECH feature branch\nand is therefore subject to change.\nThe variable value will otherwise be an empty string.\n
\n
\n\n
$ssl_protocol
\n
\nreturns the protocol of an established SSL connection;\n
\n\n
$ssl_server_name
\n
\nreturns the server name requested through\nSNI\n(1.7.0);\n
\n\n
$ssl_session_id
\n
\nreturns the session identifier of an established SSL connection;\n
\n\n
$ssl_session_reused
\n
\nreturns “r” if an SSL session was reused,\nor “.” otherwise (1.5.11).\n
\n\n
$ssl_sigalg
\n
\nreturns the\nsignature algorithm\nfor the server certificate for an established SSL connection (1.29.3).\n
\nThe variable is supported only when using OpenSSL version 3.5 or higher.\nWith older versions, the variable value will be an empty string.\n
\n
\nThe variable is available only for new sessions.\n
\n
\n\n

\n

\n\n
\n", "encoding": "utf-8"} +{"path": "en\\docs\\http\\ngx_http_status_module.html", "extension": ".html", "size_bytes": 31108, "content": "\nModule ngx_http_status_module
\n\nPlanning your ingress-nginx migration? Start here:\nkubernetes.nginx.org.\n\n

Module ngx_http_status_module

Example Configuration
Directives
     status
     status_format
     status_zone
Data
Compatibility
\n\n

\nThe ngx_http_status_module module provides\naccess to various status information.\n

\nThis module was available as part of our\ncommercial subscription\nuntil 1.13.10.\nIt was superseded by the\nngx_http_api_module module\nin 1.13.3.\n

\n

\n\n\n

Example Configuration

\n

\nhttp {\n    upstream backend {\n        zone http_backend 64k;\n\n        server backend1.example.com weight=5;\n        server backend2.example.com;\n    }\n\n    proxy_cache_path /data/nginx/cache_backend keys_zone=cache_backend:10m;\n\n    server {\n        server_name backend.example.com;\n\n        location / {\n            proxy_pass  http://backend;\n            proxy_cache cache_backend;\n\n            health_check;\n        }\n\n        status_zone server_backend;\n    }\n\n    server {\n        listen 127.0.0.1;\n\n        location /upstream_conf {\n            upstream_conf;\n        }\n\n        location /status {\n            status;\n        }\n\n        location = /status.html {\n        }\n    }\n}\n\nstream {\n    upstream backend {\n        zone stream_backend 64k;\n\n        server backend1.example.com:12345 weight=5;\n        server backend2.example.com:12345;\n    }\n\n    server {\n        listen      127.0.0.1:12345;\n        proxy_pass  backend;\n        status_zone server_backend;\n        health_check;\n    }\n}\n

\n

\nExamples of status requests with this configuration:\n

\nhttp://127.0.0.1/status\nhttp://127.0.0.1/status/nginx_version\nhttp://127.0.0.1/status/caches/cache_backend\nhttp://127.0.0.1/status/upstreams\nhttp://127.0.0.1/status/upstreams/backend\nhttp://127.0.0.1/status/upstreams/backend/peers/1\nhttp://127.0.0.1/status/upstreams/backend/peers/1/weight\nhttp://127.0.0.1/status/stream\nhttp://127.0.0.1/status/stream/upstreams\nhttp://127.0.0.1/status/stream/upstreams/backend\nhttp://127.0.0.1/status/stream/upstreams/backend/peers/1\nhttp://127.0.0.1/status/stream/upstreams/backend/peers/1/weight\n

\n

\nThe simple monitoring page is shipped with this distribution,\naccessible as “/status.html” in the default configuration.\nIt requires the locations “/status” and\n“/status.html” to be configured as shown above.\n

\n\n\n

Directives

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n status;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n location
\n

\nThe status information will be accessible from the surrounding location.\nAccess to this location should be\nlimited.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n status_format json;
status_format jsonp [callback];
\n
\n Default:\n \n
status_format json;
\n
\n Context:\n \n http, server, location
\n

\nBy default, status information is output in the JSON format.\n

\nAlternatively, data may be output as JSONP.\nThe callback parameter specifies the name of a callback function.\nParameter value can contain variables.\nIf parameter is omitted, or the computed value is an empty string,\nthen “ngx_status_jsonp_callback” is used.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n status_zone zone;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n server
\n

\nEnables collection of virtual\nhttp\nor\nstream\n(1.7.11) server status information in the specified zone.\nSeveral servers may share the same zone.\n

\n\n\n

Data

\nThe following status information is provided:\n

\n\n
version
\n
\nVersion of the provided data set.\nThe current version is 8.\n
\n\n
nginx_version
\n
\nVersion of nginx.\n
\n\n
nginx_build
\n
\nName of nginx build.\n
\n\n
address
\n
\nThe address of the server that accepted status request.\n
\n\n
generation
\n
\nThe total number of configuration\nreloads.\n
\n\n
load_timestamp
\n
\nTime of the last reload of configuration, in milliseconds since Epoch.\n
\n\n
timestamp
\n
\nCurrent time in milliseconds since Epoch.\n
\n\n
pid
\n
\nThe ID of the worker process that handled status request.\n
\n\n
ppid
\n
\nThe ID of the master process that started\nthe worker process.\n
\n\n
processes
\n
\n
\n\n
respawned
\n
\nThe total number of abnormally terminated and respawned\nchild processes.\n
\n\n
\n
\n\n
connections
\n
\n
\n\n
accepted
\n
\nThe total number of accepted client connections.\n
\n\n
dropped
\n
\nThe total number of dropped client connections.\n
\n\n
active
\n
\nThe current number of active client connections.\n
\n\n
idle
\n
\nThe current number of idle client connections.\n
\n\n
\n
\n\n
ssl
\n
\n
\n\n
handshakes
\n
\nThe total number of successful SSL handshakes.\n
\n\n
handshakes_failed
\n
\nThe total number of failed SSL handshakes.\n
\n\n
session_reuses
\n
\nThe total number of session reuses during SSL handshake.\n
\n\n
\n
\n\n
requests
\n
\n
\n\n
total
\n
\nThe total number of client requests.\n
\n\n
current
\n
\nThe current number of client requests.\n
\n\n
\n
\n\n
server_zones
\n
\nFor each status_zone:\n
\n\n
processing
\n
\nThe number of\nclient requests that are currently being processed.\n
\n\n
requests
\n
\nThe total number of\nclient requests received from clients.\n
\n\n
responses
\n
\n
\n\n
total
\n
\nThe total number of\nresponses sent to clients.\n
\n\n
\n1xx,\n2xx,\n3xx,\n4xx,\n5xx\n
\n
\nThe number of responses with status codes 1xx, 2xx, 3xx, 4xx, and 5xx.\n
\n\n
\n
\n\n
discarded
\n
\nThe total number of requests completed without sending a response.\n
\n\n
received
\n
\nThe total number of bytes received from clients.\n
\n\n
sent
\n
\nThe total number of bytes sent to clients.\n
\n\n
\n
\n\n
slabs
\n
\nFor each shared memory zone that uses slab allocator:\n
\n\n
pages
\n
\n
\n\n
used
\n
\nThe current number of used memory pages.\n
\n\n
free
\n
\nThe current number of free memory pages.\n
\n\n
\n
\n\n
slots
\n
\nFor each memory slot size (8, 16, 32, 64, 128, etc.)\nthe following data are provided:\n
\n\n
used
\n
\nThe current number of used memory slots.\n
\n\n
free
\n
\nThe current number of free memory slots.\n
\n\n
reqs
\n
\nThe total number of attempts to allocate memory of specified size.\n
\n\n
fails
\n
\nThe number of unsuccessful attempts to allocate memory of specified size.\n
\n\n
\n
\n\n
\n
\n\n
upstreams
\n
\nFor each\ndynamically\nconfigurable\ngroup,\nthe following data are provided:\n
\n\n
peers
\n
\nFor each\nserver,\nthe following data are provided:\n
\n\n
id
\n
\nThe ID of the server.\n
\n\n
server
\n
\nAn\naddress\nof the server.\n
\n\n
name
\n
\nThe name of the server specified in the\nserver\ndirective.\n
\n\n
service
\n
\nThe service\nparameter value of the\nserver directive.\n
\n\n
backup
\n
\nA boolean value indicating whether the server is a\nbackup\nserver.\n
\n\n
weight
\n
\nWeight\nof the server.\n
\n\n
state
\n
\nCurrent state, which may be one of\n“up”,\n“draining”,\n“down”,\n“unavail”,\n“checking”,\nor\n“unhealthy”.\n
\n\n
active
\n
\nThe current number of active connections.\n
\n\n
max_conns
\n
\nThe max_conns limit\nfor the server.\n
\n\n
requests
\n
\nThe total number of\nclient requests forwarded to this server.\n
\n\n
responses
\n
\n
\n\n
total
\n
\nThe total number of\nresponses obtained from this server.\n
\n\n
\n1xx,\n2xx,\n3xx,\n4xx,\n5xx\n
\n
\nThe number of responses with status codes 1xx, 2xx, 3xx, 4xx, and 5xx.\n
\n\n
\n
\n\n
sent
\n
\nThe total number of bytes sent to this server.\n
\n\n
received
\n
\nThe total number of bytes received from this server.\n
\n\n
fails
\n
\nThe total number of\nunsuccessful attempts to communicate with the server.\n
\n\n
unavail
\n
\nHow many times\nthe server became unavailable for client requests\n(state “unavail”)\ndue to the number of unsuccessful attempts reaching the\nmax_fails\nthreshold.\n
\n\n
health_checks
\n
\n
\n\n
checks
\n
\nThe total number of\nhealth check\nrequests made.\n
\n\n
fails
\n
\nThe number of failed health checks.\n
\n\n
unhealthy
\n
\nHow many times\nthe server became unhealthy (state “unhealthy”).\n
\n\n
last_passed
\n
\nBoolean indicating\nif the last health check request was successful and passed\ntests.\n
\n\n
\n
\n\n
downtime
\n
\nTotal time\nthe server was in the “unavail”,\n“checking”, and “unhealthy” states.\n
\n\n
downstart
\n
\nThe time (in milliseconds since Epoch)\nwhen the server became\n“unavail”,\n“checking”, or “unhealthy”.\n
\n\n
selected
\n
\nThe time (in milliseconds since Epoch)\nwhen the server was last selected to process a request (1.7.5).\n
\n\n
header_time
\n
\nThe average time to get the\nresponse\nheader from the server (1.7.10).\nPrior to version 1.11.6,\nthe field was available only when using the\nleast_time\nload balancing method.\n
\n\n
response_time
\n
\nThe average time to get the\nfull\nresponse from the server (1.7.10).\nPrior to version 1.11.6,\nthe field was available only when using the\nleast_time\nload balancing method.\n
\n\n
\n
\n\n
keepalive
\n
\nThe current number of\nidle keepalive connections.\n
\n\n
zombies
\n
\nThe current number of servers removed\nfrom the group but still processing active client requests.\n
\n\n
zone
\n
\nThe name of the shared memory\nzone\nthat keeps the group’s configuration and run-time state.\n
\n\n
queue
\n
\nFor the requests queue,\nthe following data are provided:\n
\n\n
size
\n
\nThe current number of requests in the queue.\n
\n\n
max_size
\n
\nThe maximum number of requests that can be in the queue at the same time.\n
\n\n
overflows
\n
\nThe total number of requests rejected due to the queue overflow.\n
\n\n
\n
\n\n
\n
\n\n
caches
\n
\nFor each cache (configured by\nproxy_cache_path and the likes):\n
\n\n
size
\n
\nThe current size of the cache.\n
\n\n
max_size
\n
\nThe limit on the maximum size of the cache specified in the configuration.\n
\n\n
cold
\n
\nA boolean value indicating whether the “cache loader” process is still loading\ndata from disk into the cache.\n
\n\n
\n hit,\n stale,\n updating,\n revalidated\n
\n
\n
\n\n
responses
\n
\nThe total number of responses read from the cache (hits, or stale responses\ndue to proxy_cache_use_stale\nand the likes).\n
\n\n
bytes
\n
\nThe total number of bytes read from the cache.\n
\n\n
\n
\n\n
\n miss,\n expired,\n bypass\n
\n
\n
\n\n
responses
\n
\nThe total number of responses not taken from the cache (misses, expires, or\nbypasses due to\nproxy_cache_bypass\nand the likes).\n
\n\n
bytes
\n
\nThe total number of bytes read from the proxied server.\n
\n\n
responses_written
\n
\nThe total number of responses written to the cache.\n
\n\n
bytes_written
\n
\nThe total number of bytes written to the cache.\n
\n\n
\n
\n\n
\n
\n\n
stream
\n
\n\n
\n
server_zones
\n
\nFor each status_zone:\n
\n\n
processing
\n
\nThe number of\nclient connections that are currently being processed.\n
\n\n
connections
\n
\nThe total number of\nconnections accepted from clients.\n
\n\n
sessions
\n
\n
\n\n
total
\n
\nThe total number of completed client sessions.\n
\n\n
\n2xx,\n4xx,\n5xx\n
\n
\nThe number of sessions completed with\nstatus codes\n2xx, 4xx, or 5xx.\n
\n\n
\n
\n\n
discarded
\n
\nThe total number of connections completed without creating a session.\n
\n\n
received
\n
\nThe total number of bytes received from clients.\n
\n\n
sent
\n
\nThe total number of bytes sent to clients.\n
\n\n
\n
\n\n
upstreams
\n
\nFor each\ndynamically\nconfigurable\ngroup,\nthe following data are provided:\n
\n\n
peers
\n
\nFor each\nserver\nthe following data are provided:\n
\n\n
id
\n
\nThe ID of the server.\n
\n\n
server
\n
\nAn\naddress\nof the server.\n
\n\n\n
name
\n
\nThe name of the server specified in the\nserver directive.\n
\n\n
service
\n
\nThe service\nparameter value of the\nserver directive.\n
\n\n
backup
\n
\nA boolean value indicating whether the server is a\nbackup\nserver.\n
\n\n
weight
\n
\nWeight\nof the server.\n
\n\n
state
\n
\nCurrent state, which may be one of\n“up”,\n“down”,\n“unavail”,\n“checking”,\nor\n“unhealthy”.\n
\n\n
active
\n
\nThe current number of connections.\n
\n\n
max_conns
\n
\nThe max_conns limit\nfor the server.\n
\n\n
connections
\n
\nThe total number of\nclient connections forwarded to this server.\n
\n\n
connect_time
\n
\nThe average time to connect to the upstream server.\nPrior to version 1.11.6,\nthe field was available only when using the\nleast_time\nload balancing method.\n
\n\n
first_byte_time
\n
\nThe average time to receive the first byte of data.\nPrior to version 1.11.6,\nthe field was available only when using the\nleast_time\nload balancing method.\n
\n\n
response_time
\n
\nThe average time to receive the last byte of data.\nPrior to version 1.11.6,\nthe field was available only when using the\nleast_time\nload balancing method.\n
\n\n
sent
\n
\nThe total number of bytes sent to this server.\n
\n\n
received
\n
\nThe total number of bytes received from this server.\n
\n\n
fails
\n
\nThe total number of\nunsuccessful attempts to communicate with the server.\n
\n\n
unavail
\n
\nHow many times\nthe server became unavailable for client connections\n(state “unavail”)\ndue to the number of unsuccessful attempts reaching the\nmax_fails\nthreshold.\n
\n\n
health_checks
\n
\n
\n\n
checks
\n
\nThe total number of\nhealth check\nrequests made.\n
\n\n
fails
\n
\nThe number of failed health checks.\n
\n\n
unhealthy
\n
\nHow many times\nthe server became unhealthy (state “unhealthy”).\n
\n\n
last_passed
\n
\nBoolean indicating\nif the last health check request was successful and passed\ntests.\n
\n\n
\n
\n\n
downtime
\n
\nTotal time\nthe server was in the “unavail”,\n“checking”, and “unhealthy” states.\n
\n\n
downstart
\n
\nThe time (in milliseconds since Epoch)\nwhen the server became\n“unavail”,\n“checking”, or “unhealthy”.\n
\n\n
selected
\n
\nThe time (in milliseconds since Epoch)\nwhen the server was last selected to process a connection.\n
\n\n
\n
\n\n
zombies
\n
\nThe current number of servers removed\nfrom the group but still processing active client connections.\n
\n\n
zone
\n
\nThe name of the shared memory\nzone\nthat keeps the group’s configuration and run-time state.\n
\n\n
\n
\n\n
\n
\n\n

\n

\n\n

Compatibility

\n

\n

\n\n
\n", "encoding": "utf-8"} +{"path": "en\\docs\\http\\ngx_http_stub_status_module.html", "extension": ".html", "size_bytes": 6508, "content": "\nModule ngx_http_stub_status_module
\n\nPlanning your ingress-nginx migration? Start here:\nkubernetes.nginx.org.\n\n

Module ngx_http_stub_status_module

Example Configuration
Directives
     stub_status
Data
Embedded Variables
\n\n

\nThe ngx_http_stub_status_module module provides\naccess to basic status information.\n

\nThis module is not built by default, it should be enabled with the\n--with-http_stub_status_module\nconfiguration parameter.\n

\n\n\n

Example Configuration

\n

\nlocation = /basic_status {\n    stub_status;\n}\n

\nThis configuration creates a simple web page\nwith basic status data which may look like as follows:\n

\nActive connections: 291\nserver accepts handled requests\n 16630948 16630948 31070465\nReading: 6 Writing: 179 Waiting: 106\n

\n

\n\n\n

Directives

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n stub_status;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n server, location
\n

\nThe basic status information will be accessible from the surrounding location.\n

\n

\nIn versions prior to 1.7.5,\nthe directive syntax required an arbitrary argument, for example,\n“stub_status on”.\n

\n

\n\n\n

Data

\nThe following status information is provided:\n

\n\n
Active connections
\n
\nThe current number of active client connections\nincluding Waiting connections.\n
\n\n
accepts
\n
\nThe total number of accepted client connections.\n
\n\n
handled
\n
\nThe total number of handled connections.\nGenerally, the parameter value is the same as accepts\nunless some resource limits have been reached\n(for example, the\nworker_connections limit).\n
\n\n
requests
\n
\nThe total number of client requests.\n
\n\n
Reading
\n
\nThe current number of connections where nginx is reading the request header.\n
\n\n
Writing
\n
\nThe current number of connections\nwhere nginx is writing the response back to the client.\n
\n\n
Waiting
\n
\nThe current number of idle client connections waiting for a request.\n
\n\n

\n

\n\n\n

Embedded Variables

\nThe ngx_http_stub_status_module module\nsupports the following embedded variables (1.3.14):\n

\n\n
$connections_active
\n
\nsame as the Active connections value;\n
\n\n
$connections_reading
\n
\nsame as the Reading value;\n
\n\n
$connections_writing
\n
\nsame as the Writing value;\n
\n\n
$connections_waiting
\n
\nsame as the Waiting value.\n
\n\n

\n

\n\n
\n", "encoding": "utf-8"} +{"path": "en\\docs\\http\\ngx_http_sub_module.html", "extension": ".html", "size_bytes": 7757, "content": "\nModule ngx_http_sub_module
\n\nPlanning your ingress-nginx migration? Start here:\nkubernetes.nginx.org.\n\n

Module ngx_http_sub_module

Example Configuration
Directives
     sub_filter
     sub_filter_last_modified
     sub_filter_once
     sub_filter_types
\n\n

\nThe ngx_http_sub_module module is a filter\nthat modifies a response by replacing one specified string by another.\n

\nThis module is not built by default, it should be enabled with the\n--with-http_sub_module\nconfiguration parameter.\n

\n\n\n

Example Configuration

\n

\nlocation / {\n    sub_filter '<a href=\"http://127.0.0.1:8080/'  '<a href=\"https://$host/';\n    sub_filter '<img src=\"http://127.0.0.1:8080/' '<img src=\"https://$host/';\n    sub_filter_once on;\n}\n

\n

\n\n\n

Directives

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n sub_filter string replacement;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n http, server, location
\n

\nSets a string to replace and a replacement string.\nThe string to replace is matched ignoring the case.\nThe string to replace (1.9.4) and replacement string can contain variables.\nSeveral sub_filter directives\ncan be specified on the same configuration level (1.9.4).\nThese directives are inherited from the previous configuration level\nif and only if there are no sub_filter directives\ndefined on the current level.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n sub_filter_last_modified on | off;
\n
\n Default:\n \n
sub_filter_last_modified off;
\n
\n Context:\n \n http, server, location
\n

This directive appeared in version 1.5.1.\n

\nAllows preserving the “Last-Modified” header field\nfrom the original response during replacement\nto facilitate response caching.\n

\nBy default, the header field is removed as contents of the response\nare modified during processing.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n sub_filter_once on | off;
\n
\n Default:\n \n
sub_filter_once on;
\n
\n Context:\n \n http, server, location
\n

\nIndicates whether to look for each string to replace\nonce or repeatedly.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n sub_filter_types mime-type ...;
\n
\n Default:\n \n
sub_filter_types text/html;
\n
\n Context:\n \n http, server, location
\n

\nEnables string replacement in responses with the specified MIME types\nin addition to “text/html”.\nThe special value “*” matches any MIME type (0.8.29).\n

\n\n
\n", "encoding": "utf-8"} +{"path": "en\\docs\\http\\ngx_http_tunnel_module.html", "extension": ".html", "size_bytes": 21508, "content": "\nModule ngx_http_tunnel_module
\n\nPlanning your ingress-nginx migration? Start here:\nkubernetes.nginx.org.\n\n

Module ngx_http_tunnel_module

Example Configuration
Directives
     tunnel_allow_upstream
     tunnel_bind
     tunnel_bind_dynamic
     tunnel_buffer_size
     tunnel_connect_timeout
     tunnel_next_upstream
     tunnel_next_upstream_timeout
     tunnel_next_upstream_tries
     tunnel_pass
     tunnel_read_timeout
     tunnel_send_lowat
     tunnel_send_timeout
     tunnel_socket_keepalive
\n\n

\nThe ngx_http_tunnel_module (1.31.0) handles HTTP/1.1\nCONNECT\nrequests and establishes an end-to-end virtual connection.\n

\n\n\n

Example Configuration

\n

\nhttp {\n\n    map $request_port $allow_port {\n        443            1;\n    }\n\n    map $host $allow_host {\n        hostnames;\n\n        example.org    1;\n        *.example.org  1;\n    }\n\n    server {\n        listen 8000;\n\n        resolver dns.example.com;\n\n        if ($allow_port != 1) {\n            return 502;\n        }\n\n        if ($allow_host != 1) {\n            return 502;\n        }\n\n        tunnel_pass;\n    }\n}\n

\n

\n\n\n

Directives

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n tunnel_allow_upstream string ...;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n http, server, location
\n

\nDefines conditions under which access to the backend server\nis allowed or denied.\nIf all string parameters are not empty\nand not equal to “0” then the access is allowed.\nThe conditions are evaluated each time\nbefore a connection to a backend server is established.\nParameter values can contain variables:\n

\ngeo $upstream_last_addr $allow {\n    volatile;\n    10.10.0.0/24        1;\n}\n\nserver {\n    listen 127.0.0.1:8080;\n\n    tunnel_pass;\n    tunnel_allow_upstream $allow;\n}\n

\n

\n

\nThis directive is available as part of our\ncommercial subscription.\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n tunnel_bind \n address |\n off;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n http, server, location
\n

\nMakes outgoing connections to a backend server originate\nfrom the specified local IP address with an optional port.\nParameter value can contain variables.\nThe special value off cancels the effect\nof the tunnel_bind directive\ninherited from the previous configuration level, which allows the\nsystem to auto-assign the local IP address and port.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n tunnel_bind_dynamic on | off;
\n
\n Default:\n \n
tunnel_bind_dynamic off;
\n
\n Context:\n \n http, server, location
\n

\nWhen enabled, makes the tunnel_bind operation\nat each connection attempt:\n

\ngeo $upstream_last_addr $bind_addr {\n    volatile;\n    10.0.0.0/24    10.0.0.1;\n    192.168.0.0/24  192.168.0.1;\n}\n\ntunnel_bind         $bind_addr;\ntunnel_bind_dynamic on;\n

\n

\n

\nThis directive is available as part of our\ncommercial subscription.\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n tunnel_buffer_size size;
\n
\n Default:\n \n
tunnel_buffer_size 16k;
\n
\n Context:\n \n http, server, location
\n

\nSets the size of the buffer used for reading data\nfrom the backend server.\nAlso sets the size of the buffer used for reading data\nfrom the client.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n tunnel_connect_timeout time;
\n
\n Default:\n \n
tunnel_connect_timeout 60s;
\n
\n Context:\n \n http, server, location
\n

\nDefines a timeout for establishing a connection with a backend server.\nIt should be noted that this timeout cannot usually exceed 75 seconds.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n tunnel_next_upstream \n error |\n timeout |\n denied |\n off\n ...;
\n
\n Default:\n \n
tunnel_next_upstream error timeout;
\n
\n Context:\n \n http, server, location
\n

\nSpecifies in which cases a request should be passed to the next server:\n

\n\n
error
\n
an error occurred while establishing a connection with the\nserver or reading data from the server;
\n\n
timeout
\n
a timeout has occurred while establishing a connection with the\nserver, passing a request to it, or reading data from the server;
\n\n
denied
\n
the server denied\nthe connection;\n

\n

\nThis parameter is available as part of our\ncommercial subscription.\n

\n

\n
\n\n
off
\n
disables passing a request to the next server.
\n\n

\n

\nOne should bear in mind that passing a request to the next server is\nonly possible if nothing has been sent to a client yet.\nThat is, if an error or timeout occurs in the middle of the\ntransferring of a response, fixing this is impossible.\n

\nThe directive also defines what is considered an\nunsuccessful\nattempt of communication with a server.\nThe cases of error, timeout,\nand denied\nare always considered unsuccessful attempts,\neven if they are not specified in the directive.\n

\nPassing a request to the next server can be limited by\nthe number of tries\nand by time.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n tunnel_next_upstream_timeout time;
\n
\n Default:\n \n
tunnel_next_upstream_timeout 0;
\n
\n Context:\n \n http, server, location
\n

\nLimits the time during which a request can be passed to the\nnext server.\nThe 0 value turns off this limitation.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n tunnel_next_upstream_tries number;
\n
\n Default:\n \n
tunnel_next_upstream_tries 0;
\n
\n Context:\n \n http, server, location
\n

\nLimits the number of possible tries for passing a request to the\nnext server.\nThe 0 value turns off this limitation.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n tunnel_pass [address];
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n server, location, if in location
\n

\nEnables handling of CONNECT requests and sets the address of a backend server.\nBy default, the address is\n$host:$request_port and is taken from the client request.\nIn most cases, tunnel_pass does not require\nconfiguring any arguments.\n

\nThe address can be specified as a domain name or IP address,\nand a port:\n

\ntunnel_pass localhost:9000;\n

\nor as a UNIX-domain socket path:\n

\ntunnel_pass unix:/tmp/backend.socket;\n

\n

\nIf a domain name resolves to several addresses, all of them will be\nused in a round-robin fashion.\nIn addition, an address can be specified as a\nserver group.\n

\nParameter value can contain variables.\nIn this case, if an address is specified as a domain name,\nthe name is searched among the described\nserver groups,\nand, if not found, is determined using a\nresolver.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n tunnel_read_timeout time;
\n
\n Default:\n \n
tunnel_read_timeout 60s;
\n
\n Context:\n \n http, server, location
\n

\nSets the timeout between two successive read or write operations\non client or backend server connections. \nIf no data is transmitted within this time, the connection is closed.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n tunnel_send_lowat size;
\n
\n Default:\n \n
tunnel_send_lowat 0;
\n
\n Context:\n \n http, server, location
\n

\nIf the directive is set to a non-zero value, nginx will try to\nminimize the number\nof send operations on outgoing connections to a backend server by using either\nNOTE_LOWAT flag of the\nkqueue method,\nor the SO_SNDLOWAT socket option,\nwith the specified size.\n

\nThis directive is ignored on Linux, Solaris, and Windows.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n tunnel_send_timeout time;
\n
\n Default:\n \n
tunnel_send_timeout 60s;
\n
\n Context:\n \n http, server, location
\n

\nSets a timeout for transmitting a request to the backend server.\nThe timeout is set only between two successive write operations,\nnot for the transmission of the whole request.\nIf the backend server does not receive anything within this time,\nthe connection is closed.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n tunnel_socket_keepalive on | off;
\n
\n Default:\n \n
tunnel_socket_keepalive off;
\n
\n Context:\n \n http, server, location
\n

\nConfigures the “TCP keepalive” behavior\nfor outgoing connections to a backend server.\nBy default, the operating system’s settings are in effect for the socket.\nIf the directive is set to the value “on”, the\nSO_KEEPALIVE socket option is turned on for the socket.\n

\n\n
\n", "encoding": "utf-8"} +{"path": "en\\docs\\http\\ngx_http_upstream_conf_module.html", "extension": ".html", "size_bytes": 12418, "content": "\nModule ngx_http_upstream_conf_module
\n\nPlanning your ingress-nginx migration? Start here:\nkubernetes.nginx.org.\n\n

Module ngx_http_upstream_conf_module

Example Configuration
Directives
     upstream_conf
\n\n

\nThe ngx_http_upstream_conf_module module\nallows configuring upstream server groups on-the-fly\nvia a simple HTTP interface without the need of restarting nginx.\nThe\nhttp\nor\nstream\nserver group must reside in the shared memory.\n

\nThis module was available as part of our\ncommercial subscription\nuntil 1.13.10.\nIt was superseded by the\nngx_http_api_module module\nin 1.13.3.\n

\n

\n\n\n

Example Configuration

\n

\nupstream backend {\n    zone upstream_backend 64k;\n\n    ...\n}\n\nserver {\n    location /upstream_conf {\n        upstream_conf;\n        allow 127.0.0.1;\n        deny all;\n    }\n}\n

\n

\n\n\n

Directives

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n upstream_conf;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n location
\n

\nTurns on the HTTP interface of upstream configuration in the surrounding\nlocation.\nAccess to this location should be\nlimited.\n

\nConfiguration commands can be used to:\n

\n

\nSince addresses in a group are not required to be unique, specific\nservers in a group are referenced by their IDs.\nIDs are assigned automatically and shown when adding a new server\nor viewing the group configuration.\n

\n

\nA configuration command consists of parameters passed as request arguments,\nfor example:\n

\nhttp://127.0.0.1/upstream_conf?upstream=backend\n

\n

\nThe following parameters are supported:\n\n

\n\n
\nstream=
\n
\nSelects a\nstream\nupstream server group.\nWithout this parameter, selects an\nhttp\nupstream server group.\n
\n\n
\nupstream=name
\n
\nSelects a group to work with.\nThis parameter is mandatory.\n
\n\n
\nid=number
\n
\nSelects a server for viewing, modifying, or removing.\n
\n\n
\nremove=
\n
\nRemoves a server from the group.\n
\n\n
\nadd=
\n
\nAdds a new server to the group.\n
\n\n
\nbackup=
\n
\nRequired to add a backup server.\n
\nBefore version 1.7.2, backup=\nwas also required to view, modify, or remove existing backup servers.\n
\n
\n\n
\nserver=address
\n
\nSame as the “address” parameter\nof the\nhttp\nor\nstream\nupstream server.\n

\nWhen adding a server, it is possible to specify it as a domain name.\nIn this case, changes of the IP addresses that correspond to a domain name\nwill be monitored and automatically applied to the upstream\nconfiguration without the need of restarting nginx (1.7.2).\nThis requires the “resolver” directive in the\nhttp\nor\nstream\nblock.\nSee also the “resolve” parameter\nof the\nhttp\nor\nstream\nupstream server.\n

\n
\n\n
\nservice=name
\n
\nSame as the “service” parameter\nof the\nhttp\nor\nstream\nupstream server (1.9.13).\n
\n\n
\nweight=number
\n
\nSame as the “weight” parameter\nof the\nhttp\nor\nstream\nupstream server.\n
\n\n
\nmax_conns=number
\n
\nSame as the “max_conns” parameter\nof the\nhttp\nor\nstream\nupstream server.\n
\n\n
\nmax_fails=number
\n
\nSame as the “max_fails” parameter\nof the\nhttp\nor\nstream\nupstream server.\n
\n\n
\nfail_timeout=time
\n
\nSame as the “fail_timeout” parameter\nof the\nhttp\nor\nstream\nupstream server.\n
\n\n
\nslow_start=time
\n
\nSame as the “slow_start” parameter\nof the\nhttp\nor\nstream\nupstream server.\n
\n\n
\ndown=
\n
\nSame as the “down” parameter\nof the\nhttp\nor\nstream\nupstream server.\n
\n\n
drain=
\n
\nPuts the\nhttp\nupstream server into the “draining” mode (1.7.5).\nIn this mode, only requests\nbound to the server\nwill be proxied to it.\n
\n\n
\nup=
\n
\nThe opposite of the “down” parameter\nof the\nhttp\nor\nstream\nupstream server.\n
\n\n
\nroute=string
\n
\nSame as the “route” parameter of the\nhttp\nupstream server.\n
\n\n

\n\nThe first three parameters select an object.\nThis can be either the whole http or stream upstream server group,\nor a specific server.\nWithout other parameters, the configuration of the selected\ngroup or server is shown.\n

\nFor example, to view the configuration of the whole group, send:\n

\nhttp://127.0.0.1/upstream_conf?upstream=backend\n

\n\nTo view the configuration of a specific server, also specify its ID:\n

\nhttp://127.0.0.1/upstream_conf?upstream=backend&id=42\n

\n

\nTo add a new server,\nspecify its address in the “server=” parameter.\nWithout other parameters specified, a server will be added with other\nparameters set to their default values (see the\nhttp\nor\nstream\n“server” directive).\n

\nFor example, to add a new primary server, send:\n

\nhttp://127.0.0.1/upstream_conf?add=&upstream=backend&server=127.0.0.1:8080\n

\n\nTo add a new backup server, send:\n

\nhttp://127.0.0.1/upstream_conf?add=&upstream=backend&backup=&server=127.0.0.1:8080\n

\n\nTo add a new primary server,\nset its parameters to non-default values\nand mark it as “down”, send:\n

\nhttp://127.0.0.1/upstream_conf?add=&upstream=backend&server=127.0.0.1:8080&weight=2&down=\n

\n\nTo remove a server, specify its ID:\n

\nhttp://127.0.0.1/upstream_conf?remove=&upstream=backend&id=42\n

\n\nTo mark an existing server as “down”, send:\n

\nhttp://127.0.0.1/upstream_conf?upstream=backend&id=42&down=\n

\n\nTo modify the address of an existing server, send:\n

\nhttp://127.0.0.1/upstream_conf?upstream=backend&id=42&server=192.0.2.3:8123\n

\n\nTo modify other parameters of an existing server, send:\n

\nhttp://127.0.0.1/upstream_conf?upstream=backend&id=42&max_fails=3&weight=4\n

\n\nThe above examples are for an\nhttp\nupstream server group.\nSimilar examples for a\nstream\nupstream server group require the “stream=” parameter.\n

\n\n
\n", "encoding": "utf-8"} +{"path": "en\\docs\\http\\ngx_http_upstream_hc_module.html", "extension": ".html", "size_bytes": 14231, "content": "\nModule ngx_http_upstream_hc_module
\n\nPlanning your ingress-nginx migration? Start here:\nkubernetes.nginx.org.\n\n

Module ngx_http_upstream_hc_module

Example Configuration
Directives
     health_check
     match
\n\n

\nThe ngx_http_upstream_hc_module module\nallows enabling periodic health checks of the servers in a\ngroup\nreferenced in the surrounding location.\nThe server group must reside in the\nshared memory.\n

\nIf a health check fails,\nthe server will be considered unhealthy.\nIf several health checks are defined for the same group of servers,\na single failure of any check will make the corresponding server be\nconsidered unhealthy.\nClient requests are not passed to unhealthy servers\nand servers in the “checking” state.\n

\n

\nPlease note that most of the variables will have empty values\nwhen used with health checks.\n

\n

\n

\nThis module is available as part of our\ncommercial subscription.\n

\n

\n\n\n

Example Configuration

\n

\nupstream dynamic {\n    zone upstream_dynamic 64k;\n\n    server backend1.example.com      weight=5;\n    server backend2.example.com:8080 fail_timeout=5s slow_start=30s;\n    server 192.0.2.1                 max_fails=3;\n\n    server backup1.example.com:8080  backup;\n    server backup2.example.com:8080  backup;\n}\n\nserver {\n    location / {\n        proxy_pass http://dynamic;\n        health_check;\n    }\n}\n

\nWith this configuration, nginx will send “/” requests to each\nserver in the backend group every five seconds.\nIf any communication error or timeout occurs, or a\nproxied server responds with the status code other than\n2xx or 3xx, the health check will fail, and the server will\nbe considered unhealthy.\n

\nHealth checks can be configured to test the status code of a response,\npresence of certain header fields and their values,\nand the body contents.\nTests are configured separately using the match directive\nand referenced in the match parameter\nof the health_check directive:\n

\nhttp {\n    server {\n    ...\n        location / {\n            proxy_pass http://backend;\n            health_check match=welcome;\n        }\n    }\n\n    match welcome {\n        status 200;\n        header Content-Type = text/html;\n        body ~ \"Welcome to nginx!\";\n    }\n}\n

\nThis configuration shows that in order for a health check to pass, the response\nto a health check request should succeed, have status 200,\nand contain “Welcome to nginx!” in the body.\n

\n\n\n

Directives

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n health_check [parameters];
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n location
\n

\nEnables periodic health checks of the servers in a\ngroup\nreferenced in the surrounding location.\n

\nThe following optional parameters are supported:\n

\n\n
\ninterval=time\n
\n
\nsets the interval between two consecutive health checks,\nby default, 5 seconds.\n
\n\n
\njitter=time\n
\n
\nsets the time within which\neach health check will be randomly delayed,\nby default, there is no delay.\n
\n\n
\nfails=number\n
\n
\nsets the number of consecutive failed health checks of a particular server\nafter which this server will be considered unhealthy,\nby default, 1.\n
\n\n
\npasses=number\n
\n
\nsets the number of consecutive passed health checks of a particular server\nafter which the server will be considered healthy,\nby default, 1.\n
\n\n
\nuri=uri\n
\n
\ndefines the URI used in health check requests,\nby default, “/”.\n
\n\n
\nmandatory [persistent]\n
\n
\n

\nsets the initial “checking” state for a server\nuntil the first health check is completed (1.11.7).\nClient requests are not passed to servers in the “checking” state.\nIf the parameter is not specified,\nthe server will be initially considered healthy.\n

\n\n

\nThe persistent parameter (1.19.7)\nsets the initial “up” state for a server after reload\nif the server was considered healthy before reload.\n

\n\n
\n\n
\nmatch=name\n
\n
\nspecifies the match block configuring the tests that a\nresponse should pass in order for a health check to pass.\nBy default, the response should have status code 2xx or 3xx.\n
\n\n
\nport=number\n
\n
\ndefines the port used when connecting to a server\nto perform a health check (1.9.7).\nBy default, equals the\nserver port.\n
\n\n
\ntype=grpc\n[grpc_service=name]\n[grpc_status=code]\n
\n
\nenables periodic\nhealth\nchecks of a gRPC server\nor a particular gRPC service specified with the optional\ngrpc_service parameter (1.19.5).\nIf the server does not support the gRPC Health Checking Protocol,\nthe optional grpc_status parameter can be used\nto specify non-zero gRPC\nstatus\n(for example,\nstatus code “12” / “UNIMPLEMENTED”)\nthat will be treated as healthy:\n
\nhealth_check mandatory type=grpc grpc_status=12;\n
\nThe type=grpc parameter\nmust be specified after all other directive parameters,\ngrpc_service and grpc_status\nmust follow type=grpc.\nThe parameter is not compatible with\nuri or\nmatch parameters.\n
\n\n
\nkeepalive_time=time\n
\n
\nenables keepalive\nconnections for health checks and specifies the time during which\nrequests can be processed through one keepalive connection (1.21.7).\nBy default keepalive connections are disabled.\n
\n\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n match name { ... }
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n http
\n

\nDefines the named test set used to verify responses to health check requests.\n

\nThe following items can be tested in a response:\n

\n\n
status 200;
\n
status is 200
\n\n
status ! 500;
\n
status is not 500
\n\n
status 200 204;
\n
status is 200 or 204
\n\n
status ! 301 302;
\n
status is neither 301 nor 302
\n\n
status 200-399;
\n
status is in the range from 200 to 399
\n\n
status ! 400-599;
\n
status is not in the range from 400 to 599
\n\n
status 301-303 307;
\n
status is either 301, 302, 303, or 307
\n\n

\n\n

\n\n
header Content-Type = text/html;
\n
\nheader contains “Content-Type”\nwith value text/html\n
\n\n
header Content-Type != text/html;
\n
\nheader contains “Content-Type”\nwith value other than text/html\n
\n\n
header Connection ~ close;
\n
\nheader contains “Connection”\nwith value matching regular expression close\n
\n\n
header Connection !~ close;
\n
\nheader contains “Connection”\nwith value not matching regular expression close\n
\n\n
header Host;
\n
header contains “Host”
\n\n
header ! X-Accel-Redirect;
\n
header lacks “X-Accel-Redirect”
\n\n

\n\n

\n\n
body ~ \"Welcome to nginx!\";
\n
\nbody matches regular expression “Welcome to nginx!”\n
\n\n
body !~ \"Welcome to nginx!\";
\n
\nbody does not match regular expression “Welcome to nginx!”\n
\n\n

\n\n

\n\n
require\n $variable\n ...;
\n
\nall specified variables are not empty and not equal to “0” (1.15.9).\n
\n\n

\n

\nIf several tests are specified,\nthe response matches only if it matches all tests.\n

\nOnly the first 256k of the response body are examined.\n

\n

\nExamples:\n

\n# status is 200, content type is \"text/html\",\n# and body contains \"Welcome to nginx!\"\nmatch welcome {\n    status 200;\n    header Content-Type = text/html;\n    body ~ \"Welcome to nginx!\";\n}\n

\n\n

\n# status is not one of 301, 302, 303, or 307, and header does not have \"Refresh:\"\nmatch not_redirect {\n    status ! 301-303 307;\n    header ! Refresh;\n}\n

\n\n

\n# status ok and not in maintenance mode\nmatch server_ok {\n    status 200-399;\n    body !~ \"maintenance mode\";\n}\n

\n\n

\n# status is 200 or 204\nmap $upstream_status $good_status {\n    200 1;\n    204 1;\n}\n\nmatch server_ok {\n    require $good_status;\n}\n

\n\n

\n\n
\n", "encoding": "utf-8"} +{"path": "en\\docs\\http\\ngx_http_upstream_module.html", "extension": ".html", "size_bytes": 60692, "content": "\nModule ngx_http_upstream_module
\n\nPlanning your ingress-nginx migration? Start here:\nkubernetes.nginx.org.\n\n

Module ngx_http_upstream_module

Example Configuration
Directives
     upstream
     server
     zone
     state
     hash
     ip_hash
     keepalive
     keepalive_requests
     keepalive_time
     keepalive_timeout
     ntlm
     least_conn
     least_time
     queue
     random
     resolver
     resolver_timeout
     sticky
Embedded Variables
\n\n

\nThe ngx_http_upstream_module module\nis used to define groups of servers that can be referenced\nby the proxy_pass,\nfastcgi_pass,\nuwsgi_pass,\nscgi_pass,\nmemcached_pass, and\ngrpc_pass directives.\n

\n\n\n

Example Configuration

\n

\nupstream backend {\n    server backend1.example.com       weight=5;\n    server backend2.example.com:8080;\n    server unix:/tmp/backend3;\n\n    server backup1.example.com:8080   backup;\n    server backup2.example.com:8080   backup;\n}\n\nserver {\n    location / {\n        proxy_pass http://backend;\n    }\n}\n

\n

\nDynamically configurable group with\nperiodic health checks is\navailable as part of our\ncommercial subscription:\n

\nresolver 10.0.0.1;\n\nupstream dynamic {\n    zone upstream_dynamic 64k;\n\n    server backend1.example.com      weight=5;\n    server backend2.example.com:8080 fail_timeout=5s slow_start=30s;\n    server 192.0.2.1                 max_fails=3;\n    server backend3.example.com      resolve;\n    server backend4.example.com      service=http resolve;\n\n    server backup1.example.com:8080  backup;\n    server backup2.example.com:8080  backup;\n}\n\nserver {\n    location / {\n        proxy_pass http://dynamic;\n        health_check;\n    }\n}\n

\n

\n\n\n

Directives

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n upstream name { ... }
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n http
\n

\nDefines a group of servers.\nServers can listen on different ports.\nIn addition, servers listening on TCP and UNIX-domain sockets\ncan be mixed.\n

\nExample:\n

\nupstream backend {\n    server backend1.example.com weight=5;\n    server 127.0.0.1:8080       max_fails=3 fail_timeout=30s;\n    server unix:/tmp/backend3;\n\n    server backup1.example.com  backup;\n}\n

\n

\nBy default, requests are distributed between the servers using a\nweighted round-robin balancing method.\nIn the above example, each 7 requests will be distributed as follows:\n5 requests go to backend1.example.com\nand one request to each of the second and third servers.\nIf an error occurs during communication with a server, the request will\nbe passed to the next server, and so on until all of the functioning\nservers will be tried.\nIf a successful response could not be obtained from any of the servers,\nthe client will receive the result of the communication with the last server.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n server address [parameters];
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n upstream
\n

\nDefines the address and other parameters\nof a server.\nThe address can be specified as a domain name or IP address,\nwith an optional port, or as a UNIX-domain socket path\nspecified after the “unix:” prefix.\nIf a port is not specified, the port 80 is used.\nA domain name that resolves to several IP addresses defines\nmultiple servers at once.\n

\nThe following parameters can be defined:\n

\n\n
\nweight=number\n
\n
\nsets the weight of the server, by default, 1.\n
\n\n
\nmax_conns=number\n
\n
\nlimits the maximum number of simultaneous active\nconnections to the proxied server (1.11.5).\nDefault value is zero, meaning there is no limit.\nIf the server group does not reside in the shared memory,\nthe limitation works per each worker process.\n
\nIf idle keepalive connections,\nmultiple workers,\nand the shared memory are enabled,\nthe total number of active and idle connections to the proxied server\nmay exceed the max_conns value.\n
\n
\nSince version 1.5.9 and prior to version 1.11.5,\nthis parameter was available as part of our\ncommercial subscription.\n
\n
\n\n
\nmax_fails=number\n
\n
\nsets the number of unsuccessful attempts to communicate with the server\nthat should happen in the duration set by the fail_timeout\nparameter to consider the server unavailable for a duration also set by the\nfail_timeout parameter.\nBy default, the number of unsuccessful attempts is set to 1.\nThe zero value disables the accounting of attempts.\nWhat is considered an unsuccessful attempt is defined by the\nproxy_next_upstream,\nfastcgi_next_upstream,\nuwsgi_next_upstream,\nscgi_next_upstream,\nmemcached_next_upstream, and\ngrpc_next_upstream\ndirectives.\n
\n\n
\nfail_timeout=time\n
\n
\nsets\n
    \n\n
  • \nthe time during which the specified number of unsuccessful attempts to\ncommunicate with the server should happen to consider the server unavailable;\n
  • \n\n
  • \nand the period of time the server will be considered unavailable.\n
  • \n\n
\nBy default, the parameter is set to 10 seconds.\n
\n\n
\nbackup\n
\n
\nmarks the server as a backup server.\nIt will be passed requests when the primary servers are unavailable.\n
\nThe parameter cannot be used along with the\nhash, ip_hash, and random\nload balancing methods.\n
\n
\n\n
\ndown\n
\n
\nmarks the server as permanently unavailable.\n
\n\n
\nresolve\n
\n
\nmonitors changes of the IP addresses\nthat correspond to a domain name of the server,\nand automatically modifies the upstream configuration\nwithout the need of restarting nginx (1.5.12).\nThe server group must reside in the shared memory.\n

\nIn order for this parameter to work,\nthe resolver directive\nmust be specified in the\nhttp block\nor in the corresponding upstream block.\n

\n\n

\n

\nPrior to version 1.27.3, this parameter was available only as part of our\ncommercial subscription.\n

\n

\n
\n\n
\nservice=name\n
\n
\nenables resolving of DNS\nSRV\nrecords and sets the service name (1.9.13).\nIn order for this parameter to work, it is necessary to specify\nthe resolve parameter for the server\nand specify a hostname without a port number.\n

\nIf the service name does not contain a dot (“.”), then\nthe RFC-compliant name\nis constructed\nand the TCP protocol is added to the service prefix.\nFor example, to look up the\n_http._tcp.backend.example.com SRV record,\nit is necessary to specify the directive:\n

\nserver backend.example.com service=http resolve;\n

\nIf the service name contains one or more dots, then the name is constructed\nby joining the service prefix and the server name.\nFor example, to look up the _http._tcp.backend.example.com\nand server1.backend.example.com SRV records,\nit is necessary to specify the directives:\n

\nserver backend.example.com service=_http._tcp resolve;\nserver example.com service=server1.backend resolve;\n

\n

\n\n

\nHighest-priority SRV records\n(records with the same lowest-number priority value)\nare resolved as primary servers,\nthe rest of SRV records are resolved as backup servers.\nIf the backup parameter is specified for the server,\nhigh-priority SRV records are resolved as backup servers,\nthe rest of SRV records are ignored.\n

\n\n

\n

\nPrior to version 1.27.3, this parameter was available only as part of our\ncommercial subscription.\n

\n

\n
\n\n
\nroute=string\n
\n
\nsets the server route name.\n

\n

\nPrior to version 1.29.6,\nthis parameter was available only as part of our\ncommercial subscription.\n

\n

\n
\n\n
\ndrain\n
\n
\nputs the server into the “draining” mode (1.13.6).\nIn this mode, only requests bound to the server\nwill be proxied to it.\n
\nPrior to version 1.13.6,\nthe parameter could be changed only with the\nAPI module.\n
\n
\nPrior to version 1.29.6,\nthe parameter was available only as part of our\ncommercial subscription.\n
\n
\n\n

\n

\nAdditionally,\nthe following parameters are available as part of our\ncommercial subscription:\n

\n\n
\nslow_start=time\n
\n
\nsets the time during which the server will recover its weight\nfrom zero to a nominal value, when unhealthy server becomes\nhealthy,\nor when the server becomes available after a period of time\nit was considered unavailable.\nDefault value is zero, i.e. slow start is disabled.\n
\nThe parameter cannot be used along with the\nhash, ip_hash, and random\nload balancing methods.\n
\n
\n\n

\n

\n

\nIf there is only a single server in a group, max_fails,\nfail_timeout and slow_start parameters\nare ignored, and such a server will never be considered unavailable.\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n zone name [size];
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n upstream
\n

This directive appeared in version 1.9.0.\n

\nDefines the name and size of the shared\nmemory zone that keeps the group’s configuration and run-time state that are\nshared between worker processes.\nSeveral groups may share the same zone.\nIn this case, it is enough to specify the size only once.\n

\nAdditionally,\nas part of our commercial subscription,\nsuch groups allow changing the group membership\nor modifying the settings of a particular server\nwithout the need of restarting nginx.\nThe configuration is accessible via the\nAPI module (1.13.3).\n

\nPrior to version 1.13.3,\nthe configuration was accessible only via a special location\nhandled by\nupstream_conf.\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n state file;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n upstream
\n

This directive appeared in version 1.9.7.\n

\nSpecifies a file that keeps the state\nof the dynamically configurable group.\n

\nExamples:\n

\nstate /var/lib/nginx/state/servers.conf; # path for Linux\nstate /var/db/nginx/state/servers.conf;  # path for FreeBSD\n

\n

\nThe state is currently limited to the list of servers with their parameters.\nThe file is read when parsing the configuration and is updated each time\nthe upstream configuration is\nchanged.\nChanging the file content directly should be avoided.\nThe directive cannot be used\nalong with the server directive.\n

\n

\nChanges made during\nconfiguration reload\nor binary upgrade\ncan be lost.\n

\n

\n

\nThis directive is available as part of our\ncommercial subscription.\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n hash key [consistent];
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n upstream
\n

This directive appeared in version 1.7.2.\n

\nSpecifies a load balancing method for a server group\nwhere the client-server mapping is based on the hashed key value.\nThe key can contain text, variables, and their combinations.\nNote that adding or removing a server from the group\nmay result in remapping most of the keys to different servers.\nThe method is compatible with the\nCache::Memcached\nPerl library.\n

\nIf the consistent parameter is specified,\nthe ketama\nconsistent hashing method will be used instead.\nThe method ensures that only a few keys\nwill be remapped to different servers\nwhen a server is added to or removed from the group.\nThis helps to achieve a higher cache hit ratio for caching servers.\nThe method is compatible with the\nCache::Memcached::Fast\nPerl library with the ketama_points parameter set to 160.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n ip_hash;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n upstream
\n

\nSpecifies that a group should use a load balancing method where requests\nare distributed between servers based on client IP addresses.\nThe first three octets of the client IPv4 address, or the entire IPv6 address,\nare used as a hashing key.\nThe method ensures that requests from the same client will always be\npassed to the same server except when this server is unavailable.\nIn the latter case client requests will be passed to another server.\nMost probably, it will always be the same server as well.\n

\nIPv6 addresses are supported starting from versions 1.3.2 and 1.2.2.\n

\n

\nIf one of the servers needs to be temporarily removed, it should\nbe marked with the down parameter in\norder to preserve the current hashing of client IP addresses.\n

\nExample:\n

\nupstream backend {\n    ip_hash;\n\n    server backend1.example.com;\n    server backend2.example.com;\n    server backend3.example.com down;\n    server backend4.example.com;\n}\n

\n

\n

\nUntil versions 1.3.1 and 1.2.2, it was not possible to specify a weight for\nservers using the ip_hash load balancing method.\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n keepalive connections [local];
\n
\n Default:\n \n
keepalive 32 local;
\n
\n Context:\n \n upstream
\n

This directive appeared in version 1.1.4.\n

\nEnables or disables caching of keepalive connections to upstream servers.\nSince 1.29.7, by default the cache for connections is activated\nand these connections are not\nshared between different\nlocations.\n

\nThe local parameter (1.29.7) disables sharing of\ncached keepalive connections across different locations\neven if the upstream server address matches.\nIf the local parameter is not specified,\nany matching cached connection to the same upstream server\ncan be reused regardless of a location.\n

\nThe connections parameter sets the maximum number of\nidle keepalive connections to upstream servers that are preserved in\nthe cache of each worker process.\nWhen this number is exceeded, the least recently used connections\nare closed.\nThe zero value disables keepalive connections to upstream servers.\n

\nSince 1.29.7, keepalive connections are enabled by default, with a\ndefault limit of 32 connections per each worker process.\n

\n

\nIt should be particularly noted that the keepalive directive\ndoes not limit the total number of connections to upstream servers\nthat an nginx worker process can open.\nThe connections parameter should be set to a number small enough\nto let upstream servers process new incoming connections as well.\n

\n\n

\nBefore 1.29.7, when using load balancing methods other than the default\nround-robin method, it was necessary to activate them before\nthe keepalive directive.\n

\n

\nExample configuration of memcached upstream with keepalive connections:\n

\nupstream memcached_backend {\n    server 127.0.0.1:11211;\n    server 10.0.0.2:11211;\n\n    keepalive 32;\n}\n\nserver {\n    ...\n\n    location /memcached/ {\n        set $memcached_key $uri;\n        memcached_pass memcached_backend;\n    }\n\n}\n

\n

\nFor HTTP, the proxy_http_version\ndirective should be “1.1” (by default since 1.29.7)\nor set to “2”\nand the “Connection” header field should be cleared.\nThis example is for versions prior to 1.29.7:\n

\nupstream http_backend {\n    server 127.0.0.1:8080;\n\n    keepalive 16;\n}\n\nserver {\n    ...\n\n    location /http/ {\n        proxy_pass http://http_backend;\n        # proxy_http_version 1.1; # before version 1.29.7\n        # proxy_set_header Connection \"\"; # before version 1.29.7\n        ...\n    }\n}\n

\n

\n

\nAlternatively, HTTP/1.0 persistent connections can be used by passing the\n“Connection: Keep-Alive” header field to an upstream server,\nthough this method is not recommended.\n

\n

\nFor FastCGI servers, it is required to set\nfastcgi_keep_conn\nfor keepalive connections to work:\n

\nupstream fastcgi_backend {\n    server 127.0.0.1:9000;\n\n    keepalive 8;\n}\n\nserver {\n    ...\n\n    location /fastcgi/ {\n        fastcgi_pass fastcgi_backend;\n        fastcgi_keep_conn on;\n        ...\n    }\n}\n

\n

\n

\nSCGI and uwsgi protocols do not have a notion of keepalive connections.\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n keepalive_requests number;
\n
\n Default:\n \n
keepalive_requests 1000;
\n
\n Context:\n \n upstream
\n

This directive appeared in version 1.15.3.\n

\nSets the maximum number of requests that can be\nserved through one keepalive connection.\nAfter the maximum number of requests is made, the connection is closed.\n

\nClosing connections periodically is necessary to free\nper-connection memory allocations.\nTherefore, using too high maximum number of requests\ncould result in excessive memory usage and not recommended.\n

\n

\nPrior to version 1.19.10, the default value was 100.\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n keepalive_time time;
\n
\n Default:\n \n
keepalive_time 1h;
\n
\n Context:\n \n upstream
\n

This directive appeared in version 1.19.10.\n

\nLimits the maximum time during which\nrequests can be processed through one keepalive connection.\nAfter this time is reached, the connection is closed\nfollowing the subsequent request processing.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n keepalive_timeout timeout;
\n
\n Default:\n \n
keepalive_timeout 60s;
\n
\n Context:\n \n upstream
\n

This directive appeared in version 1.15.3.\n

\nSets a timeout during which an idle keepalive\nconnection to an upstream server will stay open.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n ntlm;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n upstream
\n

This directive appeared in version 1.9.2.\n

\nAllows proxying requests with\nNTLM\nAuthentication.\nThe upstream connection is bound to the client connection\nonce the client sends a request with the “Authorization”\nheader field value\nstarting with “Negotiate” or “NTLM”.\nFurther client requests will be proxied through the same upstream connection,\nkeeping the authentication context.\n

\nIn order for NTLM authentication to work,\nit is necessary to enable keepalive connections to upstream servers.\nThe proxy_http_version\ndirective should be “1.1” (by default since 1.29.7)\nor set to “2”\nand the “Connection” header field should be cleared.\nThis example is for versions prior to 1.29.7:\n

\nupstream http_backend {\n    server 127.0.0.1:8080;\n\n    ntlm;\n}\n\nserver {\n    ...\n\n    location /http/ {\n        proxy_pass http://http_backend;\n        # proxy_http_version 1.1; # before version 1.29.7\n        # proxy_set_header Connection \"\"; # before version 1.29.7\n        ...\n    }\n}\n

\n

\n

\nWhen using load balancer methods other than the default\nround-robin method, it is necessary to activate them before\nthe ntlm directive.\n

\n

\n

\nThis directive is available as part of our\ncommercial subscription.\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n least_conn;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n upstream
\n
\n

\n This directive appeared in versions 1.3.1 and 1.2.2.\n \n

\n

\nSpecifies that a group should use a load balancing method where a request\nis passed to the server with the least number of active connections,\ntaking into account weights of servers.\nIf there are several such servers, they are tried in turn using a\nweighted round-robin balancing method.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n least_time \n header |\n last_byte\n [inflight];
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n upstream
\n

This directive appeared in version 1.7.10.\n

\nSpecifies that a group should use a load balancing method where a request\nis passed to the server with the least average response time and\nleast number of active connections, taking into account weights of servers.\nIf there are several such servers, they are tried in turn using a\nweighted round-robin balancing method.\n

\nIf the header parameter is specified,\ntime to receive the\nresponse header is used.\nIf the last_byte parameter is specified,\ntime to receive the full response\nis used.\nIf the inflight parameter is specified (1.11.6),\nincomplete requests are also taken into account.\n

\nPrior to version 1.11.6, incomplete requests were taken into account by default.\n

\n

\n

\nPrior to version 1.31.0,\nthis directive was available only as part of our\ncommercial subscription.\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n queue \nnumber\n[timeout=time];
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n upstream
\n

This directive appeared in version 1.5.12.\n

\nIf an upstream server cannot be selected immediately\nwhile processing a request,\nthe request will be placed into the queue.\nThe directive specifies the maximum number of requests\nthat can be in the queue at the same time.\nIf the queue is filled up,\nor the server to pass the request to cannot be selected within\nthe time period specified in the timeout parameter,\nthe 502 (Bad Gateway)\nerror will be returned to the client.\n

\nThe default value of the timeout parameter is 60 seconds.\n

\n

\nWhen using load balancer methods other than the default\nround-robin method, it is necessary to activate them before\nthe queue directive.\n

\n\n

\nThis directive is available as part of our\ncommercial subscription.\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n random [two [method]];
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n upstream
\n

This directive appeared in version 1.15.1.\n

\nSpecifies that a group should use a load balancing method where a request\nis passed to a randomly selected server, taking into account weights\nof servers.\n

\nThe optional two parameter\ninstructs nginx to randomly select\ntwo\nservers and then choose a server\nusing the specified method.\nThe default method is least_conn\nwhich passes a request to a server\nwith the least number of active connections.\n

\nThe least_time method passes a request to a server\nwith the least average response time and least number of active connections.\nIf least_time=header is specified, the time to receive the\nresponse header is used.\nIf least_time=last_byte is specified, the time to receive the\nfull response is used.\n

\nThe least_time method is available as a part of our\ncommercial subscription.\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n resolver \n address ...\n [valid=time]\n [ipv4=on|off]\n [ipv6=on|off]\n [status_zone=zone];
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n upstream
\n

This directive appeared in version 1.27.3.\n

\nConfigures name servers used to resolve names of upstream servers\ninto addresses, for example:\n

\nresolver 127.0.0.1 [::1]:5353;\n

\nThe address can be specified as a domain name or IP address,\nwith an optional port.\nIf port is not specified, the port 53 is used.\nName servers are queried in a round-robin fashion.\n

\nBy default, nginx will look up both IPv4 and IPv6 addresses while resolving.\nIf looking up of IPv4 or IPv6 addresses is not desired,\nthe ipv4=off (1.23.1) or\nthe ipv6=off parameter can be specified.\n

\nBy default, nginx caches answers using the TTL value of a response.\nAn optional valid parameter allows overriding it:\n

\nresolver 127.0.0.1 [::1]:5353 valid=30s;\n

\n

\nTo prevent DNS spoofing, it is recommended\nconfiguring DNS servers in a properly secured trusted local network.\n

\n

\nThe optional status_zone parameter (1.17.5)\nenables\ncollection\nof DNS server statistics of requests and responses\nin the specified zone.\nThe parameter is available as part of our\ncommercial subscription.\n

\n

\nSince version 1.17.5 and prior to version 1.27.3,\nthis directive was available only as part of our\ncommercial subscription.\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n resolver_timeout time;
\n
\n Default:\n \n
resolver_timeout 30s;
\n
\n Context:\n \n upstream
\n

This directive appeared in version 1.27.3.\n

\nSets a timeout for name resolution, for example:\n

\nresolver_timeout 5s;\n

\n

\n

\nSince version 1.17.5 and prior to version 1.27.3,\nthis directive was available only as part of our\ncommercial subscription.\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n sticky \n cookie name\n [expires=time]\n [domain=domain]\n [httponly]\n [samesite=strict|lax|none|$variable]\n [secure]\n [path=path];
sticky \n route $variable ...;
sticky \n learn\n create=$variable\n lookup=$variable\n zone=name:size\n [timeout=time]\n [header]\n [sync];
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n upstream
\n

This directive appeared in version 1.5.7.\n

\nEnables session affinity, which causes requests from the same client to be\npassed to the same server in a group of servers.\nThree methods are available:\n

\n
cookie
\n
\n\n

\nWhen the cookie method is used, information about the\ndesignated server is passed in an HTTP cookie generated by nginx:\n

\nupstream backend {\n    server backend1.example.com;\n    server backend2.example.com;\n\n    sticky cookie srv_id expires=1h domain=.example.com path=/;\n}\n

\n

\n\n

\nA request that comes from a client not yet bound to a particular server\nis passed to the server selected by the configured balancing method.\nFurther requests with this cookie will be passed to the designated server.\nIf the designated server cannot process a request, the new server is\nselected as if the client has not been bound yet.\n\n

\nAs a load balancing method always tries to evenly distribute the load\nconsidering already bound requests,\nthe server with a higher number of active bound requests\nhas less possibility of getting new unbound requests.\n

\n

\n\n

\nThe first parameter sets the name of the cookie to be set or inspected.\nThe cookie value is\na hexadecimal representation of the MD5 hash of the IP address and port,\nor of the UNIX-domain socket path.\nHowever, if the “route” parameter of the\nserver directive is specified, the cookie value will be\nthe value of the “route” parameter:\n

\nupstream backend {\n    server backend1.example.com route=a;\n    server backend2.example.com route=b;\n\n    sticky cookie srv_id expires=1h domain=.example.com path=/;\n}\n

\nIn this case, the value of the “srv_id” cookie will be\neither a or b.\n

\n\n

\nAdditional parameters may be as follows:\n

\n\n
expires=time
\n
\nSets the time for which a browser should keep the cookie.\nThe special value max will cause the cookie to expire on\n“31 Dec 2037 23:55:55 GMT”.\nIf the parameter is not specified, it will cause the cookie to expire at\nthe end of a browser session.\n
\n\n
domain=domain
\n
\nDefines the domain for which the cookie is set.\nParameter value can contain variables (1.11.5).\n
\n\n
httponly
\n
\nAdds the HttpOnly attribute to the cookie (1.7.11).\n
\n\n
samesite=strict |\nlax | none | $variable
\n
\nAdds the SameSite (1.19.4) attribute to the cookie\nwith one of the following values:\nStrict,\nLax,\nNone, or\nusing variables (1.23.3).\nIn the latter case, if the variable value is empty,\nthe SameSite attribute will not be added to the cookie,\nif the value is resolved to\nStrict,\nLax, or\nNone,\nthe corresponding value will be assigned,\notherwise the Strict value will be assigned.\n
\n\n
secure
\n
\nAdds the Secure attribute to the cookie (1.7.11).\n
\n\n
path=path
\n
\nDefines the path for which the cookie is set.\n
\n\n

\nIf any parameters are omitted, the corresponding cookie fields are not set.\n

\n
\n\n
route
\n
\n\n

\nWhen the route method is used, proxied server assigns\nclient a route on receipt of the first request.\nAll subsequent requests from this client will carry routing information\nin a cookie or URI.\nThis information is compared with the “route” parameter\nof the server directive to identify the server to which the\nrequest should be proxied.\nIf the “route” parameter is not specified, the route name\nwill be a hexadecimal representation of the MD5 hash of the IP address and port,\nor of the UNIX-domain socket path.\nIf the designated server cannot process a request, the new server is\nselected by the configured balancing method as if there is no routing\ninformation in the request.\n

\n\n

\nThe parameters of the route method specify variables that\nmay contain routing information.\nThe first non-empty variable is used to find the matching server.\n

\n\n

\nExample:\n

\nmap $cookie_jsessionid $route_cookie {\n    ~.+\\.(?P<route>\\w+)$ $route;\n}\n\nmap $request_uri $route_uri {\n    ~jsessionid=.+\\.(?P<route>\\w+)$ $route;\n}\n\nupstream backend {\n    server backend1.example.com route=a;\n    server backend2.example.com route=b;\n\n    sticky route $route_cookie $route_uri;\n}\n

\nHere, the route is taken from the “JSESSIONID” cookie\nif present in a request.\nOtherwise, the route from the URI is used.\n

\n\n
\n\n
learn
\n
\n

\nWhen the learn method (1.7.1) is used, nginx\nanalyzes upstream server responses and learns server-initiated sessions\nusually passed in an HTTP cookie.\n

\nupstream backend {\n   server backend1.example.com:8080;\n   server backend2.example.com:8081;\n\n   sticky learn\n          create=$upstream_cookie_examplecookie\n          lookup=$cookie_examplecookie\n          zone=client_sessions:1m;\n}\n

\n\nIn the example, the upstream server creates a session by setting the\ncookie “EXAMPLECOOKIE” in the response.\nFurther requests with this cookie will be passed to the same server.\nIf the server cannot process the request, the new server is\nselected as if the client has not been bound yet.\n

\n\n

\nThe parameters create and lookup\nspecify variables that indicate how new sessions are created and existing\nsessions are searched, respectively.\nBoth parameters may be specified more than once, in which case the first\nnon-empty variable is used.\n

\n\n

\nSessions are stored in a shared memory zone, whose name and\nsize are configured by the zone parameter.\nOne megabyte zone can store about 4000 sessions on the 64-bit platform.\nThe sessions that are not accessed during the time specified by the\ntimeout parameter get removed from the zone.\nBy default, timeout is set to 10 minutes.\n

\n\n

\nThe header parameter (1.13.1) allows creating a session\nright after receiving response headers from the upstream server.\n

\n\n

\nThe sync parameter (1.13.8) enables\nsynchronization\nof the shared memory zone.\nThe parameter is available as part of our\ncommercial subscription.\n

\n\n
\n

\n

\n

\nPrior to version 1.29.6,\nthis directive was available only as part of our\ncommercial subscription.\n

\n

\n\n\n

Embedded Variables

\nThe ngx_http_upstream_module module\nsupports the following embedded variables:\n

\n\n
$upstream_addr
\n
\nkeeps the IP address and port,\nor the path to the UNIX-domain socket of the upstream server.\nIf several servers were contacted during request processing,\ntheir addresses are separated by commas, e.g.\n“192.168.1.1:80, 192.168.1.2:80, unix:/tmp/sock”.\nIf an internal redirect from one server group to another happens,\ninitiated by\n“X-Accel-Redirect” or\nerror_page,\nthen the server addresses from different groups are separated by colons, e.g.\n“192.168.1.1:80, 192.168.1.2:80, unix:/tmp/sock : 192.168.10.1:80, 192.168.10.2:80”.\nIf a server cannot be selected,\nthe variable keeps the name of the server group.\n
\n\n
$upstream_bytes_received
\n
\nnumber of bytes received from an upstream server (1.11.4).\nValues from several connections\nare separated by commas and colons like addresses in the\n$upstream_addr variable.\n
\n\n
$upstream_bytes_sent
\n
\nnumber of bytes sent to an upstream server (1.15.8).\nValues from several connections\nare separated by commas and colons like addresses in the\n$upstream_addr variable.\n
\n\n
$upstream_cache_status\n
\n
\nkeeps the status of accessing a response cache (0.8.3).\nThe status can be either “MISS”,\n“BYPASS”, “EXPIRED”,\n“STALE”, “UPDATING”,\n“REVALIDATED”, or “HIT”.\n
\n\n
$upstream_connect_time\n
\n
\nkeeps time spent on establishing a connection with the upstream server (1.9.1);\nthe time is kept in seconds with millisecond resolution.\nIn case of SSL, includes time spent on handshake.\nTimes of several connections\nare separated by commas and colons like addresses in the\n$upstream_addr variable.\n
\n\n\n
\ncookie with the specified name sent by the upstream server\nin the “Set-Cookie” response header field (1.7.1).\nOnly the cookies from the response of the last server are saved.\n
\n\n
$upstream_header_time\n
\n
\nkeeps time\nspent on receiving the response header from the upstream server (1.7.10);\nthe time is kept in seconds with millisecond resolution.\nTimes of several responses\nare separated by commas and colons like addresses in the\n$upstream_addr variable.\n
\n\n
$upstream_http_name
\n
\nkeep server response header fields.\nFor example, the “Server” response header field\nis available through the $upstream_http_server variable.\nThe rules of converting header field names to variable names are the same\nas for the variables that start with the\n“$http_” prefix.\nOnly the header fields from the response of the last server are saved.\n
\n\n
$upstream_last_addr
\n
\nkeeps the IP address or the path to the UNIX-domain socket\nof the last selected upstream server (1.29.3).\n\n

\n

\nThis variable is available as part of our\ncommercial subscription.\n

\n

\n\n
\n\n
$upstream_last_server_name
\n
\nkeeps the name of last selected upstream server (1.25.3);\nallows passing it\nthrough SNI:\n
\nproxy_ssl_server_name on;\nproxy_ssl_name        $upstream_last_server_name;\n
\n\n

\n

\nThis variable is available as part of our\ncommercial subscription.\n

\n

\n\n
\n\n
$upstream_queue_time
\n
\nkeeps time the request spent in the upstream queue\n(1.13.9);\nthe time is kept in seconds with millisecond resolution.\nTimes of several responses\nare separated by commas and colons like addresses in the\n$upstream_addr variable.\n
\n\n
$upstream_response_length\n
\n
\nkeeps the length of the response obtained from the upstream server (0.7.27);\nthe length is kept in bytes.\nLengths of several responses\nare separated by commas and colons like addresses in the\n$upstream_addr variable.\n
\n\n
$upstream_response_time\n
\n
\nkeeps time spent on receiving the response from the upstream server;\nthe time is kept in seconds with millisecond resolution.\nTimes of several responses\nare separated by commas and colons like addresses in the\n$upstream_addr variable.\n
\n\n
$upstream_status
\n
\nkeeps status code of the response obtained from the upstream server.\nStatus codes of several responses\nare separated by commas and colons like addresses in the\n$upstream_addr variable.\nIf a server cannot be selected,\nthe variable keeps the 502 (Bad Gateway) status code.\n
\n\n
$upstream_trailer_name
\n
\nkeeps fields from the end of the response\nobtained from the upstream server (1.13.10).\n
\n\n

\n

\n\n
\n", "encoding": "utf-8"} +{"path": "en\\docs\\http\\ngx_http_userid_module.html", "extension": ".html", "size_bytes": 14701, "content": "\nModule ngx_http_userid_module
\n\nPlanning your ingress-nginx migration? Start here:\nkubernetes.nginx.org.\n\n

Module ngx_http_userid_module

Example Configuration
Directives
     userid
     userid_domain
     userid_expires
     userid_flags
     userid_mark
     userid_name
     userid_p3p
     userid_path
     userid_service
Embedded Variables
\n\n

\nThe ngx_http_userid_module module sets cookies\nsuitable for client identification.\nReceived and set cookies can be logged using the embedded variables\n$uid_got and\n$uid_set.\nThis module is compatible with the\nmod_uid\nmodule for Apache.\n

\n\n\n

Example Configuration

\n

\nuserid         on;\nuserid_name    uid;\nuserid_domain  example.com;\nuserid_path    /;\nuserid_expires 365d;\nuserid_p3p     'policyref=\"/w3c/p3p.xml\", CP=\"CUR ADM OUR NOR STA NID\"';\n

\n

\n\n\n

Directives

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n userid \n on |\n v1 |\n log |\n off;
\n
\n Default:\n \n
userid off;
\n
\n Context:\n \n http, server, location
\n

\nEnables or disables setting cookies and logging the received cookies:\n

\n\n
on
\n
\nenables the setting of version 2 cookies\nand logging of the received cookies;\n
\n\n
v1
\n
\nenables the setting of version 1 cookies\nand logging of the received cookies;\n
\n\n
log
\n
\ndisables the setting of cookies,\nbut enables logging of the received cookies;\n
\n\n
off
\n
\ndisables the setting of cookies and logging of the received cookies.\n
\n\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n userid_domain name | none;
\n
\n Default:\n \n
userid_domain none;
\n
\n Context:\n \n http, server, location
\n

\nDefines a domain for which the cookie is set.\nThe none parameter disables setting of a domain for the\ncookie.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n userid_expires time | max |\n off;
\n
\n Default:\n \n
userid_expires off;
\n
\n Context:\n \n http, server, location
\n

\nSets a time during which a browser should keep the cookie.\nThe parameter max will cause the cookie to expire on\n“31 Dec 2037 23:55:55 GMT”.\nThe parameter off will cause the cookie to expire at\nthe end of a browser session.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n userid_flags \n off |\n flag ...;
\n
\n Default:\n \n
userid_flags off;
\n
\n Context:\n \n http, server, location
\n

This directive appeared in version 1.19.3.\n

\nIf the parameter is not off,\ndefines one or more additional flags for the cookie:\nsecure,\nhttponly,\nsamesite=strict,\nsamesite=lax,\nsamesite=none.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n userid_mark \n letter | digit |\n = |\n off;
\n
\n Default:\n \n
userid_mark off;
\n
\n Context:\n \n http, server, location
\n

\nIf the parameter is not off, enables the cookie marking\nmechanism and sets the character used as a mark.\nThis mechanism is used to add or change\nuserid_p3p and/or a cookie expiration time while\npreserving the client identifier.\nA mark can be any letter of the English alphabet (case-sensitive),\ndigit, or the “=” character.\n

\nIf the mark is set, it is compared with the first padding symbol\nin the base64 representation of the client identifier passed in a cookie.\nIf they do not match, the cookie is resent with the specified mark,\nexpiration time, and “P3P” header.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n userid_name name;
\n
\n Default:\n \n
userid_name uid;
\n
\n Context:\n \n http, server, location
\n

\nSets the cookie name.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n userid_p3p string | none;
\n
\n Default:\n \n
userid_p3p none;
\n
\n Context:\n \n http, server, location
\n

\nSets a value for the “P3P” header field that will be\nsent along with the cookie.\nIf the directive is set to the special value none,\nthe “P3P” header will not be sent in a response.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n userid_path path;
\n
\n Default:\n \n
userid_path /;
\n
\n Context:\n \n http, server, location
\n

\nDefines a path for which the cookie is set.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n userid_service number;
\n
\n Default:\n \n
userid_service IP address of the server;
\n
\n Context:\n \n http, server, location
\n

\nIf identifiers are issued by multiple servers (services),\neach service should be assigned its own number\nto ensure that client identifiers are unique.\nFor version 1 cookies, the default value is zero.\nFor version 2 cookies, the default value is the number composed from the last\nfour octets of the server’s IP address.\n

\n\n\n

Embedded Variables

\nThe ngx_http_userid_module module\nsupports the following embedded variables:\n

\n\n
$uid_got
\n
\nThe cookie name and received client identifier.\n
\n\n
$uid_reset
\n
\nIf the variable is set to a non-empty string that is not “0”,\nthe client identifiers are reset.\nThe special value “log” additionally leads to the output of\nmessages about the reset identifiers to the\nerror_log.\n
\n\n
$uid_set
\n
\nThe cookie name and sent client identifier.\n
\n\n

\n

\n\n
\n", "encoding": "utf-8"} +{"path": "en\\docs\\http\\ngx_http_uwsgi_module.html", "extension": ".html", "size_bytes": 106082, "content": "\nModule ngx_http_uwsgi_module
\n\nPlanning your ingress-nginx migration? Start here:\nkubernetes.nginx.org.\n\n

Module ngx_http_uwsgi_module

Example Configuration
Directives
     uwsgi_allow_upstream
     uwsgi_bind
     uwsgi_bind_dynamic
     uwsgi_buffer_size
     uwsgi_buffering
     uwsgi_buffers
     uwsgi_busy_buffers_size
     uwsgi_cache
     uwsgi_cache_background_update
     uwsgi_cache_bypass
     uwsgi_cache_key
     uwsgi_cache_lock
     uwsgi_cache_lock_age
     uwsgi_cache_lock_timeout
     uwsgi_cache_max_range_offset
     uwsgi_cache_methods
     uwsgi_cache_min_uses
     uwsgi_cache_path
     uwsgi_cache_purge
     uwsgi_cache_revalidate
     uwsgi_cache_use_stale
     uwsgi_cache_valid
     uwsgi_connect_timeout
     uwsgi_force_ranges
     uwsgi_hide_header
     uwsgi_ignore_client_abort
     uwsgi_ignore_headers
     uwsgi_intercept_errors
     uwsgi_limit_rate
     uwsgi_max_temp_file_size
     uwsgi_modifier1
     uwsgi_modifier2
     uwsgi_next_upstream
     uwsgi_next_upstream_timeout
     uwsgi_next_upstream_tries
     uwsgi_no_cache
     uwsgi_param
     uwsgi_pass
     uwsgi_pass_header
     uwsgi_pass_request_body
     uwsgi_pass_request_headers
     uwsgi_read_timeout
     uwsgi_request_buffering
     uwsgi_request_dynamic
     uwsgi_send_timeout
     uwsgi_socket_keepalive
     uwsgi_ssl_certificate
     uwsgi_ssl_certificate_cache
     uwsgi_ssl_certificate_key
     uwsgi_ssl_ciphers
     uwsgi_ssl_conf_command
     uwsgi_ssl_crl
     uwsgi_ssl_key_log
     uwsgi_ssl_name
     uwsgi_ssl_password_file
     uwsgi_ssl_protocols
     uwsgi_ssl_server_name
     uwsgi_ssl_session_reuse
     uwsgi_ssl_trusted_certificate
     uwsgi_ssl_verify
     uwsgi_ssl_verify_depth
     uwsgi_store
     uwsgi_store_access
     uwsgi_temp_file_write_size
     uwsgi_temp_path
\n\n

\nThe ngx_http_uwsgi_module module allows passing\nrequests to a uwsgi server.\n

\n\n\n

Example Configuration

\n

\nlocation / {\n    include    uwsgi_params;\n    uwsgi_pass localhost:9000;\n}\n

\n

\n\n\n

Directives

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n uwsgi_allow_upstream string ...;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n http, server, location
\n

This directive appeared in version 1.29.3.\n

\nDefines conditions under which access to a uwsgi server\nis allowed or denied.\nIf all string parameters are not empty\nand not equal to “0” then the access is allowed.\nThe conditions are evaluated each time\nbefore a connection to a uwsgi server is established.\nParameter values can contain variables:\n

\ngeo $upstream_last_addr $allow {\n    volatile;\n    10.10.0.0/24        1;\n}\n\nserver {\n    listen 127.0.0.1:8080;\n\n    location / {\n        uwsgi_pass           localhost:9000;\n        uwsgi_allow_upstream $allow;\n        ...\n    }\n}\n

\n

\n

\nThis directive is available as part of our\ncommercial subscription.\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n uwsgi_bind \n address\n [transparent] |\n off;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n http, server, location
\n

\nMakes outgoing connections to a uwsgi server originate\nfrom the specified local IP address with an optional port (1.11.2).\nParameter value can contain variables (1.3.12).\nThe special value off (1.3.12) cancels the effect\nof the uwsgi_bind directive\ninherited from the previous configuration level, which allows the\nsystem to auto-assign the local IP address and port.\n

\nThe transparent parameter (1.11.0) allows\noutgoing connections to a uwsgi server originate\nfrom a non-local IP address,\nfor example, from a real IP address of a client:\n

\nuwsgi_bind $remote_addr transparent;\n

\nIn order for this parameter to work,\nit is usually necessary to run nginx worker processes with the\nsuperuser privileges.\nOn Linux it is not required (1.13.8) as if\nthe transparent parameter is specified, worker processes\ninherit the CAP_NET_RAW capability from the master process.\nIt is also necessary to configure kernel routing table\nto intercept network traffic from the uwsgi server.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n uwsgi_bind_dynamic on | off;
\n
\n Default:\n \n
uwsgi_bind_dynamic off;
\n
\n Context:\n \n http, server, location
\n

This directive appeared in version 1.29.3.\n

\nWhen enabled, makes the bind operation\nat each connection attempt.\n

\n

\nThis directive is available as part of our\ncommercial subscription.\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n uwsgi_buffer_size size;
\n
\n Default:\n \n
uwsgi_buffer_size 4k|8k;
\n
\n Context:\n \n http, server, location
\n

\nSets the size of the buffer used for reading the first part\nof the response received from the uwsgi server.\nThis part usually contains a small response header;\nif it exceeds the buffer size, the response is considered\ninvalid.\nBy default, the buffer size is equal to one memory page.\nThis is either 4K or 8K, depending on a platform.\nIt can be made smaller, however.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n uwsgi_buffering on | off;
\n
\n Default:\n \n
uwsgi_buffering on;
\n
\n Context:\n \n http, server, location
\n

\nEnables or disables buffering of responses from the uwsgi server.\n

\nWhen buffering is enabled, nginx receives a response from the uwsgi server\nas soon as possible, saving it into the buffers set by the\nuwsgi_buffer_size and uwsgi_buffers directives.\nIf the whole response does not fit into memory, a part of it can be saved\nto a temporary file on the disk.\nWriting to temporary files is controlled by the\nuwsgi_max_temp_file_size and\nuwsgi_temp_file_write_size directives.\n

\nWhen buffering is disabled, the response is passed to a client synchronously,\nimmediately as it is received.\nnginx will not try to read the whole response from the uwsgi server.\nThe maximum size of the data that nginx can receive from the server\nat a time is set by the uwsgi_buffer_size directive.\n

\nBuffering can also be enabled or disabled by passing\n“yes” or “no” in the\n“X-Accel-Buffering” response header field.\nThis capability can be disabled using the\nuwsgi_ignore_headers directive.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n uwsgi_buffers number size;
\n
\n Default:\n \n
uwsgi_buffers 8 4k|8k;
\n
\n Context:\n \n http, server, location
\n

\nSets the number and size of the\nbuffers used for reading a response from the uwsgi server,\nfor a single connection.\nBy default, the buffer size is equal to one memory page.\nThis is either 4K or 8K, depending on a platform.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n uwsgi_busy_buffers_size size;
\n
\n Default:\n \n
uwsgi_busy_buffers_size 8k|16k;
\n
\n Context:\n \n http, server, location
\n

\nWhen buffering of responses from the uwsgi\nserver is enabled, limits the total size of buffers that\ncan be busy sending a response to the client while the response is not\nyet fully read.\nIn the meantime, the rest of the buffers can be used for reading the response\nand, if needed, buffering part of the response to a temporary file.\nBy default, size is limited by the size of two buffers set by the\nuwsgi_buffer_size and uwsgi_buffers directives.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n uwsgi_cache zone | off;
\n
\n Default:\n \n
uwsgi_cache off;
\n
\n Context:\n \n http, server, location
\n

\nDefines a shared memory zone used for caching.\nThe same zone can be used in several places.\nParameter value can contain variables (1.7.9).\nThe off parameter disables caching inherited\nfrom the previous configuration level.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n uwsgi_cache_background_update on | off;
\n
\n Default:\n \n
uwsgi_cache_background_update off;
\n
\n Context:\n \n http, server, location
\n

This directive appeared in version 1.11.10.\n

\nAllows starting a background subrequest\nto update an expired cache item,\nwhile a stale cached response is returned to the client.\nNote that it is necessary to\nallow\nthe usage of a stale cached response when it is being updated.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n uwsgi_cache_bypass string ...;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n http, server, location
\n

\nDefines conditions under which the response will not be taken from a cache.\nIf at least one value of the string parameters is not empty and is not\nequal to “0” then the response will not be taken from the cache:\n

\nuwsgi_cache_bypass $cookie_nocache $arg_nocache$arg_comment;\nuwsgi_cache_bypass $http_pragma    $http_authorization;\n

\nCan be used along with the uwsgi_no_cache directive.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n uwsgi_cache_key string;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n http, server, location
\n

\nDefines a key for caching, for example\n

\nuwsgi_cache_key localhost:9000$request_uri;\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n uwsgi_cache_lock on | off;
\n
\n Default:\n \n
uwsgi_cache_lock off;
\n
\n Context:\n \n http, server, location
\n

This directive appeared in version 1.1.12.\n

\nWhen enabled, only one request at a time will be allowed to populate\na new cache element identified according to the uwsgi_cache_key\ndirective by passing a request to a uwsgi server.\nOther requests of the same cache element will either wait\nfor a response to appear in the cache or the cache lock for\nthis element to be released, up to the time set by the\nuwsgi_cache_lock_timeout directive.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n uwsgi_cache_lock_age time;
\n
\n Default:\n \n
uwsgi_cache_lock_age 5s;
\n
\n Context:\n \n http, server, location
\n

This directive appeared in version 1.7.8.\n

\nIf the last request passed to the uwsgi server\nfor populating a new cache element\nhas not completed for the specified time,\none more request may be passed to the uwsgi server.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n uwsgi_cache_lock_timeout time;
\n
\n Default:\n \n
uwsgi_cache_lock_timeout 5s;
\n
\n Context:\n \n http, server, location
\n

This directive appeared in version 1.1.12.\n

\nSets a timeout for uwsgi_cache_lock.\nWhen the time expires,\nthe request will be passed to the uwsgi server,\nhowever, the response will not be cached.\n

\nBefore 1.7.8, the response could be cached.\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n uwsgi_cache_max_range_offset number;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n http, server, location
\n

This directive appeared in version 1.11.6.\n

\nSets an offset in bytes for byte-range requests.\nIf the range is beyond the offset,\nthe range request will be passed to the uwsgi server\nand the response will not be cached.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n uwsgi_cache_methods \n GET |\n HEAD |\n POST\n ...;
\n
\n Default:\n \n
uwsgi_cache_methods GET HEAD;
\n
\n Context:\n \n http, server, location
\n

\nIf the client request method is listed in this directive then\nthe response will be cached.\n“GET” and “HEAD” methods are always\nadded to the list, though it is recommended to specify them explicitly.\nSee also the uwsgi_no_cache directive.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n uwsgi_cache_min_uses number;
\n
\n Default:\n \n
uwsgi_cache_min_uses 1;
\n
\n Context:\n \n http, server, location
\n

\nSets the number of requests after which the response\nwill be cached.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n uwsgi_cache_path \n path\n [levels=levels]\n [use_temp_path=on|off]\n keys_zone=name:size\n [inactive=time]\n [max_size=size]\n [min_free=size]\n [manager_files=number]\n [manager_sleep=time]\n [manager_threshold=time]\n [loader_files=number]\n [loader_sleep=time]\n [loader_threshold=time]\n [purger=on|off]\n [purger_files=number]\n [purger_sleep=time]\n [purger_threshold=time];
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n http
\n

\nSets the path and other parameters of a cache.\nCache data are stored in files.\nThe file name in a cache is a result of\napplying the MD5 function to the\ncache key.\nThe levels parameter defines hierarchy levels of a cache:\nfrom 1 to 3, each level accepts values 1 or 2.\nFor example, in the following configuration\n

\nuwsgi_cache_path /data/nginx/cache levels=1:2 keys_zone=one:10m;\n

\nfile names in a cache will look like this:\n

\n/data/nginx/cache/c/29/b7f54b2df7773722d382f4809d65029c\n

\n

\nA cached response is first written to a temporary file,\nand then the file is renamed.\nStarting from version 0.8.9, temporary files and the cache can be put on\ndifferent file systems.\nHowever, be aware that in this case a file is copied\nacross two file systems instead of the cheap renaming operation.\nIt is thus recommended that for any given location both cache and a directory\nholding temporary files\nare put on the same file system.\nA directory for temporary files is set based on\nthe use_temp_path parameter (1.7.10).\nIf this parameter is omitted or set to the value on,\nthe directory set by the uwsgi_temp_path directive\nfor the given location will be used.\nIf the value is set to off,\ntemporary files will be put directly in the cache directory.\n

\nIn addition, all active keys and information about data are stored\nin a shared memory zone, whose name and size\nare configured by the keys_zone parameter.\nOne megabyte zone can store about 8 thousand keys.\n

\nAs part of\ncommercial subscription,\nthe shared memory zone also stores extended\ncache information,\nthus, it is required to specify a larger zone size for the same number of keys.\nFor example,\none megabyte zone can store about 4 thousand keys.\n

\n

\nCached data that are not accessed during the time specified by the\ninactive parameter get removed from the cache\nregardless of their freshness.\nBy default, inactive is set to 10 minutes.\n

\nThe special “cache manager” process monitors the maximum cache size set\nby the max_size parameter,\nand the minimum amount of free space set\nby the min_free (1.19.1) parameter\non the file system with cache.\nWhen the size is exceeded or there is not enough free space,\nit removes the least recently used data.\nThe data is removed in iterations configured by\nmanager_files,\nmanager_threshold, and\nmanager_sleep parameters (1.11.5).\nDuring one iteration no more than manager_files items\nare deleted (by default, 100).\nThe duration of one iteration is limited by the\nmanager_threshold parameter (by default, 200 milliseconds).\nBetween iterations, a pause configured by the manager_sleep\nparameter (by default, 50 milliseconds) is made.\n

\nA minute after the start the special “cache loader” process is activated.\nIt loads information about previously cached data stored on file system\ninto a cache zone.\nThe loading is also done in iterations.\nDuring one iteration no more than loader_files items\nare loaded (by default, 100).\nBesides, the duration of one iteration is limited by the\nloader_threshold parameter (by default, 200 milliseconds).\nBetween iterations, a pause configured by the loader_sleep\nparameter (by default, 50 milliseconds) is made.\n

\nAdditionally,\nthe following parameters are available as part of our\ncommercial subscription:\n

\n

\n\n
\npurger=on|off\n
\n
\nInstructs whether cache entries that match a\nwildcard key\nwill be removed from the disk by the cache purger (1.7.12).\nSetting the parameter to on\n(default is off)\nwill activate the “cache purger” process that\npermanently iterates through all cache entries\nand deletes the entries that match the wildcard key.\n
\n\n
\npurger_files=number\n
\n
\nSets the number of items that will be scanned during one iteration (1.7.12).\nBy default, purger_files is set to 10.\n
\n\n
\npurger_threshold=number\n
\n
\nSets the duration of one iteration (1.7.12).\nBy default, purger_threshold is set to 50 milliseconds.\n
\n\n
\npurger_sleep=number\n
\n
\nSets a pause between iterations (1.7.12).\nBy default, purger_sleep is set to 50 milliseconds.\n
\n\n

\n

\n

\nIn versions 1.7.3, 1.7.7, and 1.11.10 cache header format has been changed.\nPreviously cached responses will be considered invalid\nafter upgrading to a newer nginx version.\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n uwsgi_cache_purge string ...;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n http, server, location
\n

This directive appeared in version 1.5.7.\n

\nDefines conditions under which the request will be considered a cache\npurge request.\nIf at least one value of the string parameters is not empty and is not equal\nto “0” then the cache entry with a corresponding\ncache key is removed.\nThe result of successful operation is indicated by returning\nthe 204 (No Content) response.\n

\nIf the cache key of a purge request ends\nwith an asterisk (“*”), all cache entries matching the\nwildcard key will be removed from the cache.\nHowever, these entries will remain on the disk until they are deleted\nfor either inactivity,\nor processed by the cache purger (1.7.12),\nor a client attempts to access them.\n

\nExample configuration:\n

\nuwsgi_cache_path /data/nginx/cache keys_zone=cache_zone:10m;\n\nmap $request_method $purge_method {\n    PURGE   1;\n    default 0;\n}\n\nserver {\n    ...\n    location / {\n        uwsgi_pass        backend;\n        uwsgi_cache       cache_zone;\n        uwsgi_cache_key   $uri;\n        uwsgi_cache_purge $purge_method;\n    }\n}\n

\n

\nThis functionality is available as part of our\ncommercial subscription.\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n uwsgi_cache_revalidate on | off;
\n
\n Default:\n \n
uwsgi_cache_revalidate off;
\n
\n Context:\n \n http, server, location
\n

This directive appeared in version 1.5.7.\n

\nEnables revalidation of expired cache items using conditional requests with\nthe “If-Modified-Since” and “If-None-Match”\nheader fields.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n uwsgi_cache_use_stale \n error |\n timeout |\n invalid_header |\n updating |\n http_500 |\n http_503 |\n http_403 |\n http_404 |\n http_429 |\n off\n ...;
\n
\n Default:\n \n
uwsgi_cache_use_stale off;
\n
\n Context:\n \n http, server, location
\n

\nDetermines in which cases a stale cached response can be used\nwhen an error occurs during communication with the uwsgi server.\nThe directive’s parameters match the parameters of the\nuwsgi_next_upstream directive.\n

\nThe error parameter also permits\nusing a stale cached response if a uwsgi server to process a request\ncannot be selected.\n

\nAdditionally, the updating parameter permits\nusing a stale cached response if it is currently being updated.\nThis allows minimizing the number of accesses to uwsgi servers\nwhen updating cached data.\n

\nUsing a stale cached response\ncan also be enabled directly in the response header\nfor a specified number of seconds after the response became stale (1.11.10).\nThis has lower priority than using the directive parameters.\n

\n

\nTo minimize the number of accesses to uwsgi servers when\npopulating a new cache element, the uwsgi_cache_lock\ndirective can be used.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n uwsgi_cache_valid [code ...] time;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n http, server, location
\n

\nSets caching time for different response codes.\nFor example, the following directives\n

\nuwsgi_cache_valid 200 302 10m;\nuwsgi_cache_valid 404      1m;\n

\nset 10 minutes of caching for responses with codes 200 and 302\nand 1 minute for responses with code 404.\n

\nIf only caching time is specified\n

\nuwsgi_cache_valid 5m;\n

\nthen only 200, 301, and 302 responses are cached.\n

\nIn addition, the any parameter can be specified\nto cache any responses:\n

\nuwsgi_cache_valid 200 302 10m;\nuwsgi_cache_valid 301      1h;\nuwsgi_cache_valid any      1m;\n

\n

\nParameters of caching can also be set directly\nin the response header.\nThis has higher priority than setting of caching time using the directive.\n

\nProcessing of one or more of these response header fields can be disabled\nusing the uwsgi_ignore_headers directive.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n uwsgi_connect_timeout time;
\n
\n Default:\n \n
uwsgi_connect_timeout 60s;
\n
\n Context:\n \n http, server, location
\n

\nDefines a timeout for establishing a connection with a uwsgi server.\nIt should be noted that this timeout cannot usually exceed 75 seconds.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n uwsgi_force_ranges on | off;
\n
\n Default:\n \n
uwsgi_force_ranges off;
\n
\n Context:\n \n http, server, location
\n

This directive appeared in version 1.7.7.\n

\nEnables byte-range support\nfor both cached and uncached responses from the uwsgi server\nregardless of the “Accept-Ranges” field in these responses.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n uwsgi_hide_header field;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n http, server, location
\n

\nBy default,\nnginx does not pass the header fields “Status” and\n“X-Accel-...” from the response of a uwsgi\nserver to a client.\nThe uwsgi_hide_header directive sets additional fields\nthat will not be passed.\nIf, on the contrary, the passing of fields needs to be permitted,\nthe uwsgi_pass_header directive can be used.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n uwsgi_ignore_client_abort on | off;
\n
\n Default:\n \n
uwsgi_ignore_client_abort off;
\n
\n Context:\n \n http, server, location
\n

\nDetermines whether the connection with a uwsgi server should be\nclosed when a client closes the connection without waiting\nfor a response.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n uwsgi_ignore_headers field ...;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n http, server, location
\n

\nDisables processing of certain response header fields from the uwsgi server.\nThe following fields can be ignored: “X-Accel-Redirect”,\n“X-Accel-Expires”, “X-Accel-Limit-Rate” (1.1.6),\n“X-Accel-Buffering” (1.1.6),\n“X-Accel-Charset” (1.1.6), “Expires”,\n“Cache-Control”, “Set-Cookie” (0.8.44),\nand “Vary” (1.7.7).\n

\nIf not disabled, processing of these header fields has the following\neffect:\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n uwsgi_intercept_errors on | off;
\n
\n Default:\n \n
uwsgi_intercept_errors off;
\n
\n Context:\n \n http, server, location
\n

\nDetermines whether a uwsgi server responses with codes greater than or equal\nto 300 should be passed to a client\nor be intercepted and redirected to nginx for processing\nwith the error_page directive.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n uwsgi_limit_rate rate;
\n
\n Default:\n \n
uwsgi_limit_rate 0;
\n
\n Context:\n \n http, server, location
\n

This directive appeared in version 1.7.7.\n

\nLimits the speed of reading the response from the uwsgi server.\nThe rate is specified in bytes per second.\nThe zero value disables rate limiting.\nThe limit is set per a request, and so if nginx simultaneously opens\ntwo connections to the uwsgi server,\nthe overall rate will be twice as much as the specified limit.\nThe limitation works only if\nbuffering of responses from the uwsgi\nserver is enabled.\nParameter value can contain variables (1.27.0).\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n uwsgi_max_temp_file_size size;
\n
\n Default:\n \n
uwsgi_max_temp_file_size 1024m;
\n
\n Context:\n \n http, server, location
\n

\nWhen buffering of responses from the uwsgi\nserver is enabled, and the whole response does not fit into the buffers\nset by the uwsgi_buffer_size and uwsgi_buffers\ndirectives, a part of the response can be saved to a temporary file.\nThis directive sets the maximum size of the temporary file.\nThe size of data written to the temporary file at a time is set\nby the uwsgi_temp_file_write_size directive.\n

\nThe zero value disables buffering of responses to temporary files.\n

\n

\nThis restriction does not apply to responses\nthat will be cached\nor stored on disk.\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n uwsgi_modifier1 number;
\n
\n Default:\n \n
uwsgi_modifier1 0;
\n
\n Context:\n \n http, server, location
\n

\nSets the value of the modifier1 field in the\nuwsgi\npacket header.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n uwsgi_modifier2 number;
\n
\n Default:\n \n
uwsgi_modifier2 0;
\n
\n Context:\n \n http, server, location
\n

\nSets the value of the modifier2 field in the\nuwsgi\npacket header.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n uwsgi_next_upstream \n error |\n timeout |\n denied |\n invalid_header |\n http_500 |\n http_503 |\n http_403 |\n http_404 |\n http_429 |\n non_idempotent |\n off\n ...;
\n
\n Default:\n \n
uwsgi_next_upstream error timeout;
\n
\n Context:\n \n http, server, location
\n

\nSpecifies in which cases a request should be passed to the next server:\n

\n\n
error
\n
an error occurred while establishing a connection with the\nserver, passing a request to it, or reading the response header;
\n\n
timeout
\n
a timeout has occurred while establishing a connection with the\nserver, passing a request to it, or reading the response header;
\n\n
denied
\n
the server denied\nthe connection (1.29.3);\n

\n

\nThis parameter is available as part of our\ncommercial subscription.\n

\n

\n
\n\n
invalid_header
\n
a server returned an empty or invalid response;
\n\n
http_500
\n
a server returned a response with the code 500;
\n\n
http_503
\n
a server returned a response with the code 503;
\n\n
http_403
\n
a server returned a response with the code 403;
\n\n
http_404
\n
a server returned a response with the code 404;
\n\n
http_429
\n
a server returned a response with the code 429 (1.11.13);
\n\n
non_idempotent
\n
normally, requests with a\nnon-idempotent\nmethod\n(POST, LOCK, PATCH)\nare not passed to the next server\nif a request has been sent to an upstream server (1.9.13);\nenabling this option explicitly allows retrying such requests;\n
\n\n
off
\n
disables passing a request to the next server.
\n\n

\n

\nOne should bear in mind that passing a request to the next server is\nonly possible if nothing has been sent to a client yet.\nThat is, if an error or timeout occurs in the middle of the\ntransferring of a response, fixing this is impossible.\n

\nThe directive also defines what is considered an\nunsuccessful\nattempt of communication with a server.\nThe cases of error, timeout,\ndenied and\ninvalid_header are always considered unsuccessful attempts,\neven if they are not specified in the directive.\nThe cases of http_500, http_503,\nand http_429 are\nconsidered unsuccessful attempts only if they are specified in the directive.\nThe cases of http_403 and http_404\nare never considered unsuccessful attempts.\n

\nPassing a request to the next server can be limited by\nthe number of tries\nand by time.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n uwsgi_next_upstream_timeout time;
\n
\n Default:\n \n
uwsgi_next_upstream_timeout 0;
\n
\n Context:\n \n http, server, location
\n

This directive appeared in version 1.7.5.\n

\nLimits the time during which a request can be passed to the\nnext server.\nThe 0 value turns off this limitation.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n uwsgi_next_upstream_tries number;
\n
\n Default:\n \n
uwsgi_next_upstream_tries 0;
\n
\n Context:\n \n http, server, location
\n

This directive appeared in version 1.7.5.\n

\nLimits the number of possible tries for passing a request to the\nnext server.\nThe 0 value turns off this limitation.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n uwsgi_no_cache string ...;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n http, server, location
\n

\nDefines conditions under which the response will not be saved to a cache.\nIf at least one value of the string parameters is not empty and is not\nequal to “0” then the response will not be saved:\n

\nuwsgi_no_cache $cookie_nocache $arg_nocache$arg_comment;\nuwsgi_no_cache $http_pragma    $http_authorization;\n

\nCan be used along with the uwsgi_cache_bypass directive.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n uwsgi_param \n parameter value\n [if_not_empty];
\n
\n Default:\n \n
uwsgi_param HTTP_HOST $host$is_request_port$request_port;
\n
\n Context:\n \n http, server, location
\n

\nSets a parameter that should be passed to the uwsgi server.\nThe value can contain text, variables, and their combination.\nThese directives are inherited from the previous configuration level\nif and only if there are no uwsgi_param directives\ndefined on the current level.\n

\nStandard\nCGI\nenvironment variables\nshould be provided as uwsgi headers, see the uwsgi_params file\nprovided in the distribution:\n

\nlocation / {\n    include uwsgi_params;\n    ...\n}\n

\n

\nIf the directive is specified with if_not_empty (1.1.11) then\nsuch a parameter will be passed to the server only if its value is not empty:\n

\nuwsgi_param HTTPS $https if_not_empty;\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n uwsgi_pass [protocol://]address;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n location, if in location
\n

\nSets the protocol and address of a uwsgi server.\nAs a protocol,\n“uwsgi” or “suwsgi”\n(secured uwsgi, uwsgi over SSL) can be specified.\nThe address can be specified as a domain name or IP address,\nand a port:\n

\nuwsgi_pass localhost:9000;\nuwsgi_pass uwsgi://localhost:9000;\nuwsgi_pass suwsgi://[2001:db8::1]:9090;\n

\nor as a UNIX-domain socket path:\n

\nuwsgi_pass unix:/tmp/uwsgi.socket;\n

\n

\nIf a domain name resolves to several addresses, all of them will be\nused in a round-robin fashion.\nIn addition, an address can be specified as a\nserver group.\n

\nParameter value can contain variables.\nIn this case, if an address is specified as a domain name,\nthe name is searched among the described\nserver groups,\nand, if not found, is determined using a\nresolver.\n

\n

\nSecured uwsgi protocol is supported since version 1.5.8.\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n uwsgi_pass_header field;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n http, server, location
\n

\nPermits passing otherwise disabled header\nfields from a uwsgi server to a client.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n uwsgi_pass_request_body on | off;
\n
\n Default:\n \n
uwsgi_pass_request_body on;
\n
\n Context:\n \n http, server, location
\n

\nIndicates whether the original request body is passed\nto the uwsgi server.\nSee also the uwsgi_pass_request_headers directive.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n uwsgi_pass_request_headers on | off;
\n
\n Default:\n \n
uwsgi_pass_request_headers on;
\n
\n Context:\n \n http, server, location
\n

\nIndicates whether the header fields of the original request are passed\nto the uwsgi server.\nSee also the uwsgi_pass_request_body directive.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n uwsgi_read_timeout time;
\n
\n Default:\n \n
uwsgi_read_timeout 60s;
\n
\n Context:\n \n http, server, location
\n

\nDefines a timeout for reading a response from the uwsgi server.\nThe timeout is set only between two successive read operations,\nnot for the transmission of the whole response.\nIf the uwsgi server does not transmit anything within this time,\nthe connection is closed.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n uwsgi_request_buffering on | off;
\n
\n Default:\n \n
uwsgi_request_buffering on;
\n
\n Context:\n \n http, server, location
\n

This directive appeared in version 1.7.11.\n

\nEnables or disables buffering of a client request body.\n

\nWhen buffering is enabled, the entire request body is\nread\nfrom the client before sending the request to a uwsgi server.\n

\nWhen buffering is disabled, the request body is sent to the uwsgi server\nimmediately as it is received.\nIn this case, the request cannot be passed to the\nnext server\nif nginx already started sending the request body.\n

\nWhen HTTP/1.1 chunked transfer encoding is used\nto send the original request body,\nthe request body will be buffered regardless of the directive value.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n uwsgi_request_dynamic on | off;
\n
\n Default:\n \n
uwsgi_request_dynamic off;
\n
\n Context:\n \n http, server, location
\n

This directive appeared in version 1.29.3.\n

\nEnables or disables creation of a separate request instance\nfor each uwsgi server.\nBy default, a single request is used for all uwsgi servers.\nIf enabled, a separate request instance is created,\nallowing per-server request customization.\n

\n

\nThis directive is available as part of our\ncommercial subscription.\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n uwsgi_send_timeout time;
\n
\n Default:\n \n
uwsgi_send_timeout 60s;
\n
\n Context:\n \n http, server, location
\n

\nSets a timeout for transmitting a request to the uwsgi server.\nThe timeout is set only between two successive write operations,\nnot for the transmission of the whole request.\nIf the uwsgi server does not receive anything within this time,\nthe connection is closed.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n uwsgi_socket_keepalive on | off;
\n
\n Default:\n \n
uwsgi_socket_keepalive off;
\n
\n Context:\n \n http, server, location
\n

This directive appeared in version 1.15.6.\n

\nConfigures the “TCP keepalive” behavior\nfor outgoing connections to a uwsgi server.\nBy default, the operating system’s settings are in effect for the socket.\nIf the directive is set to the value “on”, the\nSO_KEEPALIVE socket option is turned on for the socket.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n uwsgi_ssl_certificate file;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n http, server, location
\n

This directive appeared in version 1.7.8.\n

\nSpecifies a file with the certificate in the PEM format\nused for authentication to a secured uwsgi server.\n

\nSince version 1.21.0, variables can be used in the file name.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n uwsgi_ssl_certificate_cache off;
uwsgi_ssl_certificate_cache \n max=N\n [inactive=time]\n [valid=time];
\n
\n Default:\n \n
uwsgi_ssl_certificate_cache off;
\n
\n Context:\n \n http, server, location
\n

This directive appeared in version 1.27.4.\n

\nDefines a cache that stores\nSSL certificates and\nsecret keys\nspecified with variables.\n

\nThe directive has the following parameters:\n

\n\n
\nmax\n
\n
\nsets the maximum number of elements in the cache;\non cache overflow the least recently used (LRU) elements are removed;\n
\n\n
\ninactive\n
\n
\ndefines a time after which an element is removed from the cache\nif it has not been accessed during this time;\nby default, it is 10 seconds;\n
\n\n
\nvalid\n
\n
\ndefines a time during which\nan element in the cache is considered valid\nand can be reused;\nby default, it is 60 seconds.\nCertificates that exceed this time will be reloaded or revalidated;\n
\n\n
\noff\n
\n
\ndisables the cache.\n
\n\n

\n

\nExample:\n

\nuwsgi_ssl_certificate       $uwsgi_ssl_server_name.crt;\nuwsgi_ssl_certificate_key   $uwsgi_ssl_server_name.key;\nuwsgi_ssl_certificate_cache max=1000 inactive=20s valid=1m;\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n uwsgi_ssl_certificate_key file;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n http, server, location
\n

This directive appeared in version 1.7.8.\n

\nSpecifies a file with the secret key in the PEM format\nused for authentication to a secured uwsgi server.\n

\nThe value\nengine:name:id\ncan be specified instead of the file (1.7.9),\nwhich loads a secret key with a specified id\nfrom the OpenSSL engine name.\n

\nThe value\nstore:scheme:id\ncan be specified instead of the file (1.29.0),\nwhich is used to load a secret key with a specified id\nand OpenSSL provider registered URI scheme, such as\npkcs11.\n

\nSince version 1.21.0, variables can be used in the file name.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n uwsgi_ssl_ciphers ciphers;
\n
\n Default:\n \n
uwsgi_ssl_ciphers DEFAULT;
\n
\n Context:\n \n http, server, location
\n

This directive appeared in version 1.5.8.\n

\nSpecifies the enabled ciphers for requests to a secured uwsgi server.\nThe ciphers are specified in the format understood by the OpenSSL library.\n

\nThe full list can be viewed using the\n“openssl ciphers” command.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n uwsgi_ssl_conf_command name value;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n http, server, location
\n

This directive appeared in version 1.19.4.\n

\nSets arbitrary OpenSSL configuration\ncommands\nwhen establishing a connection with the secured uwsgi server.\n

\nThe directive is supported when using OpenSSL 1.0.2 or higher.\n

\n

\nSeveral uwsgi_ssl_conf_command directives\ncan be specified on the same level.\nThese directives are inherited from the previous configuration level\nif and only if there are\nno uwsgi_ssl_conf_command directives\ndefined on the current level.\n

\n

\nNote that configuring OpenSSL directly\nmight result in unexpected behavior.\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n uwsgi_ssl_crl file;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n http, server, location
\n

This directive appeared in version 1.7.0.\n

\nSpecifies a file with revoked certificates (CRL)\nin the PEM format used to verify\nthe certificate of the secured uwsgi server.\nWhen using intermediate certificates, their CRLs should be\nspecified in the same file.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n uwsgi_ssl_key_log path;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n http, server, location
\n

This directive appeared in version 1.27.2.\n

\nEnables logging of secured uwsgi server connection SSL keys\nand specifies the path to the key log file.\nKeys are logged in the\nSSLKEYLOGFILE\nformat compatible with Wireshark.\n

\n

\nThis directive is available as part of our\ncommercial subscription.\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n uwsgi_ssl_name name;
\n
\n Default:\n \n
uwsgi_ssl_name host from uwsgi_pass;
\n
\n Context:\n \n http, server, location
\n

This directive appeared in version 1.7.0.\n

\nAllows overriding the server name used to\nverify\nthe certificate of the secured uwsgi server and to be\npassed through SNI\nwhen establishing a connection with the secured uwsgi server.\n

\nBy default, the host part from uwsgi_pass is used.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n uwsgi_ssl_password_file file;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n http, server, location
\n

This directive appeared in version 1.7.8.\n

\nSpecifies a file with passphrases for\nsecret keys\nwhere each passphrase is specified on a separate line.\nPassphrases are tried in turn when loading the key.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n uwsgi_ssl_protocols \n [SSLv2]\n [SSLv3]\n [TLSv1]\n [TLSv1.1]\n [TLSv1.2]\n [TLSv1.3];
\n
\n Default:\n \n
uwsgi_ssl_protocols TLSv1.2 TLSv1.3;
\n
\n Context:\n \n http, server, location
\n

This directive appeared in version 1.5.8.\n

\nEnables the specified protocols for requests to a secured uwsgi server.\n

\n

\nThe TLSv1.3 parameter is used by default\nsince 1.23.4.\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n uwsgi_ssl_server_name on | off;
\n
\n Default:\n \n
uwsgi_ssl_server_name off;
\n
\n Context:\n \n http, server, location
\n

This directive appeared in version 1.7.0.\n

\nEnables or disables passing of the server name through\nTLS\nServer Name Indication extension (SNI, RFC 6066)\nwhen establishing a connection with the secured uwsgi server.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n uwsgi_ssl_session_reuse on | off;
\n
\n Default:\n \n
uwsgi_ssl_session_reuse on;
\n
\n Context:\n \n http, server, location
\n

This directive appeared in version 1.5.8.\n

\nDetermines whether SSL sessions can be reused when working with\na secured uwsgi server.\nIf the errors\n“digest check failed”\nappear in the logs, try disabling session reuse.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n uwsgi_ssl_trusted_certificate file;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n http, server, location
\n

This directive appeared in version 1.7.0.\n

\nSpecifies a file with trusted CA certificates in the PEM format\nused to verify\nthe certificate of the secured uwsgi server.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n uwsgi_ssl_verify on | off;
\n
\n Default:\n \n
uwsgi_ssl_verify off;
\n
\n Context:\n \n http, server, location
\n

This directive appeared in version 1.7.0.\n

\nEnables or disables verification of the secured uwsgi server certificate.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n uwsgi_ssl_verify_depth number;
\n
\n Default:\n \n
uwsgi_ssl_verify_depth 1;
\n
\n Context:\n \n http, server, location
\n

This directive appeared in version 1.7.0.\n

\nSets the verification depth in the secured uwsgi server certificates chain.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n uwsgi_store \n on |\n off |\n string;
\n
\n Default:\n \n
uwsgi_store off;
\n
\n Context:\n \n http, server, location
\n

\nEnables saving of files to a disk.\nThe on parameter saves files with paths\ncorresponding to the directives\nalias or\nroot.\nThe off parameter disables saving of files.\nIn addition, the file name can be set explicitly using the\nstring with variables:\n

\nuwsgi_store /data/www$original_uri;\n

\n

\nThe modification time of files is set according to the received\n“Last-Modified” response header field.\nThe response is first written to a temporary file,\nand then the file is renamed.\nStarting from version 0.8.9, temporary files and the persistent store\ncan be put on different file systems.\nHowever, be aware that in this case a file is copied\nacross two file systems instead of the cheap renaming operation.\nIt is thus recommended that for any given location both saved files and a\ndirectory holding temporary files, set by the uwsgi_temp_path\ndirective, are put on the same file system.\n

\nThis directive can be used to create local copies of static unchangeable\nfiles, e.g.:\n

\nlocation /images/ {\n    root               /data/www;\n    error_page         404 = /fetch$uri;\n}\n\nlocation /fetch/ {\n    internal;\n\n    uwsgi_pass         backend:9000;\n    ...\n\n    uwsgi_store        on;\n    uwsgi_store_access user:rw group:rw all:r;\n    uwsgi_temp_path    /data/temp;\n\n    alias              /data/www/;\n}\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n uwsgi_store_access users:permissions ...;
\n
\n Default:\n \n
uwsgi_store_access user:rw;
\n
\n Context:\n \n http, server, location
\n

\nSets access permissions for newly created files and directories, e.g.:\n

\nuwsgi_store_access user:rw group:rw all:r;\n

\n

\nIf any group or all access permissions\nare specified then user permissions may be omitted:\n

\nuwsgi_store_access group:rw all:r;\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n uwsgi_temp_file_write_size size;
\n
\n Default:\n \n
uwsgi_temp_file_write_size 8k|16k;
\n
\n Context:\n \n http, server, location
\n

\nLimits the size of data written to a temporary file\nat a time, when buffering of responses from the uwsgi server\nto temporary files is enabled.\nBy default, size is limited by two buffers set by the\nuwsgi_buffer_size and uwsgi_buffers directives.\nThe maximum size of a temporary file is set by the\nuwsgi_max_temp_file_size directive.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n uwsgi_temp_path \n path\n [level1\n [level2\n [level3]]];
\n
\n Default:\n \n
uwsgi_temp_path uwsgi_temp;
\n
\n Context:\n \n http, server, location
\n

\nDefines a directory for storing temporary files\nwith data received from uwsgi servers.\nUp to three-level subdirectory hierarchy can be used underneath the specified\ndirectory.\nFor example, in the following configuration\n

\nuwsgi_temp_path /spool/nginx/uwsgi_temp 1 2;\n

\na temporary file might look like this:\n

\n/spool/nginx/uwsgi_temp/7/45/00000123457\n

\n

\nSee also the use_temp_path parameter of the\nuwsgi_cache_path directive.\n

\n\n
\n", "encoding": "utf-8"} +{"path": "en\\docs\\http\\ngx_http_v2_module.html", "extension": ".html", "size_bytes": 21213, "content": "\nModule ngx_http_v2_module
\n\nPlanning your ingress-nginx migration? Start here:\nkubernetes.nginx.org.\n\n

Module ngx_http_v2_module

Known Issues
Example Configuration
Directives
     http2
     http2_body_preread_size
     http2_chunk_size
     http2_idle_timeout
     http2_max_concurrent_pushes
     http2_max_concurrent_streams
     http2_max_field_size
     http2_max_header_size
     http2_max_requests
     http2_push
     http2_push_preload
     http2_recv_buffer_size
     http2_recv_timeout
Embedded Variables
\n\n

\nThe ngx_http_v2_module module (1.9.5) provides\nsupport for\nHTTP/2.\n

\nThis module is not built by default, it should be enabled with\nthe --with-http_v2_module\nconfiguration parameter.\n

\n\n\n

Known Issues

\nBefore version 1.9.14,\nbuffering of a client request body could not be disabled\nregardless of\nproxy_request_buffering,\nfastcgi_request_buffering,\nuwsgi_request_buffering, and\nscgi_request_buffering\ndirective values.\n

\nBefore version 1.19.1,\nthe lingering_close mechanism\nwas not used to control closing HTTP/2 connections.\n

\n\n\n

Example Configuration

\n

\nserver {\n    listen 443 ssl;\n\n    http2 on;\n\n    ssl_certificate server.crt;\n    ssl_certificate_key server.key;\n}\n

\nNote that accepting HTTP/2 connections over TLS requires\nthe “Application-Layer Protocol Negotiation” (ALPN) TLS extension\nsupport, which is available since\nOpenSSL version 1.0.2.\n

\nAlso note that if the\nssl_prefer_server_ciphers directive\nis set to the value “on”,\nthe ciphers\nshould be configured to comply with\nRFC 9113, Appendix A\nblack list and supported by clients.\n

\n\n\n

Directives

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n http2 on | off;
\n
\n Default:\n \n
http2 off;
\n
\n Context:\n \n http, server
\n

This directive appeared in version 1.25.1.\n

\nEnables\nthe HTTP/2\nprotocol.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n http2_body_preread_size size;
\n
\n Default:\n \n
http2_body_preread_size 64k;
\n
\n Context:\n \n http, server
\n

This directive appeared in version 1.11.0.\n

\nSets the size of the buffer per each request\nin which the request body may be saved\nbefore it is started to be processed.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n http2_chunk_size size;
\n
\n Default:\n \n
http2_chunk_size 8k;
\n
\n Context:\n \n http, server, location
\n

\nSets the maximum size of chunks\ninto which the response body is sliced.\nA too low value results in higher overhead.\nA too high value impairs prioritization due to\n\nHOL blocking.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n http2_idle_timeout time;
\n
\n Default:\n \n
http2_idle_timeout 3m;
\n
\n Context:\n \n http, server
\n

\n

\nThis directive is obsolete since version 1.19.7.\nThe keepalive_timeout\ndirective should be used instead.\n

\n

\nSets the timeout of inactivity after which the connection is closed.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n http2_max_concurrent_pushes number;
\n
\n Default:\n \n
http2_max_concurrent_pushes 10;
\n
\n Context:\n \n http, server
\n

This directive appeared in version 1.13.9.\n

\n

\nThis directive is obsolete since version 1.25.1.\n

\n

\nLimits the maximum number of concurrent\npush requests in a connection.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n http2_max_concurrent_streams number;
\n
\n Default:\n \n
http2_max_concurrent_streams 128;
\n
\n Context:\n \n http, server
\n

\nSets the maximum number of concurrent HTTP/2 streams\nin a connection.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n http2_max_field_size size;
\n
\n Default:\n \n
http2_max_field_size 4k;
\n
\n Context:\n \n http, server
\n

\n

\nThis directive is obsolete since version 1.19.7.\nThe large_client_header_buffers\ndirective should be used instead.\n

\n

\nLimits the maximum size of\nan HPACK-compressed\nrequest header field.\nThe limit applies equally to both name and value.\nNote that if Huffman encoding is applied,\nthe actual size of decompressed name and value strings may be larger.\nFor most requests, the default limit should be enough.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n http2_max_header_size size;
\n
\n Default:\n \n
http2_max_header_size 16k;
\n
\n Context:\n \n http, server
\n

\n

\nThis directive is obsolete since version 1.19.7.\nThe large_client_header_buffers\ndirective should be used instead.\n

\n

\nLimits the maximum size of the entire request header list after\nHPACK decompression.\nFor most requests, the default limit should be enough.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n http2_max_requests number;
\n
\n Default:\n \n
http2_max_requests 1000;
\n
\n Context:\n \n http, server
\n

This directive appeared in version 1.11.6.\n

\n

\nThis directive is obsolete since version 1.19.7.\nThe keepalive_requests\ndirective should be used instead.\n

\n

\nSets the maximum number of requests (including\npush requests) that can be served\nthrough one HTTP/2 connection,\nafter which the next client request will lead to connection closing\nand the need of establishing a new connection.\n

\nClosing connections periodically is necessary to free\nper-connection memory allocations.\nTherefore, using too high maximum number of requests\ncould result in excessive memory usage and not recommended.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n http2_push uri | off;
\n
\n Default:\n \n
http2_push off;
\n
\n Context:\n \n http, server, location
\n

This directive appeared in version 1.13.9.\n

\n

\nThis directive is obsolete since version 1.25.1.\nThe early_hints\ndirective can be used instead.\n

\n

\nPre-emptively sends\n(pushes)\na request to the specified uri\nalong with the response to the original request.\nOnly relative URIs with absolute path will be processed,\nfor example:\n

\nhttp2_push /static/css/main.css;\n

\nThe uri value can contain variables.\n

\nSeveral http2_push directives\ncan be specified on the same configuration level.\nThe off parameter cancels the effect\nof the http2_push directives\ninherited from the previous configuration level.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n http2_push_preload on | off;
\n
\n Default:\n \n
http2_push_preload off;
\n
\n Context:\n \n http, server, location
\n

This directive appeared in version 1.13.9.\n

\n

\nThis directive is obsolete since version 1.25.1.\n

\n

\nEnables automatic conversion of\npreload\nlinks\nspecified in the “Link” response header fields into\npush\nrequests.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n http2_recv_buffer_size size;
\n
\n Default:\n \n
http2_recv_buffer_size 256k;
\n
\n Context:\n \n http
\n

\nSets the size of the per\nworker\ninput buffer.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n http2_recv_timeout time;
\n
\n Default:\n \n
http2_recv_timeout 30s;
\n
\n Context:\n \n http, server
\n

\n

\nThis directive is obsolete since version 1.19.7.\nThe client_header_timeout\ndirective should be used instead.\n

\n

\nSets the timeout for expecting more data from the client,\nafter which the connection is closed.\n

\n\n\n

Embedded Variables

\nThe ngx_http_v2_module module\nsupports the following embedded variables:\n

\n\n
$http2
\n
\nnegotiated protocol identifier:\n“h2” for HTTP/2 over TLS,\n“h2c” for HTTP/2 over cleartext TCP,\nor an empty string otherwise.\n
\n\n

\n

\n\n
\n", "encoding": "utf-8"} +{"path": "en\\docs\\http\\ngx_http_v3_module.html", "extension": ".html", "size_bytes": 14326, "content": "\nModule ngx_http_v3_module
\n\nPlanning your ingress-nginx migration? Start here:\nkubernetes.nginx.org.\n\n

Module ngx_http_v3_module

Known Issues
Example Configuration
Directives
     http3
     http3_hq
     http3_max_concurrent_streams
     http3_stream_buffer_size
     quic_active_connection_id_limit
     quic_bpf
     quic_gso
     quic_host_key
     quic_retry
Embedded Variables
\n\n

\nThe ngx_http_v3_module module (1.25.0) provides\nexperimental support for\nHTTP/3.\n

\nThis module is not built by default, it should be enabled with the\n--with-http_v3_module\nconfiguration parameter.\n

\nThis module requires the\nOpenSSL library\nversion 1.1.1 or higher.\n

\n

\n0-RTT support requires the\nOpenSSL library\nversion 3.5.1 or higher.\nAlternatively,\nBoringSSL,\nLibreSSL, or\nQuicTLS\nlibraries can be used to build and run this module.\n

\n

\n\n\n

Known Issues

\nThe module is experimental, caveat emptor applies.\n

\nBefore version 1.29.1,\n0-RTT support could not be enabled with OpenSSL\nregardless of the\nssl_early_data\ndirective value.\n

\nThe module cannot be built on the Win32 platform.\n

\n\n\n

Example Configuration

\n

\nhttp {\n    log_format quic '$remote_addr - $remote_user [$time_local] '\n                    '\"$request\" $status $body_bytes_sent '\n                    '\"$http_referer\" \"$http_user_agent\" \"$http3\"';\n\n    access_log logs/access.log quic;\n\n    server {\n        # for better compatibility it's recommended\n        # to use the same port for http/3 and https\n        listen 8443 quic reuseport;\n        listen 8443 ssl;\n\n        ssl_certificate     certs/example.com.crt;\n        ssl_certificate_key certs/example.com.key;\n\n        location / {\n            # used to advertise the availability of HTTP/3\n            add_header Alt-Svc 'h3=\":8443\"; ma=86400';\n        }\n    }\n}\n

\n

\n\n\n

Directives

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n http3 on | off;
\n
\n Default:\n \n
http3 on;
\n
\n Context:\n \n http, server
\n

\nEnables\nHTTP/3\nprotocol negotiation.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n http3_hq on | off;
\n
\n Default:\n \n
http3_hq off;
\n
\n Context:\n \n http, server
\n

\nEnables HTTP/0.9 protocol negotiation\nused in\nQUIC\ninteroperability tests.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n http3_max_concurrent_streams number;
\n
\n Default:\n \n
http3_max_concurrent_streams 128;
\n
\n Context:\n \n http, server
\n

\nSets the maximum number of concurrent HTTP/3 request streams\nin a connection.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n http3_stream_buffer_size size;
\n
\n Default:\n \n
http3_stream_buffer_size 64k;
\n
\n Context:\n \n http, server
\n

\nSets the size of the buffer used for reading and writing of the\nQUIC streams.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n quic_active_connection_id_limit number;
\n
\n Default:\n \n
quic_active_connection_id_limit 2;
\n
\n Context:\n \n http, server
\n

\nSets the\nQUIC active_connection_id_limit transport parameter value.\nThis is the maximum number of client connection IDs\nwhich can be stored on the server.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n quic_bpf on | off;
\n
\n Default:\n \n
quic_bpf off;
\n
\n Context:\n \n main
\n

\nEnables routing of QUIC packets using\neBPF.\nWhen enabled, this allows supporting QUIC connection migration.\n

\n

\nThe directive is only supported on Linux 5.7+.\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n quic_gso on | off;
\n
\n Default:\n \n
quic_gso off;
\n
\n Context:\n \n http, server
\n

\nEnables sending in optimized batch mode\nusing segmentation offloading.\n

\n

\nOptimized sending is supported only on Linux\nfeaturing UDP_SEGMENT.\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n quic_host_key file;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n http, server
\n

\nSets a file with the secret key used to encrypt\nstateless reset and address validation tokens.\nBy default, a random key is generated on each reload.\nTokens generated with old keys are not accepted.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n quic_retry on | off;
\n
\n Default:\n \n
quic_retry off;
\n
\n Context:\n \n http, server
\n

\nEnables the\nQUIC\nAddress Validation feature.\nThis includes sending a new token in a Retry packet\nor a NEW_TOKEN frame\nand\nvalidating a token received in the Initial packet.\n

\n\n\n

Embedded Variables

\nThe ngx_http_v3_module module\nsupports the following embedded variables:\n

\n\n
$http3
\n
\nnegotiated protocol identifier:\n“h3” for HTTP/3 connections,\n“hq” for hq connections,\nor an empty string otherwise.\n
\n\n

\n

\n\n
\n", "encoding": "utf-8"} +{"path": "en\\docs\\http\\ngx_http_xslt_module.html", "extension": ".html", "size_bytes": 12144, "content": "\nModule ngx_http_xslt_module
\n\nPlanning your ingress-nginx migration? Start here:\nkubernetes.nginx.org.\n\n

Module ngx_http_xslt_module

Example Configuration
Directives
     xml_entities
     xslt_last_modified
     xslt_param
     xslt_string_param
     xslt_stylesheet
     xslt_types
\n\n

\nThe ngx_http_xslt_module (0.7.8+) is a filter\nthat transforms XML responses using one or more XSLT stylesheets.\n

\nThis module is not built by default, it should be enabled with the\n--with-http_xslt_module\nconfiguration parameter.\n

\nThis module requires the\nlibxml2 and\nlibxslt libraries.\n

\n

\n\n\n

Example Configuration

\n

\nlocation / {\n    xml_entities    /site/dtd/entities.dtd;\n    xslt_stylesheet /site/xslt/one.xslt param=value;\n    xslt_stylesheet /site/xslt/two.xslt;\n}\n

\n

\n\n\n

Directives

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n xml_entities path;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n http, server, location
\n

\nSpecifies the DTD file that declares character entities.\nThis file is compiled at the configuration stage.\nFor technical reasons, the module is unable to use the\nexternal subset declared in the processed XML, so it is\nignored and a specially defined file is used instead.\nThis file should not describe the XML structure.\nIt is enough to declare just the required character entities, for example:\n

\n<!ENTITY nbsp \"&#xa0;\">\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n xslt_last_modified on | off;
\n
\n Default:\n \n
xslt_last_modified off;
\n
\n Context:\n \n http, server, location
\n

This directive appeared in version 1.5.1.\n

\nAllows preserving the “Last-Modified” header field\nfrom the original response during XSLT transformations\nto facilitate response caching.\n

\nBy default, the header field is removed as contents of the response\nare modified during transformations and may contain dynamically generated\nelements or parts that are changed independently of the original response.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n xslt_param parameter value;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n http, server, location
\n

This directive appeared in version 1.1.18.\n

\nDefines the parameters for XSLT stylesheets.\nThe value is treated as an XPath expression.\nThe value can contain variables.\nTo pass a string value to a stylesheet,\nthe xslt_string_param directive can be used.\n

\nThere could be several xslt_param directives.\nThese directives are inherited from the previous configuration level\nif and only if there are no xslt_param and\nxslt_string_param directives\ndefined on the current level.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n xslt_string_param parameter value;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n http, server, location
\n

This directive appeared in version 1.1.18.\n

\nDefines the string parameters for XSLT stylesheets.\nXPath expressions in the value are not interpreted.\nThe value can contain variables.\n

\nThere could be several xslt_string_param directives.\nThese directives are inherited from the previous configuration level\nif and only if there are no xslt_param and\nxslt_string_param directives\ndefined on the current level.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n xslt_stylesheet \n stylesheet\n [parameter=value ...];
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n location
\n

\nDefines the XSLT stylesheet and its optional parameters.\nA stylesheet is compiled at the configuration stage.\n

\nParameters can either be specified separately, or grouped in a\nsingle line using the “:” delimiter.\nIf a parameter includes the “:” character,\nit should be escaped as “%3A”.\nAlso, libxslt requires to enclose parameters\nthat contain non-alphanumeric characters into single or double quotes,\nfor example:\n

\nparam1='http%3A//www.example.com':param2=value2\n

\n

\nThe parameters description can contain variables, for example,\nthe whole line of parameters can be taken from a single variable:\n

\nlocation / {\n    xslt_stylesheet /site/xslt/one.xslt\n                    $arg_xslt_params\n                    param1='$value1':param2=value2\n                    param3=value3;\n}\n

\n

\nIt is possible to specify several stylesheets.\nThey will be applied sequentially in the specified order.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n xslt_types mime-type ...;
\n
\n Default:\n \n
xslt_types text/xml;
\n
\n Context:\n \n http, server, location
\n

\nEnables transformations in responses with the specified MIME types\nin addition to “text/xml”.\nThe special value “*” matches any MIME type (0.8.29).\nIf the transformation result is an HTML response, its MIME type\nis changed to “text/html”.\n

\n\n
\n", "encoding": "utf-8"} +{"path": "en\\docs\\http\\request_processing.html", "extension": ".html", "size_bytes": 11317, "content": "\nHow nginx processes a request
\n\nPlanning your ingress-nginx migration? Start here:\nkubernetes.nginx.org.\n\n

How nginx processes a request

How to prevent processing requests with undefined server names
Mixed name-based and IP-based virtual servers
A simple PHP site configuration

Name-based virtual servers

\nnginx first decides which server should process the request.\nLet’s start with a simple configuration\nwhere all three virtual servers listen on port *:80:\n

\nserver {\n    listen      80;\n    server_name example.org www.example.org;\n    ...\n}\n\nserver {\n    listen      80;\n    server_name example.net www.example.net;\n    ...\n}\n\nserver {\n    listen      80;\n    server_name example.com www.example.com;\n    ...\n}\n

\n\n

\nIn this configuration nginx tests only the request’s header field\n“Host” to determine which server the request should be routed to.\nIf its value does not match any server name,\nor the request does not contain this header field at all,\nthen nginx will route the request to the default server for this port.\nIn the configuration above, the default server is the first\none — which is nginx’s standard default behaviour.\nIt can also be set explicitly which server should be default,\nwith the default_server parameter\nin the listen directive:\n

\nserver {\n    listen      80 default_server;\n    server_name example.net www.example.net;\n    ...\n}\n

\n\n

\nThe default_server parameter has been available since\nversion 0.8.21.\nIn earlier versions the default parameter should be used\ninstead.\n

\nNote that the default server is a property of the listen port\nand not of the server name.\nMore about this later.\n

How to prevent processing requests with undefined server names

\nIf requests without the “Host” header field should not be\nallowed, a server that just drops the requests can be defined:\n

\nserver {\n    listen      80;\n    server_name \"\";\n    return      444;\n}\n

\nHere, the server name is set to an empty string that will match\nrequests without the “Host” header field,\nand a special nginx’s non-standard code 444\nis returned that closes the connection.\n

\nSince version 0.8.48, this is the default setting for the\nserver name, so the server_name \"\" can be omitted.\nIn earlier versions, the machine’s hostname was used as\na default server name.\n

\n

Mixed name-based and IP-based virtual servers

\nLet’s look at a more complex configuration\nwhere some virtual servers listen on different addresses:\n

\nserver {\n    listen      192.168.1.1:80;\n    server_name example.org www.example.org;\n    ...\n}\n\nserver {\n    listen      192.168.1.1:80;\n    server_name example.net www.example.net;\n    ...\n}\n\nserver {\n    listen      192.168.1.2:80;\n    server_name example.com www.example.com;\n    ...\n}\n

\nIn this configuration, nginx first tests the IP address and port\nof the request against the\nlisten directives\nof the\nserver blocks.\nIt then tests the “Host”\nheader field of the request against the\nserver_name\nentries of the\nserver\nblocks that matched\nthe IP address and port.\nIf the server name is not found, the request will be processed by\nthe default server.\nFor example, a request for www.example.com received on\nthe 192.168.1.1:80 port will be handled by the default server\nof the 192.168.1.1:80 port, i.e., by the first server,\nsince there is no www.example.com defined for this port.\n

\nAs already stated, a default server is a property of the listen port,\nand different default servers may be defined for different ports:\n

\nserver {\n    listen      192.168.1.1:80;\n    server_name example.org www.example.org;\n    ...\n}\n\nserver {\n    listen      192.168.1.1:80 default_server;\n    server_name example.net www.example.net;\n    ...\n}\n\nserver {\n    listen      192.168.1.2:80 default_server;\n    server_name example.com www.example.com;\n    ...\n}\n

\n\n

A simple PHP site configuration

\nNow let’s look at how nginx chooses a location to process a request\nfor a typical, simple PHP site:\n

\nserver {\n    listen      80;\n    server_name example.org www.example.org;\n    root        /data/www;\n\n    location / {\n        index   index.html index.php;\n    }\n\n    location ~* \\.(gif|jpg|png)$ {\n        expires 30d;\n    }\n\n    location ~ \\.php$ {\n        fastcgi_pass  localhost:9000;\n        fastcgi_param SCRIPT_FILENAME\n                      $document_root$fastcgi_script_name;\n        include       fastcgi_params;\n    }\n}\n

\n\n

\nnginx first searches for the most specific prefix location given by\nliteral strings regardless of the listed order.\nIn the configuration above\nthe only prefix location is “/” and since it matches\nany request it will be used as a last resort.\nThen nginx checks locations given by\nregular expression in the order listed in the configuration file.\nThe first matching expression stops the search and nginx will use this\nlocation.\nIf no regular expression matches a request, then nginx uses\nthe most specific prefix location found earlier.\n

\nNote that locations of all types test only a URI part of request line\nwithout arguments.\nThis is done because arguments in the query string may be given in\nseveral ways, for example:\n

\n/index.php?user=john&page=1\n/index.php?page=1&user=john\n

\nBesides, anyone may request anything in the query string:\n

\n/index.php?page=1&something+else&user=john\n

\n\n

\nNow let’s look at how requests would be processed\nin the configuration above:\n

\n\n

written by Igor Sysoev
edited by Brian Mercer
\n", "encoding": "utf-8"} +{"path": "en\\docs\\http\\server_names.html", "extension": ".html", "size_bytes": 18392, "content": "\nServer names
\n\nPlanning your ingress-nginx migration? Start here:\nkubernetes.nginx.org.\n\n

Server names

Wildcard names
Regular expressions names
Miscellaneous names
Internationalized names
Virtual server selection
Optimization
Compatibility

\nServer names are defined using the\nserver_name\ndirective\nand determine which server block\nis used for a given request.\nSee also “How nginx processes a request”.\nThey may be defined using exact names, wildcard names, or regular expressions:\n\n

\nserver {\n    listen       80;\n    server_name  example.org  www.example.org;\n    ...\n}\n\nserver {\n    listen       80;\n    server_name  *.example.org;\n    ...\n}\n\nserver {\n    listen       80;\n    server_name  mail.*;\n    ...\n}\n\nserver {\n    listen       80;\n    server_name  ~^(?<user>.+)\\.example\\.net$;\n    ...\n}\n

\n

\nThe search is performed in the following order of priority\nand terminates on the first matching variant:\n

    \n\n
  1. \nthe exact name\n
  2. \n\n
  3. \nthe longest wildcard name starting with an asterisk,\ne.g. “*.example.org”\n
  4. \n\n
  5. \nthe longest wildcard name ending with an asterisk,\ne.g. “mail.*”\n
  6. \n\n
  7. \nthe first matching regular expression\n(in order of appearance in the configuration file)\n
  8. \n\n

\n

Wildcard names

\nA wildcard name may contain an asterisk only on the name’s start or end,\nand only on a dot border. The names “www.*.example.org”\nand “w*.example.org” are invalid.\nHowever, these names can be specified using regular expressions,\nfor example, “~^www\\..+\\.example\\.org$” and\n“~^w.*\\.example\\.org$”.\nAn asterisk can match several name parts.\nThe name “*.example.org” matches not only\nwww.example.org but www.sub.example.org as well.\n

\nA special wildcard name in the form “.example.org” can be\nused to match both the exact name “example.org”\nand the wildcard name ���*.example.org”.\n

Regular expressions names

\nThe regular expressions used by nginx are compatible with those used\nby the Perl programming language (PCRE).\nTo use a regular expression, the server name must start with the tilde\ncharacter:\n\n

\nserver_name  ~^www\\d+\\.example\\.net$;\n

\n\notherwise it will be treated as an exact name, or if the expression contains\nan asterisk, as a wildcard name (and most likely as an invalid one).\nDo not forget to set “^” and “$” anchors.\nThey are not required syntactically, but logically.\nAlso note that domain name dots should be escaped with a backslash.\nA regular expression containing the characters “{”\nand “}” should be quoted:\n\n

\nserver_name  \"~^(?<name>\\w\\d{1,3}+)\\.example\\.net$\";\n

\n\notherwise nginx will fail to start and display the error message:\n\n

\ndirective \"server_name\" is not terminated by \";\" in ...\n

\n\nA named regular expression capture can be used later as a variable:\n\n

\nserver {\n    server_name   ~^(www\\.)?(?<domain>.+)$;\n\n    location / {\n        root   /sites/$domain;\n    }\n}\n

\n\nThe PCRE library supports named captures using the following syntax:\n\n

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
?<name>Perl 5.10 compatible syntax, supported since PCRE-7.0
?'name'Perl 5.10 compatible syntax, supported since PCRE-7.0
?P<name>Python compatible syntax, supported since PCRE-4.0
\n\nIf nginx fails to start and displays the error message:\n\n

\npcre_compile() failed: unrecognized character after (?< in ...\n

\n\nthis means that the PCRE library is old and the syntax\n“?P<name>” should be tried instead.\nThe captures can also be used in digital form:\n\n

\nserver {\n    server_name   ~^(www\\.)?(.+)$;\n\n    location / {\n        root   /sites/$2;\n    }\n}\n

\n\nHowever, such usage should be limited to simple cases (like the above),\nsince the digital references can easily be overwritten.\n

Miscellaneous names

\nThere are some server names that are treated specially.\n

\nIf it is required to process requests without the “Host”\nheader field in a server\nblock which is not the default, an empty name should be specified:\n\n

\nserver {\n    listen       80;\n    server_name  example.org  www.example.org  \"\";\n    ...\n}\n

\n

\nIf no\nserver_name\nis defined in a server block\nthen nginx uses the empty name as the server name.\n

\nnginx versions up to 0.8.48 used the machine’s hostname as the server name\nin this case.\n

\n

\nIf a server name is defined as “$hostname” (0.9.4), the\nmachine’s hostname is used.\n

\nIf someone makes a request using an IP address instead of a server name,\nthe “Host” request header field will contain the IP address\nand the request can be handled using the IP address as the server name:\n\n

\nserver {\n    listen       80;\n    server_name  example.org\n                 www.example.org\n                 \"\"\n                 192.168.1.1\n                 ;\n    ...\n}\n

\n

\nIn catch-all server examples the strange name “_” can\nbe seen:\n\n

\nserver {\n    listen       80  default_server;\n    server_name  _;\n    return       444;\n}\n

\n\nThere is nothing special about this name, it is just one of a myriad\nof invalid domain names which never intersect with any real name.\nOther invalid names like “--” and “!@#”\nmay equally be used.\n

\nnginx versions up to 0.6.25 supported the special name “*”\nwhich was erroneously interpreted to be a catch-all name.\nIt never functioned as a catch-all or wildcard server name.\nInstead, it supplied the functionality that is now provided\nby the\nserver_name_in_redirect\ndirective.\nThe special name “*” is now deprecated\nand the\nserver_name_in_redirect\ndirective should be used.\nNote that there is no way to specify the catch-all name or\nthe default server using the\nserver_name\ndirective.\nThis is a property of the\nlisten\ndirective\nand not of the\nserver_name\ndirective.\nSee also “How nginx processes a request”.\nIt is possible to define servers listening on ports *:80 and *:8080,\nand direct that one will be the default server for port *:8080,\nwhile the other will be the default for port *:80:\n\n

\nserver {\n    listen       80;\n    listen       8080  default_server;\n    server_name  example.net;\n    ...\n}\n\nserver {\n    listen       80  default_server;\n    listen       8080;\n    server_name  example.org;\n    ...\n}\n

\n

Internationalized names

\nInternationalized domain names\n(IDNs)\nshould be specified using an ASCII (Punycode) representation\nin the server_name directive:\n

\nserver {\n    listen       80;\n    server_name  xn--e1afmkfd.xn--80akhbyknj4f;  # пример.испытание\n    ...\n}\n

\n

Virtual server selection

\nFirst, a connection is created in a default server context.\nThen, the server name can be determined\nin the following request processing stages,\neach involved in server configuration selection:\n\n

\n\nAt each of these stages, different server configurations can be applied.\nAs such, certain directives should be specified with caution:\n

\n

Optimization

\nExact names, wildcard names starting with an asterisk,\nand wildcard names ending with an asterisk are stored\nin three hash tables bound to the listen ports.\nThe sizes of hash tables are optimized at the configuration phase\nso that a name can be found with the fewest CPU cache misses.\nThe details of setting up hash tables are provided in a separate\ndocument.\n

\nThe exact names hash table is searched first.\nIf a name is not found, the hash table with wildcard names\nstarting with an asterisk is searched.\nIf the name is not found there, the hash table with wildcard names\nending with an asterisk is searched.\n

\nSearching wildcard names hash table is slower than searching exact names hash\ntable because names are searched by domain parts.\nNote that the special wildcard form “.example.org”\nis stored in a wildcard names hash table and not in an exact names hash table.\n

\nRegular expressions are tested sequentially\nand therefore are the slowest method and are non-scalable.\n

\nFor these reasons, it is better to use exact names where possible.\nFor example, if the most frequently requested names of a server\nare example.org and www.example.org,\nit is more efficient to define them explicitly:\n\n

\nserver {\n    listen       80;\n    server_name  example.org  www.example.org  *.example.org;\n    ...\n}\n

\n\nthan to use the simplified form:\n\n

\nserver {\n    listen       80;\n    server_name  .example.org;\n    ...\n}\n

\n

\nIf a large number of server names are defined,\nor unusually long server names are defined, tuning\nthe server_names_hash_max_size\nand server_names_hash_bucket_size\ndirectives at the http level may become necessary.\nThe default value of the\nserver_names_hash_bucket_size\ndirective may be equal to 32, or 64, or another value,\ndepending on CPU cache line size.\nIf the default value is 32 and server name is defined as\n“too.long.server.name.example.org”\nthen nginx will fail to start and display the error message:\n\n

\ncould not build the server_names_hash,\nyou should increase server_names_hash_bucket_size: 32\n

\n\nIn this case, the directive value should be increased to the next power of two:\n\n

\nhttp {\n    server_names_hash_bucket_size  64;\n    ...\n

\n\nIf a large number of server names are defined,\nanother error message will appear:\n\n

\ncould not build the server_names_hash,\nyou should increase either server_names_hash_max_size: 512\nor server_names_hash_bucket_size: 32\n

\n\nIn such a case, first try to set\nserver_names_hash_max_size\nto a number close to the number of server names.\nOnly if this does not help,\nor if nginx’s start time is unacceptably long, try to increase\nserver_names_hash_bucket_size.\n

\nIf a server is the only server for a listen port, then nginx will not test\nserver names at all (and will not build the hash tables for the listen port).\nHowever, there is one exception.\nIf a server name is a regular expression with captures,\nthen nginx has to execute the expression to get the captures.\n

Compatibility

\n

\n

written by Igor Sysoev
edited by Brian Mercer
\n", "encoding": "utf-8"} +{"path": "en\\docs\\http\\websocket.html", "extension": ".html", "size_bytes": 4814, "content": "\nWebSocket proxying
\n\nPlanning your ingress-nginx migration? Start here:\nkubernetes.nginx.org.\n\n

WebSocket proxying

\nTo turn a connection between a client and server from HTTP/1.1 into WebSocket,\nthe protocol\nswitch mechanism available in HTTP/1.1 is used.\n

\nThere is one subtlety however: since the “Upgrade” is a\nhop-by-hop\nheader, it is not passed from a client to proxied server.\nWith forward proxying, clients may use the CONNECT\nmethod to circumvent this issue.\nThis does not work with reverse proxying however,\nsince clients are not aware of any proxy servers,\nand special processing on a proxy server is required.\n

\nSince version 1.3.13,\nnginx implements special mode of operation\nthat allows setting up a tunnel between a client and proxied\nserver if the proxied server returned a response with the code\n101 (Switching Protocols),\nand the client asked for a protocol switch via the “Upgrade”\nheader in a request.\n

\nAs noted above, hop-by-hop headers including “Upgrade”\nand “Connection” are not passed from a client to proxied\nserver, therefore in order for the proxied server to know about the client’s\nintention to switch a protocol to WebSocket, these headers have to be\npassed explicitly:\n

\nlocation /chat/ {\n    proxy_pass http://backend;\n    # proxy_http_version 1.1; # before version 1.29.7\n    proxy_set_header Upgrade $http_upgrade;\n    proxy_set_header Connection \"upgrade\";\n}\n

\nA more sophisticated example\nin which a value of the “Connection” header field\nin a request to the proxied server depends on the presence of\nthe “Upgrade” field in the client request header:\n

\nhttp {\n    map $http_upgrade $connection_upgrade {\n        default upgrade;\n        ''      close;\n    }\n\n    server {\n        ...\n\n        location /chat/ {\n            proxy_pass http://backend;\n            # proxy_http_version 1.1; # before version 1.29.7\n            proxy_set_header Upgrade $http_upgrade;\n            proxy_set_header Connection $connection_upgrade;\n        }\n    }\n

\n

\nBy default, the connection will be closed\nif the proxied server does not transmit any data within 60 seconds.\nThis timeout can be increased with the\nproxy_read_timeout directive.\nAlternatively, the proxied server can be configured\nto periodically send WebSocket ping frames to reset the timeout\nand check if the connection is still alive.\n

\n", "encoding": "utf-8"} +{"path": "en\\docs\\mail\\ngx_mail_auth_http_module.html", "extension": ".html", "size_bytes": 11891, "content": "\nModule ngx_mail_auth_http_module
\n\nPlanning your ingress-nginx migration? Start here:\nkubernetes.nginx.org.\n\n

Module ngx_mail_auth_http_module

Directives
     auth_http
     auth_http_header
     auth_http_pass_client_cert
     auth_http_timeout
Protocol
\n\n

Directives

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n auth_http URL;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n mail, server
\n

\nSets the URL of the HTTP authentication server.\nThe protocol is described below.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n auth_http_header header value;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n mail, server
\n

\nAppends the specified header to requests sent to the authentication server.\nThis header can be used as the shared secret to verify\nthat the request comes from nginx.\nFor example:\n

\nauth_http_header X-Auth-Key \"secret_string\";\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n auth_http_pass_client_cert on | off;
\n
\n Default:\n \n
auth_http_pass_client_cert off;
\n
\n Context:\n \n mail, server
\n

This directive appeared in version 1.7.11.\n

\nAppends the “Auth-SSL-Cert” header with the\nclient\ncertificate in the PEM format (urlencoded)\nto requests sent to the authentication server.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n auth_http_timeout time;
\n
\n Default:\n \n
auth_http_timeout 60s;
\n
\n Context:\n \n mail, server
\n

\nSets the timeout for communication with the authentication server.\n

\n\n\n

Protocol

\nThe HTTP protocol is used to communicate with the authentication server.\nThe data in the response body is ignored, the information is passed only in\nthe headers.\n

\nExamples of requests and responses:\n

\nRequest:\n

\nGET /auth HTTP/1.0\nHost: localhost\nAuth-Method: plain # plain/apop/cram-md5/external\nAuth-User: user\nAuth-Pass: password\nAuth-Protocol: imap # imap/pop3/smtp\nAuth-Login-Attempt: 1\nClient-IP: 192.0.2.42\nClient-Host: client.example.org\n

\nGood response:\n

\nHTTP/1.0 200 OK\nAuth-Status: OK\nAuth-Server: 198.51.100.1\nAuth-Port: 143\n

\nBad response:\n

\nHTTP/1.0 200 OK\nAuth-Status: Invalid login or password\nAuth-Wait: 3\n

\n

\nIf there is no “Auth-Wait” header,\nan error will be returned and the connection will be closed.\nThe current implementation allocates memory for each authentication attempt.\nThe memory is freed only at the end of a session.\nTherefore, the number of invalid authentication attempts in a single session\nmust be limited — the server must respond without\nthe “Auth-Wait” header after 10-20 attempts\n(the attempt number is passed in the “Auth-Login-Attempt”\nheader).\n

\nWhen the APOP or CRAM-MD5 are used, request-response will look as follows:\n

\nGET /auth HTTP/1.0\nHost: localhost\nAuth-Method: apop\nAuth-User: user\nAuth-Salt: <238188073.1163692009@mail.example.com>\nAuth-Pass: auth_response\nAuth-Protocol: imap\nAuth-Login-Attempt: 1\nClient-IP: 192.0.2.42\nClient-Host: client.example.org\n

\nGood response:\n

\nHTTP/1.0 200 OK\nAuth-Status: OK\nAuth-Server: 198.51.100.1\nAuth-Port: 143\nAuth-Pass: plain-text-pass\n

\n

\nIf the “Auth-User” header exists in the response,\nit overrides the username used to authenticate with the backend.\n

\nFor the SMTP, the response additionally takes into account\nthe “Auth-Error-Code” header — if exists, it is used\nas a response code in case of an error.\nOtherwise, the 535 5.7.0 code will be added to\nthe “Auth-Status” header.\n

\nFor example, if the following response is received\nfrom the authentication server:\n

\nHTTP/1.0 200 OK\nAuth-Status: Temporary server problem, try again later\nAuth-Error-Code: 451 4.3.0\nAuth-Wait: 3\n

\nthen the SMTP client will receive an error\n

\n451 4.3.0 Temporary server problem, try again later\n

\n

\nIf proxying SMTP does not require authentication,\nthe request will look as follows:\n

\nGET /auth HTTP/1.0\nHost: localhost\nAuth-Method: none\nAuth-User:\nAuth-Pass:\nAuth-Protocol: smtp\nAuth-Login-Attempt: 1\nClient-IP: 192.0.2.42\nClient-Host: client.example.org\nAuth-SMTP-Helo: client.example.org\nAuth-SMTP-From: MAIL FROM: <>\nAuth-SMTP-To: RCPT TO: <postmaster@mail.example.com>\n

\n

\nFor the SSL/TLS client connection (1.7.11),\nthe “Auth-SSL” header is added, and\n“Auth-SSL-Verify” will contain\nthe result of client certificate verification, if\nenabled:\n“SUCCESS”, “FAILED:reason”,\nand “NONE” if a certificate was not present.\n

\nPrior to version 1.11.7, the “FAILED” result\ndid not contain the reason string.\n

\nWhen the client certificate was present,\nits details are passed in the following request headers:\n“Auth-SSL-Subject”, “Auth-SSL-Issuer”,\n“Auth-SSL-Serial”, and “Auth-SSL-Fingerprint”.\nIf auth_http_pass_client_cert is enabled,\nthe certificate itself is passed in the\n“Auth-SSL-Cert” header.\nThe protocol and cipher of the established connection\nare passed in the “Auth-SSL-Protocol”\nand “Auth-SSL-Cipher” headers (1.21.2).\nThe request will look as follows:\n

\nGET /auth HTTP/1.0\nHost: localhost\nAuth-Method: plain\nAuth-User: user\nAuth-Pass: password\nAuth-Protocol: imap\nAuth-Login-Attempt: 1\nClient-IP: 192.0.2.42\nAuth-SSL: on\nAuth-SSL-Protocol: TLSv1.3\nAuth-SSL-Cipher: TLS_AES_256_GCM_SHA384\nAuth-SSL-Verify: SUCCESS\nAuth-SSL-Subject: /CN=example.com\nAuth-SSL-Issuer: /CN=example.com\nAuth-SSL-Serial: C07AD56B846B5BFF\nAuth-SSL-Fingerprint: 29d6a80a123d13355ed16b4b04605e29cb55a5ad\n

\n

\nWhen the\nPROXY protocol\nis used,\nits details are passed in the following request headers:\n“Proxy-Protocol-Addr”,\n“Proxy-Protocol-Port”,\n“Proxy-Protocol-Server-Addr”, and\n“Proxy-Protocol-Server-Port” (1.19.8).\n

\n\n
\n", "encoding": "utf-8"} +{"path": "en\\docs\\mail\\ngx_mail_core_module.html", "extension": ".html", "size_bytes": 21209, "content": "\nModule ngx_mail_core_module
\n\nPlanning your ingress-nginx migration? Start here:\nkubernetes.nginx.org.\n\n

Module ngx_mail_core_module

Example Configuration
Directives
     listen
     mail
     max_errors
     protocol
     resolver
     resolver_timeout
     server
     server_name
     timeout
\n\n

\nThis module is not built by default, it should be\nenabled with\nthe --with-mail configuration parameter.\n

\n\n\n

Example Configuration

\n

\nworker_processes auto;\n\nerror_log /var/log/nginx/error.log info;\n\nevents {\n    worker_connections  1024;\n}\n\nmail {\n    server_name       mail.example.com;\n    auth_http         localhost:9000/cgi-bin/nginxauth.cgi;\n\n    imap_capabilities IMAP4rev1 UIDPLUS IDLE LITERAL+ QUOTA;\n\n    pop3_auth         plain apop cram-md5;\n    pop3_capabilities LAST TOP USER PIPELINING UIDL;\n\n    smtp_auth         login plain cram-md5;\n    smtp_capabilities \"SIZE 10485760\" ENHANCEDSTATUSCODES 8BITMIME DSN;\n    xclient           off;\n\n    server {\n        listen   25;\n        protocol smtp;\n    }\n    server {\n        listen   110;\n        protocol pop3;\n        proxy_pass_error_message on;\n    }\n    server {\n        listen   143;\n        protocol imap;\n    }\n    server {\n        listen   587;\n        protocol smtp;\n    }\n}\n

\n

\n\n\n

Directives

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n listen \n address:port\n [ssl]\n [proxy_protocol]\n [backlog=number]\n [rcvbuf=size]\n [sndbuf=size]\n [bind]\n [ipv6only=on|off]\n [multipath]\n [so_keepalive=on|off|[keepidle]:[keepintvl]:[keepcnt]];
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n server
\n

\nSets the address and port for the socket\non which the server will accept requests.\nIt is possible to specify just the port.\nThe address can also be a hostname, for example:\n

\nlisten 127.0.0.1:110;\nlisten *:110;\nlisten 110;     # same as *:110\nlisten localhost:110;\n

\nIPv6 addresses (0.7.58) are specified in square brackets:\n

\nlisten [::1]:110;\nlisten [::]:110;\n

\nUNIX-domain sockets (1.3.5) are specified with the “unix:”\nprefix:\n

\nlisten unix:/var/run/nginx.sock;\n

\n\n

\nDifferent servers must listen on different\naddress:port pairs.\n

\nThe ssl parameter allows specifying that all\nconnections accepted on this port should work in SSL mode.\n

\nThe proxy_protocol parameter (1.19.8)\nallows specifying that all connections accepted on this port should use the\nPROXY\nprotocol.\nObtained information is passed to the\nauthentication server\nand can be used to\nchange the client address.\n

\nThe listen directive\ncan have several additional parameters specific to socket-related system calls.\n

\n\n
\nbacklog=number\n
\n
\nsets the backlog parameter in the\nlisten() call that limits\nthe maximum length for the queue of pending connections (1.9.2).\nBy default,\nbacklog is set to -1 on FreeBSD, DragonFly BSD, and macOS,\nand to 511 on other platforms.\n
\n\n
\nrcvbuf=size\n
\n
\nsets the receive buffer size\n(the SO_RCVBUF option) for the listening socket (1.11.13).\n
\n\n
\nsndbuf=size\n
\n
\nsets the send buffer size\n(the SO_SNDBUF option) for the listening socket (1.11.13).\n
\n\n
\nbind\n
\n
\nthis parameter instructs to make a separate bind()\ncall for a given address:port pair.\nThe fact is that if there are several listen directives with\nthe same port but different addresses, and one of the\nlisten directives listens on all addresses\nfor the given port (*:port), nginx will\nbind() only to *:port.\nIt should be noted that the getsockname() system call will be\nmade in this case to determine the address that accepted the connection.\nIf the backlog,\nrcvbuf, sndbuf,\nipv6only, multipath,\nor so_keepalive parameters\nare used then for a given\naddress:port pair\na separate bind() call will always be made.\n
\n\n
\nipv6only=on|off\n
\n
\nthis parameter determines\n(via the IPV6_V6ONLY socket option)\nwhether an IPv6 socket listening on a wildcard address [::]\nwill accept only IPv6 connections or both IPv6 and IPv4 connections.\nThis parameter is turned on by default.\nIt can only be set once on start.\n
\n\n
\nmultipath\n
\n
\nthis parameter (1.29.7) configures the\nMultipath TCP\nprotocol (IPPROTO_MPTCP) for the listening socket.\nThis currently works only on Linux 5.6+.\n
\nAdding or removing this parameter will also enable\nthe SO_REUSEPORT socket option, which may have its security\nimplications.\n
\n
\n\n
\nso_keepalive=on|off|[keepidle]:[keepintvl]:[keepcnt]\n
\n
\nthis parameter configures the “TCP keepalive” behavior\nfor the listening socket.\nIf this parameter is omitted then the operating system’s settings will be\nin effect for the socket.\nIf it is set to the value “on”, the\nSO_KEEPALIVE option is turned on for the socket.\nIf it is set to the value “off”, the\nSO_KEEPALIVE option is turned off for the socket.\nSome operating systems support setting of TCP keepalive parameters on\na per-socket basis using the TCP_KEEPIDLE,\nTCP_KEEPINTVL, and TCP_KEEPCNT socket options.\nOn such systems\n(currently, Linux, NetBSD, Dragonfly, FreeBSD, and macOS),\nthey can be configured\nusing the keepidle, keepintvl, and\nkeepcnt parameters.\nOne or two parameters may be omitted, in which case the system default setting\nfor the corresponding socket option will be in effect.\nFor example,\n
so_keepalive=30m::10
\nwill set the idle timeout (TCP_KEEPIDLE) to 30 minutes,\nleave the probe interval (TCP_KEEPINTVL) at its system default,\nand set the probes count (TCP_KEEPCNT) to 10 probes.\n
\n\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n mail { ... }
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n main
\n

\nProvides the configuration file context in which the mail server directives\nare specified.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n max_errors number;
\n
\n Default:\n \n
max_errors 5;
\n
\n Context:\n \n mail, server
\n

This directive appeared in version 1.21.0.\n

\nSets the number of protocol errors after which the connection is closed.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n protocol \n imap |\n pop3 |\n smtp;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n server
\n

\nSets the protocol for a proxied server.\nSupported protocols are\nIMAP,\nPOP3, and\nSMTP.\n

\nIf the directive is not set, the protocol can be detected automatically\nbased on the well-known port specified in the listen\ndirective:\n

\n

\nUnnecessary protocols can be disabled using the\nconfiguration\nparameters --without-mail_imap_module,\n--without-mail_pop3_module, and\n--without-mail_smtp_module.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n resolver \n address ...\n [valid=time]\n [ipv4=on|off]\n [ipv6=on|off]\n [status_zone=zone];
resolver off;
\n
\n Default:\n \n
resolver off;
\n
\n Context:\n \n mail, server
\n

\nConfigures name servers used to find the client’s hostname\nto pass it to the\nauthentication server,\nand in the\nXCLIENT\ncommand when proxying SMTP.\nFor example:\n

\nresolver 127.0.0.1 [::1]:5353;\n

\nThe address can be specified as a domain name or IP address,\nwith an optional port (1.3.1, 1.2.2).\nIf port is not specified, the port 53 is used.\nName servers are queried in a round-robin fashion.\n

\nBefore version 1.1.7, only a single name server could be configured.\nSpecifying name servers using IPv6 addresses is supported\nstarting from versions 1.3.1 and 1.2.2.\n

\n

\nBy default, nginx will look up both IPv4 and IPv6 addresses while resolving.\nIf looking up of IPv4 or IPv6 addresses is not desired,\nthe ipv4=off (1.23.1) or\nthe ipv6=off parameter can be specified.\n

\nResolving of names into IPv6 addresses is supported\nstarting from version 1.5.8.\n

\n

\nBy default, nginx caches answers using the TTL value of a response.\nAn optional valid parameter allows overriding it:\n

\nresolver 127.0.0.1 [::1]:5353 valid=30s;\n

\n

\nBefore version 1.1.9, tuning of caching time was not possible,\nand nginx always cached answers for the duration of 5 minutes.\n

\n

\nTo prevent DNS spoofing, it is recommended\nconfiguring DNS servers in a properly secured trusted local network.\n

\n

\nThe optional status_zone parameter (1.17.1)\nenables\ncollection\nof DNS server statistics of requests and responses\nin the specified zone.\nThe parameter is available as part of our\ncommercial subscription.\n

\nThe special value off disables resolving.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n resolver_timeout time;
\n
\n Default:\n \n
resolver_timeout 30s;
\n
\n Context:\n \n mail, server
\n

\nSets a timeout for DNS operations, for example:\n

\nresolver_timeout 5s;\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n server { ... }
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n mail
\n

\nSets the configuration for a server.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n server_name name;
\n
\n Default:\n \n
server_name hostname;
\n
\n Context:\n \n mail, server
\n

\nSets the server name that is used:\n

\n

\nIf the directive is not specified, the machine’s hostname is used.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n timeout time;
\n
\n Default:\n \n
timeout 60s;
\n
\n Context:\n \n mail, server
\n

\nSets the timeout that is used before proxying to the backend starts.\n

\n\n
\n", "encoding": "utf-8"} +{"path": "en\\docs\\mail\\ngx_mail_imap_module.html", "extension": ".html", "size_bytes": 7274, "content": "\nModule ngx_mail_imap_module
\n\nPlanning your ingress-nginx migration? Start here:\nkubernetes.nginx.org.\n\n

Module ngx_mail_imap_module

Directives
     imap_auth
     imap_capabilities
     imap_client_buffer
\n\n

Directives

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n imap_auth method ...;
\n
\n Default:\n \n
imap_auth plain;
\n
\n Context:\n \n mail, server
\n

\nSets permitted methods of authentication for IMAP clients.\nSupported methods are:\n

\n\n
plain
\n
\nLOGIN,\nAUTH=PLAIN\n
\n\n
login
\n
\nAUTH=LOGIN\n
\n\n
cram-md5
\n
\nAUTH=CRAM-MD5.\nIn order for this method to work, the password must be stored unencrypted.\n
\n\n
external
\n
\nAUTH=EXTERNAL (1.11.6).\n
\n\n

\n

\nPlain text authentication methods\n(the LOGIN command, AUTH=PLAIN,\nand AUTH=LOGIN) are always enabled,\nthough if the plain and login methods\nare not specified,\nAUTH=PLAIN and AUTH=LOGIN\nwill not be automatically included in imap_capabilities.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n imap_capabilities extension ...;
\n
\n Default:\n \n
imap_capabilities IMAP4 IMAP4rev1 UIDPLUS;
\n
\n Context:\n \n mail, server
\n

\nSets the\nIMAP protocol\nextensions list that is passed to the client in response to\nthe CAPABILITY command.\nThe authentication methods specified in the imap_auth directive and\nSTARTTLS\nare automatically added to this list depending on the\nstarttls directive value.\n

\nIt makes sense to specify the extensions\nsupported by the IMAP backends\nto which the clients are proxied (if these extensions are related to commands\nused after the authentication, when nginx transparently proxies a client\nconnection to the backend).\n

\nThe current list of standardized extensions is published at\nwww.iana.org.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n imap_client_buffer size;
\n
\n Default:\n \n
imap_client_buffer 4k|8k;
\n
\n Context:\n \n mail, server
\n

\nSets the size of the buffer used for reading IMAP commands.\nBy default, the buffer size is equal to one memory page.\nThis is either 4K or 8K, depending on a platform.\n

\n\n
\n", "encoding": "utf-8"} +{"path": "en\\docs\\mail\\ngx_mail_pop3_module.html", "extension": ".html", "size_bytes": 6389, "content": "\nModule ngx_mail_pop3_module
\n\nPlanning your ingress-nginx migration? Start here:\nkubernetes.nginx.org.\n\n

Module ngx_mail_pop3_module

Directives
     pop3_auth
     pop3_capabilities
\n\n

Directives

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n pop3_auth method ...;
\n
\n Default:\n \n
pop3_auth plain;
\n
\n Context:\n \n mail, server
\n

\nSets permitted methods of authentication for POP3 clients.\nSupported methods are:\n

\n\n
plain
\n
\nUSER/PASS,\nAUTH PLAIN,\nAUTH LOGIN\n
\n\n
apop
\n
\nAPOP.\nIn order for this method to work, the password must be stored unencrypted.\n
\n\n
cram-md5
\n
\nAUTH CRAM-MD5.\nIn order for this method to work, the password must be stored unencrypted.\n
\n\n
external
\n
\nAUTH EXTERNAL (1.11.6).\n
\n\n

\n

\nPlain text authentication methods\n(USER/PASS, AUTH PLAIN,\nand AUTH LOGIN) are always enabled,\nthough if the plain method is not specified,\nAUTH PLAIN and AUTH LOGIN\nwill not be automatically included in pop3_capabilities.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n pop3_capabilities extension ...;
\n
\n Default:\n \n
pop3_capabilities TOP USER UIDL;
\n
\n Context:\n \n mail, server
\n

\nSets the\nPOP3 protocol\nextensions list that is passed to the client in response to\nthe CAPA command.\nThe authentication methods specified in the pop3_auth directive\n(SASL extension) and\nSTLS\nare automatically added to this list depending on the\nstarttls directive value.\n

\nIt makes sense to specify the extensions\nsupported by the POP3 backends\nto which the clients are proxied (if these extensions are related to commands\nused after the authentication, when nginx transparently proxies the client\nconnection to the backend).\n

\nThe current list of standardized extensions is published at\nwww.iana.org.\n

\n\n
\n", "encoding": "utf-8"} +{"path": "en\\docs\\mail\\ngx_mail_proxy_module.html", "extension": ".html", "size_bytes": 10785, "content": "\nModule ngx_mail_proxy_module
\n\nPlanning your ingress-nginx migration? Start here:\nkubernetes.nginx.org.\n\n

Module ngx_mail_proxy_module

Directives
     proxy_buffer
     proxy_pass_error_message
     proxy_protocol
     proxy_smtp_auth
     proxy_timeout
     xclient
\n\n

Directives

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n proxy_buffer size;
\n
\n Default:\n \n
proxy_buffer 4k|8k;
\n
\n Context:\n \n mail, server
\n

\nSets the size of the buffer used for proxying.\nBy default, the buffer size is equal to one memory page.\nDepending on a platform, it is either 4K or 8K.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n proxy_pass_error_message on | off;
\n
\n Default:\n \n
proxy_pass_error_message off;
\n
\n Context:\n \n mail, server
\n

\nIndicates whether to pass the error message obtained during\nthe authentication on the backend to the client.\n

\nUsually, if the authentication in nginx is a success,\nthe backend cannot return an error.\nIf it nevertheless returns an error,\nit means some internal error has occurred.\nIn such case the backend message can contain information\nthat should not be shown to the client.\nHowever, responding with an error for the correct password\nis a normal behavior for some POP3 servers.\nFor example, CommuniGatePro informs a user about\nmailbox\noverflow or other events by periodically outputting the\nauthentication\nerror.\nThe directive should be enabled in this case.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n proxy_protocol on | off;
\n
\n Default:\n \n
proxy_protocol off;
\n
\n Context:\n \n mail, server
\n

This directive appeared in version 1.19.8.\n

\nEnables the\nPROXY\nprotocol for connections to a backend.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n proxy_smtp_auth on | off;
\n
\n Default:\n \n
proxy_smtp_auth off;
\n
\n Context:\n \n mail, server
\n

This directive appeared in version 1.19.4.\n

\nEnables or disables user authentication on the SMTP backend\nusing the AUTH command.\n

\nIf XCLIENT is also enabled,\nthen the XCLIENT command will not send\nthe LOGIN parameter.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n proxy_timeout timeout;
\n
\n Default:\n \n
proxy_timeout 24h;
\n
\n Context:\n \n mail, server
\n

\nSets the timeout between two successive\nread or write operations on client or proxied server connections.\nIf no data is transmitted within this time, the connection is closed.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n xclient on | off;
\n
\n Default:\n \n
xclient on;
\n
\n Context:\n \n mail, server
\n

\nEnables or disables the passing of the\nXCLIENT\ncommand with client parameters when connecting to the SMTP backend.\n

\nWith XCLIENT, the MTA is able to write client information\nto the log and apply various limitations based on this data.\n

\nIf XCLIENT is enabled\nthen nginx passes the following commands when connecting to the backend:\n

\n

\nIf the name\nfound\nby the client IP address points to the same address,\nit is passed in the NAME parameter\nof the XCLIENT command.\nIf the name could not be found, points to a different address,\nor resolver is not specified,\nthe [UNAVAILABLE] is passed\nin the NAME parameter.\nIf an error has occurred in the process of resolving,\nthe [TEMPUNAVAIL] value is used.\n

\nIf XCLIENT is disabled\nthen nginx passes the EHLO command with the\nserver name\nwhen connecting to the backend if the client has passed\nEHLO,\nor HELO with the server name, otherwise.\n

\n\n
\n", "encoding": "utf-8"} +{"path": "en\\docs\\mail\\ngx_mail_realip_module.html", "extension": ".html", "size_bytes": 4240, "content": "\nModule ngx_mail_realip_module
\n\nPlanning your ingress-nginx migration? Start here:\nkubernetes.nginx.org.\n\n

Module ngx_mail_realip_module

Example Configuration
Directives
     set_real_ip_from
\n\n

\nThe ngx_mail_realip_module module is used\nto change the client address and port\nto the ones sent in the PROXY protocol header (1.19.8).\nThe PROXY protocol must be previously enabled by setting the\nproxy_protocol parameter\nin the listen directive.\n

\n\n\n

Example Configuration

\n

\nlisten 110 proxy_protocol;\n\nset_real_ip_from  192.168.1.0/24;\nset_real_ip_from  192.168.2.1;\nset_real_ip_from  2001:0db8::/32;\n

\n

\n\n\n

Directives

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n set_real_ip_from \n address |\n CIDR |\n unix:;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n mail, server
\n

\nDefines trusted addresses that are known to send correct\nreplacement addresses.\nIf the special value unix: is specified,\nall UNIX-domain sockets will be trusted.\n

\n\n
\n", "encoding": "utf-8"} +{"path": "en\\docs\\mail\\ngx_mail_smtp_module.html", "extension": ".html", "size_bytes": 8233, "content": "\nModule ngx_mail_smtp_module
\n\nPlanning your ingress-nginx migration? Start here:\nkubernetes.nginx.org.\n\n

Module ngx_mail_smtp_module

Directives
     smtp_auth
     smtp_capabilities
     smtp_client_buffer
     smtp_greeting_delay
\n\n

Directives

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n smtp_auth method ...;
\n
\n Default:\n \n
smtp_auth plain login;
\n
\n Context:\n \n mail, server
\n

\nSets permitted methods of\nSASL authentication\nfor SMTP clients.\nSupported methods are:\n

\n\n
plain
\n
\nAUTH PLAIN\n
\n\n
login
\n
\nAUTH LOGIN\n
\n\n
cram-md5
\n
\nAUTH CRAM-MD5.\nIn order for this method to work, the password must be stored unencrypted.\n
\n\n
external
\n
\nAUTH EXTERNAL (1.11.6).\n
\n\n
none
\n
\nAuthentication is not required.\n
\n\n

\n

\nPlain text authentication methods\n(AUTH PLAIN and AUTH LOGIN)\nare always enabled,\nthough if the plain and login methods\nare not specified,\nAUTH PLAIN and AUTH LOGIN\nwill not be automatically included in smtp_capabilities.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n smtp_capabilities extension ...;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n mail, server
\n

\nSets the SMTP protocol extensions list\nthat is passed to the client in response to the\nEHLO command.\nThe authentication methods specified in the smtp_auth directive and\nSTARTTLS\nare automatically added to this list depending on the\nstarttls directive value.\n

\nIt makes sense to specify the extensions\nsupported by the MTA\nto which the clients are proxied (if these extensions are related to commands\nused after the authentication, when nginx transparently proxies the client\nconnection to the backend).\n

\nThe current list of standardized extensions is published at\nwww.iana.org.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n smtp_client_buffer size;
\n
\n Default:\n \n
smtp_client_buffer 4k|8k;
\n
\n Context:\n \n mail, server
\n

\nSets the size of the buffer used for reading SMTP commands.\nBy default, the buffer size is equal to one memory page.\nThis is either 4K or 8K, depending on a platform.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n smtp_greeting_delay time;
\n
\n Default:\n \n
smtp_greeting_delay 0;
\n
\n Context:\n \n mail, server
\n

\nAllows setting a delay before sending an SMTP greeting\nin order to reject clients who fail to wait for the greeting before\nsending SMTP commands.\n

\n\n
\n", "encoding": "utf-8"} +{"path": "en\\docs\\mail\\ngx_mail_ssl_module.html", "extension": ".html", "size_bytes": 35489, "content": "\nModule ngx_mail_ssl_module
\n\nPlanning your ingress-nginx migration? Start here:\nkubernetes.nginx.org.\n\n

Module ngx_mail_ssl_module

Example Configuration
Directives
     ssl
     ssl_certificate
     ssl_certificate_compression
     ssl_certificate_key
     ssl_ciphers
     ssl_client_certificate
     ssl_conf_command
     ssl_crl
     ssl_dhparam
     ssl_ecdh_curve
     ssl_password_file
     ssl_prefer_server_ciphers
     ssl_protocols
     ssl_session_cache
     ssl_session_ticket_key
     ssl_session_tickets
     ssl_session_timeout
     ssl_trusted_certificate
     ssl_verify_client
     ssl_verify_depth
     starttls
\n\n

\nThe ngx_mail_ssl_module module provides the necessary\nsupport for a mail proxy server to work with the SSL/TLS protocol.\n

\nThis module is not built by default, it should be enabled with the\n--with-mail_ssl_module\nconfiguration parameter.\n

\nThis module requires the\nOpenSSL library.\n

\n

\n\n\n

Example Configuration

\nTo reduce the processor load, it is recommended to\n

\n\n

\nworker_processes auto;\n\nmail {\n\n    ...\n\n    server {\n        listen              993 ssl;\n\n        ssl_protocols       TLSv1.2 TLSv1.3;\n        ssl_ciphers         AES128-SHA:AES256-SHA:RC4-SHA:DES-CBC3-SHA:RC4-MD5;\n        ssl_certificate     /usr/local/nginx/conf/cert.pem;\n        ssl_certificate_key /usr/local/nginx/conf/cert.key;\n        ssl_session_cache   shared:SSL:10m;\n        ssl_session_timeout 10m;\n\n        ...\n    }\n

\n

\n\n\n

Directives

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n ssl on | off;
\n
\n Default:\n \n
ssl off;
\n
\n Context:\n \n mail, server
\n

\nThis directive was made obsolete in version 1.15.0\nand was removed in version 1.25.1.\nThe ssl parameter\nof the listen directive\nshould be used instead.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n ssl_certificate file;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n mail, server
\n

\nSpecifies a file with the certificate in the PEM format\nfor the given server.\nIf intermediate certificates should be specified in addition to a primary\ncertificate, they should be specified in the same file in the following\norder: the primary certificate comes first, then the intermediate certificates.\nA secret key in the PEM format may be placed in the same file.\n

\nSince version 1.11.0,\nthis directive can be specified multiple times\nto load certificates of different types, for example, RSA and ECDSA:\n

\nserver {\n    listen              993 ssl;\n\n    ssl_certificate     example.com.rsa.crt;\n    ssl_certificate_key example.com.rsa.key;\n\n    ssl_certificate     example.com.ecdsa.crt;\n    ssl_certificate_key example.com.ecdsa.key;\n\n    ...\n}\n

\n

\nOnly OpenSSL 1.0.2 or higher supports separate\ncertificate\nchains\nfor different certificates.\nWith older versions, only one certificate chain can be used.\n

\n

\nThe value\ndata:certificate\ncan be specified instead of the file (1.15.10),\nwhich loads a certificate\nwithout using intermediate files.\nNote that inappropriate use of this syntax may have its security implications,\nsuch as writing secret key data to\nerror log.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n ssl_certificate_compression on | off;
\n
\n Default:\n \n
ssl_certificate_compression off;
\n
\n Context:\n \n mail, server
\n

This directive appeared in version 1.29.1.\n

\nEnables TLS 1.3\ncompression\nof server certificates.\n

\nThe directive is supported when using OpenSSL 3.2 or higher;\nthe list of supported compression algorithms is provided by the library.\n

\n

\nThe directive is supported when using BoringSSL;\nthe list of supported compression algorithms includes\nzlib (1.29.3).\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n ssl_certificate_key file;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n mail, server
\n

\nSpecifies a file with the secret key in the PEM format\nfor the given server.\n

\nThe value\nengine:name:id\ncan be specified instead of the file (1.7.9),\nwhich loads a secret key with a specified id\nfrom the OpenSSL engine name.\n

\nThe value\nstore:scheme:id\ncan be specified instead of the file (1.29.0),\nwhich is used to load a secret key with a specified id\nand OpenSSL provider registered URI scheme, such as\npkcs11.\n

\nThe value\ndata:key\ncan be specified instead of the file (1.15.10),\nwhich loads a secret key without using intermediate files.\nNote that inappropriate use of this syntax may have its security implications,\nsuch as writing secret key data to\nerror log.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n ssl_ciphers ciphers;
\n
\n Default:\n \n
ssl_ciphers HIGH:!aNULL:!MD5;
\n
\n Context:\n \n mail, server
\n

\nSpecifies the enabled ciphers.\nThe ciphers are specified in the format understood by the\nOpenSSL library, for example:\n

\nssl_ciphers ALL:!aNULL:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP;\n

\n

\nThe full list can be viewed using the\n“openssl ciphers” command.\n

\n

\nThe previous versions of nginx used\ndifferent\nciphers by default.\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n ssl_client_certificate file;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n mail, server
\n

This directive appeared in version 1.7.11.\n

\nSpecifies a file with trusted CA certificates in the PEM format\nused to verify client certificates.\n

\nThe list of certificates will be sent to clients.\nIf this is not desired, the ssl_trusted_certificate\ndirective can be used.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n ssl_conf_command name value;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n mail, server
\n

This directive appeared in version 1.19.4.\n

\nSets arbitrary OpenSSL configuration\ncommands.\n

\nThe directive is supported when using OpenSSL 1.0.2 or higher.\n

\n

\nSeveral ssl_conf_command directives\ncan be specified on the same level:\n

\nssl_conf_command Options PrioritizeChaCha;\nssl_conf_command Ciphersuites TLS_CHACHA20_POLY1305_SHA256;\n

\nThese directives are inherited from the previous configuration level\nif and only if there are no ssl_conf_command directives\ndefined on the current level.\n

\n

\nNote that configuring OpenSSL directly\nmight result in unexpected behavior.\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n ssl_crl file;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n mail, server
\n

This directive appeared in version 1.7.11.\n

\nSpecifies a file with revoked certificates (CRL)\nin the PEM format used to verify\nclient certificates.\nWhen using intermediate certificates, their CRLs should be\nspecified in the same file.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n ssl_dhparam file;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n mail, server
\n

This directive appeared in version 0.7.2.\n

\nSpecifies a file with DH parameters for DHE ciphers.\n

\nBy default no parameters are set,\nand therefore DHE ciphers will not be used.\n

\nPrior to version 1.11.0, builtin parameters were used by default.\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n ssl_ecdh_curve curve;
\n
\n Default:\n \n
ssl_ecdh_curve auto;
\n
\n Context:\n \n mail, server
\n
\n

\n This directive appeared in versions 1.1.0 and 1.0.6.\n \n

\n

\nSpecifies a curve for ECDHE ciphers.\n

\nWhen using OpenSSL 1.0.2 or higher,\nit is possible to specify multiple curves (1.11.0), for example:\n

\nssl_ecdh_curve prime256v1:secp384r1;\n

\n

\nThe special value auto (1.11.0) instructs nginx to use\na list built into the OpenSSL library when using OpenSSL 1.0.2 or higher,\nor prime256v1 with older versions.\n

\n

\nPrior to version 1.11.0,\nthe prime256v1 curve was used by default.\n

\n

\n

\nWhen using OpenSSL 1.0.2 or higher,\nthis directive sets the list of curves supported by the server.\nThus, in order for ECDSA certificates to work,\nit is important to include the curves used in the certificates.\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n ssl_password_file file;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n mail, server
\n

This directive appeared in version 1.7.3.\n

\nSpecifies a file with passphrases for\nsecret keys\nwhere each passphrase is specified on a separate line.\nPassphrases are tried in turn when loading the key.\n

\nExample:\n

\nmail {\n    ssl_password_file /etc/keys/global.pass;\n    ...\n\n    server {\n        server_name mail1.example.com;\n        ssl_certificate_key /etc/keys/first.key;\n    }\n\n    server {\n        server_name mail2.example.com;\n\n        # named pipe can also be used instead of a file\n        ssl_password_file /etc/keys/fifo;\n        ssl_certificate_key /etc/keys/second.key;\n    }\n}\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n ssl_prefer_server_ciphers on | off;
\n
\n Default:\n \n
ssl_prefer_server_ciphers off;
\n
\n Context:\n \n mail, server
\n

\nSpecifies that server ciphers should be preferred over client ciphers\nwhen the SSLv3 and TLS protocols are used.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n ssl_protocols \n [SSLv2]\n [SSLv3]\n [TLSv1]\n [TLSv1.1]\n [TLSv1.2]\n [TLSv1.3];
\n
\n Default:\n \n
ssl_protocols TLSv1.2 TLSv1.3;
\n
\n Context:\n \n mail, server
\n

\nEnables the specified protocols.\n

\nThe TLSv1.1 and TLSv1.2 parameters\n(1.1.13, 1.0.12) work only when OpenSSL 1.0.1 or higher is used.\n

\n

\nThe TLSv1.3 parameter (1.13.0) works only when\nOpenSSL 1.1.1 or higher is used.\n

\n

\nThe TLSv1.3 parameter is used by default\nsince 1.23.4.\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n ssl_session_cache \n off |\n none |\n [builtin[:size]]\n [shared:name:size];
\n
\n Default:\n \n
ssl_session_cache none;
\n
\n Context:\n \n mail, server
\n

\nSets the types and sizes of caches that store session parameters.\nA cache can be of any of the following types:\n

\n\n
off
\n
\nthe use of a session cache is strictly prohibited:\nnginx explicitly tells a client that sessions may not be reused.\n
\n\n
none
\n
\nthe use of a session cache is gently disallowed:\nnginx tells a client that sessions may be reused, but does not\nactually store session parameters in the cache.\n
\n\n
builtin
\n
\na cache built in OpenSSL; used by one worker process only.\nThe cache size is specified in sessions.\nIf size is not given, it is equal to 20480 sessions.\nUse of the built-in cache can cause memory fragmentation.\n
\n\n
shared
\n
\na cache shared between all worker processes.\nThe cache size is specified in bytes; one megabyte can store\nabout 4000 sessions.\nEach shared cache should have an arbitrary name.\nA cache with the same name can be used in several\nservers.\nIt is also used to automatically generate, store, and\nperiodically rotate TLS session ticket keys (1.23.2)\nunless configured explicitly\nusing the ssl_session_ticket_key directive.\n
\n\n

\n

\nBoth cache types can be used simultaneously, for example:\n

\nssl_session_cache builtin:1000 shared:SSL:10m;\n

\nbut using only shared cache without the built-in cache should\nbe more efficient.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n ssl_session_ticket_key file;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n mail, server
\n

This directive appeared in version 1.5.7.\n

\nSets a file with the secret key used to encrypt\nand decrypt TLS session tickets.\nThe directive is necessary if the same key has to be shared between\nmultiple servers.\nBy default, a randomly generated key is used.\n

\nIf several keys are specified, only the first key is\nused to encrypt TLS session tickets.\nThis allows configuring key rotation, for example:\n

\nssl_session_ticket_key current.key;\nssl_session_ticket_key previous.key;\n

\n

\nThe file must contain 80 or 48 bytes\nof random data and can be created using the following command:\n

\nopenssl rand 80 > ticket.key\n

\nDepending on the file size either AES256 (for 80-byte keys, 1.11.8)\nor AES128 (for 48-byte keys) is used for encryption.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n ssl_session_tickets on | off;
\n
\n Default:\n \n
ssl_session_tickets on;
\n
\n Context:\n \n mail, server
\n

This directive appeared in version 1.5.9.\n

\nEnables or disables session resumption through\nTLS session tickets.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n ssl_session_timeout time;
\n
\n Default:\n \n
ssl_session_timeout 5m;
\n
\n Context:\n \n mail, server
\n

\nSpecifies a time during which a client may reuse the\nsession parameters.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n ssl_trusted_certificate file;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n mail, server
\n

This directive appeared in version 1.7.11.\n

\nSpecifies a file with trusted CA certificates in the PEM format\nused to verify client certificates.\n

\nIn contrast to the certificate set by ssl_client_certificate,\nthe list of these certificates will not be sent to clients.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n ssl_verify_client \n on | off |\n optional | optional_no_ca;
\n
\n Default:\n \n
ssl_verify_client off;
\n
\n Context:\n \n mail, server
\n

This directive appeared in version 1.7.11.\n

\nEnables verification of client certificates.\nThe verification result is passed in the\n“Auth-SSL-Verify” header of the\nauthentication\nrequest.\n

\nThe optional parameter requests the client\ncertificate and verifies it if the certificate is present.\n

\nThe optional_no_ca parameter\nrequests the client\ncertificate but does not require it to be signed by a trusted CA certificate.\nThis is intended for the use in cases when a service that is external to nginx\nperforms the actual certificate verification.\nThe contents of the certificate is accessible through requests\nsent\nto the authentication server.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n ssl_verify_depth number;
\n
\n Default:\n \n
ssl_verify_depth 1;
\n
\n Context:\n \n mail, server
\n

This directive appeared in version 1.7.11.\n

\nSets the verification depth in the client certificates chain.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n starttls \n on |\n off |\n only;
\n
\n Default:\n \n
starttls off;
\n
\n Context:\n \n mail, server
\n

\n

\n\n
on
\n
\nallow usage of the STLS command for the POP3\nand the STARTTLS command for the IMAP and SMTP;\n
\n\n
off
\n
\ndeny usage of the STLS\nand STARTTLS commands;\n
\n\n
only
\n
\nrequire preliminary TLS transition.\n
\n\n

\n

\n\n
\n", "encoding": "utf-8"} +{"path": "en\\docs\\njs\\changes.html", "extension": ".html", "size_bytes": 124793, "content": "\nChanges
\n\nPlanning your ingress-nginx migration? Start here:\nkubernetes.nginx.org.\n\n

Changes

Changes with njs 0.9.9

\nRelease Date:\n19 May 2026\n

\nnginx modules:\n

\n

\nCore:\n

\n

Changes with njs 0.9.8

\nRelease Date:\n23 April 2026\n

\nnginx modules:\n

\n

Changes with njs 0.9.7

\nRelease Date:\n21 April 2026\n

\nnginx modules:\n

\n

\nCore:\n

\n

Changes with njs 0.9.6

\nRelease Date:\n3 March 2026\n

\nnginx modules:\n

\n

\nCore:\n

\n

Changes with njs 0.9.5

\nRelease Date:\n13 January 2026\n

\nnginx modules:\n

\n

\nCore:\n

\n

Changes with njs 0.9.4

\nRelease Date:\n28 October 2025\n

\nnginx modules:\n

\n

\nCore:\n

\n

Changes with njs 0.9.3

\nRelease Date:\n07 October 2025\n

\nnginx modules:\n

\n

Changes with njs 0.9.2

\nRelease Date:\n23 September 2025\n

\nnginx modules:\n

\n

\nCore:\n

\n

Changes with njs 0.9.1

\nRelease Date:\n10 Jul 2025\n

\nnginx modules:\n

\n

\nCore:\n

\n

Changes with njs 0.9.0

\nRelease Date:\n06 May 2025\n

\nCore:\n

\n

Changes with njs 0.8.10

\nRelease Date:\n08 April 2025\n

\nnginx modules:\n

\n

\nCore:\n

\n

Changes with njs 0.8.9

\nRelease Date:\n14 January 2025\n

\nnginx modules:\n

\n

\nCore:\n

\n

Changes with njs 0.8.8

\nRelease Date:\n10 December 2024\n

\nnginx modules:\n

\n

\nCore:\n

\n

Changes with njs 0.8.7

\nRelease Date:\n22 October 2024\n

\nnginx modules:\n

\n

\nCore:\n

\n

Changes with njs 0.8.6

\nRelease Date:\n02 October 2024\n

\nnginx modules:\n

\n

\nCore:\n

\n

Changes with njs 0.8.5

\nRelease Date:\n25 June 2024\n

\nnginx modules:\n

\n

\nCore:\n

\n

Changes with njs 0.8.4

\nRelease Date:\n16 April 2024\n

\nnginx modules:\n

\n

\nCore:\n

\n

Changes with njs 0.8.3

\nRelease Date:\n07 February 2024\n

\nnginx modules:\n

\n

\nCore:\n

\n

Changes with njs 0.8.2

\nRelease Date:\n24 October 2023\n

\nnginx modules:\n

\n

\nCore:\n

\n

Changes with njs 0.8.1

\nRelease Date:\n12 September 2023\n

\nnginx modules:\n

\n

\nCore:\n

\n

Changes with njs 0.8.0

\nRelease Date:\n06 July 2023\n

\nnginx modules:\n

\n

\nCore:\n

\n

Changes with njs 0.7.12

\nRelease Date:\n10 April 2023\n

\nnginx modules:\n

\n

\nCore:\n

\n

Changes with njs 0.7.11

\nRelease Date:\n09 March 2023\n

\nnginx modules:\n

\n

\nCore:\n

\n

Changes with njs 0.7.10

\nRelease Date:\n07 February 2023\n

\nnginx modules:\n

\n

\nCore:\n

\n

Changes with njs 0.7.9

\nRelease Date:\n17 November 2022\n

\nnginx modules:\n

\n

\nCore:\n

\n

Changes with njs 0.7.8

\nRelease Date:\n25 October 2022\n

\nnginx modules:\n

\n

\nCore:\n

\n

Changes with njs 0.7.7

\nRelease Date:\n30 August 2022\n

\nnginx modules:\n

\n

\nCore:\n

\n

Changes with njs 0.7.6

\nRelease Date:\n19 July 2022\n

\nnginx modules:\n

\n

\nCore:\n

\n

Changes with njs 0.7.5

\nRelease Date:\n21 June 2022\n

\nnginx modules:\n

\n

\nCore:\n

\n

Changes with njs 0.7.4

\nRelease Date:\n24 May 2022\n

\nnginx modules:\n

\n

\nCore:\n

\n

Changes with njs 0.7.3

\nRelease Date:\n12 April 2022\n

\nCore:\n

\n

Changes with njs 0.7.2

\nRelease Date:\n25 January 2022\n

\nCore:\n

\n

Changes with njs 0.7.1

\nRelease Date:\n28 December 2021\n

\nnginx modules:\n

\n

\nCore:\n

\n\n

Changes with njs 0.7.0

\nRelease Date:\n19 October 2021\n

\nnginx modules:\n

\n

\nCore:\n

\n\n

Changes with njs 0.6.2

\nRelease Date:\n31 August 2021\n

\nnginx modules:\n

\n

\nCore:\n

\n\n

Changes with njs 0.6.1

\nRelease Date:\n29 June 2021\n

\n

\n

Changes with njs 0.6.0

\nRelease Date:\n15 June 2021\n

\nCore:\n

\n

Changes with njs 0.5.3

\nRelease Date:\n30 March 2021\n

\nnginx modules:\n

\n

Changes with njs 0.5.2

\nRelease Date:\n09 March 2021\n

\nnginx modules:\n

\n

\nCore:\n

\n

Changes with njs 0.5.1

\nRelease Date:\n16 February 2021\n

\nnginx modules:\n

\n

\nCore:\n

\n

Changes with njs 0.5.0

\nRelease Date:\n01 December 2020\n

\nnginx modules:\n

\n

\nCore:\n

\n

Changes with njs 0.4.4

\nRelease Date:\n29 September 2020\n

\nnginx modules:\n

\n

\nCore:\n

\n

Changes with njs 0.4.3

\nRelease Date:\n11 August 2020\n

\nCore:\n

\n

Changes with njs 0.4.2

\nRelease Date:\n07 July 2020\n

\nCore:\n

\n

Changes with njs 0.4.1

\nRelease Date:\n19 May 2020\n

\nnginx modules:\n

\n

\nCore:\n

\n

Changes with njs 0.4.0

\nRelease Date:\n23 April 2020\n

\nnginx modules:\n

\n

\nCore:\n

\n

Changes with njs 0.3.9

\nRelease Date:\n03 March 2020\n

\nnginx modules:\n

\n

\nCore:\n

\n

Changes with njs 0.3.8

\nRelease Date:\n21 January 2020\n

\nnginx modules:\n

\n

\nCore:\n

\n

Changes with njs 0.3.7

\nRelease Date:\n19 November 2019\n

\nnginx modules:\n

\n

\nCore:\n

\n

Changes with njs 0.3.6

\nRelease Date:\n22 October 2019\n

\nnginx modules:\n

\n

\nCore:\n

\n

Changes with njs 0.3.5

\nRelease Date:\n15 August 2019\n

\nCore:\n

\n

Changes with njs 0.3.4

\nRelease Date:\n13 August 2019\n

\nCore:\n

\n

Changes with njs 0.3.3

\nRelease Date:\n25 June 2019\n

\nnginx modules:\n

\n

\nCore:\n

\n

Changes with njs 0.3.2

\nRelease Date:\n21 May 2019\n

\nCore:\n

\n

Changes with njs 0.3.1

\nRelease Date:\n16 April 2019\n

\nCore:\n

\n

Changes with njs 0.3.0

\nRelease Date:\n26 March 2019\n

\nnginx modules:\n

\n

\nCore:\n

\n

Changes with njs 0.2.8

\nRelease Date:\n26 February 2019\n

\nnginx modules:\n

\n

\nCore:\n

\n

Changes with njs 0.2.7

\nRelease Date:\n25 December 2018\n

\nCore:\n

\n

Changes with njs 0.2.6

\nRelease Date:\n27 November 2018\n

\nCore:\n

\n

Changes with njs 0.2.5

\nRelease Date:\n30 October 2018\n

\nnginx modules:\n

\n

\nCore:\n

\n

Changes with njs 0.2.4

\nRelease Date:\n18 September 2018\n

\nnginx modules:\n

\n

\nCore:\n

\n

Changes with njs 0.2.3

\nRelease Date:\n31 July 2018\n

\nnginx modules:\n

\n

\nCore:\n

\n

Changes with njs 0.2.2

\nRelease Date:\n19 June 2018\n

\nnginx modules:\n

\n

\nCore:\n

\n

Changes with njs 0.2.1

\nRelease Date:\n31 May 2018\n

\nnginx modules:\n

\n

\nCore:\n

\n

Changes with njs 0.2.0

\nRelease Date:\n03 April 2018\n

\n

\n

Changes with njs 0.1.15

\nRelease Date:\n20 November 2017\n

\n

\n

Changes with njs 0.1.14

\nRelease Date:\n09 October 2017\n

\n

\n

Changes with njs 0.1.13

\nRelease Date:\n31 August 2017\n

\n

\n

Changes with njs 0.1.12

\nRelease Date:\n08 August 2017\n

\n

\n

Changes with njs 0.1.11

\nRelease Date:\n27 June 2017\n

\n

\n

Changes with njs 0.1.10

\nRelease Date:\n04 April 2017\n

\n

\n

Changes with njs 0.1.9

\nRelease Date:\n01 February 2017\n

\n

\n

Changes with njs 0.1.8

\nRelease Date:\n24 January 2017\n

\n

\n

Changes with njs 0.1.7

\nRelease Date:\n27 December 2016\n

\n

\n

Changes with njs 0.1.6

\nRelease Date:\n13 December 2016\n

\n

\n

\n", "encoding": "utf-8"} +{"path": "en\\docs\\njs\\cli.html", "extension": ".html", "size_bytes": 3304, "content": "\nCommand-line interface
\n\nPlanning your ingress-nginx migration? Start here:\nkubernetes.nginx.org.\n\n

Command-line interface

\nnjs scripts development and debugging can be performed\nfrom the command-line.\nThe command-line utility is available after the installation of\nthe Linux package\nor after building from the\nsources.\nCompared to njs running inside nginx,\nnginx objects\n(HTTP and\nStream)\nare not available in the utility.\n

\n$ echo \"2**3\" | njs -q\n8\n\n$ njs\n>> globalThis\nglobal {\n njs: njs {\n  version: '0.3.9'\n },\n global: [Circular],\n process: process {\n  argv: [\n   '/usr/bin/njs'\n  ],\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.17.9',\n   NJS_VERSION: '0.3.9',\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>>\n

\n

\n", "encoding": "utf-8"} +{"path": "en\\docs\\njs\\compatibility.html", "extension": ".html", "size_bytes": 38420, "content": "\nCompatibility
\n\nPlanning your ingress-nginx migration? Start here:\nkubernetes.nginx.org.\n\n

Compatibility

\nnjs is created in compliance with\nECMAScript 5.1\n(strict mode) with some\nECMAScript 6\nand later extensions.\nThe compliance is still evolving.\n

\nDefinitions of njs specific properties and methods\nnot compliant with ECMAScript can be found in\nReference.\nDefinitions of njs properties and methods\ncompliant with ECMAScript can be found in\nECMAScript\nspecification.\n

What is currently supported

\n

\n

\n", "encoding": "utf-8"} +{"path": "en\\docs\\njs\\engine.html", "extension": ".html", "size_bytes": 5550, "content": "\nJavaScript Engine
\n\nPlanning your ingress-nginx migration? Start here:\nkubernetes.nginx.org.\n\n

JavaScript Engine

\nStarting from version 0.8.6,\nmultiple JavaScript engines are supported.\nTo specify a particular engine, use the js_engine directive\navailable for both the\nhttp\nand\nstream.\nBy default, the njs engine is used.\n

njs engine

\nnjs is an embeddable JavaScript engine\ndeveloped as a part of the njs module.\nSee the Сompatibility section for details.\n

QuickJS engine

\nQuickJS is a lightweight,\nembeddable JavaScript engine that supports\nthe ES2023 specification,\nincluding features as modules, asynchronous generators, proxies and BigInt.\n

\nSince version 0.8.6,\na drop-in replacement for\nnjs/nginx objects\nhas been introduced\nto ensure compatibility with the njs engine, with the following exceptions:\n\n

\n\n

\nnjs built-in modules status:\n\n

\n\n

\nnjs built-in objects status:\n\n

\n\n

\nnginx built-in objects status:\n\n

\n\n

\n", "encoding": "utf-8"} +{"path": "en\\docs\\njs\\index.html", "extension": ".html", "size_bytes": 5780, "content": "\nnginx JavaScript module
\n\nPlanning your ingress-nginx migration? Start here:\nkubernetes.nginx.org.\n\n

nginx JavaScript module

\nnjs is an nginx module that extends the server's functionality through\nJavaScript scripting, enabling the creation of custom\nserver-side logic and more.\n

\n

\n

\n

\n

\n

\n

Use cases

\n

\nSee examples\nfor more njs use cases.\n

Basic HTTP Example

\nTo use njs in nginx:\n

\nThere is also a standalone command line utility\nthat can be used independently of nginx for njs development and debugging.\n

Tested OS and platforms

\n

\n

Presentation at nginx.conf 2018

\n", "encoding": "utf-8"} +{"path": "en\\docs\\njs\\install.html", "extension": ".html", "size_bytes": 5347, "content": "\nDownload and install
\n\nPlanning your ingress-nginx migration? Start here:\nkubernetes.nginx.org.\n\n

Download and install

Installing as a Linux package
Building from the sources
     Adding QuickJS engine support
Building njs command-line utility

Installing as a Linux package

\nFor Linux, njs modules\npackages can be used:\n

\n

\nAfter package installation, njs dynamic modules need to be loaded with the\nload_module\ndirective:\n

\nload_module modules/ngx_http_js_module.so;\n

\nor\n

\nload_module modules/ngx_stream_js_module.so;\n

\n

Building from the sources

\nThe repository\nwith njs sources can be cloned with the following command\n(requires Git client):\n

\ngit clone https://github.com/nginx/njs\n

\nThen the modules should be compiled from\nnginx root directory using the\n--add-module configuration parameter:\n

\n./configure --add-module=path-to-njs/nginx\n

\nThe modules can also be built as\ndynamic:\n

\n./configure --add-dynamic-module=path-to-njs/nginx\n

\n

Adding QuickJS engine support

\nMake sure you have built the QuickJS library:\n

\ngit clone https://github.com/bellard/quickjs\ncd quickjs\nCFLAGS='-fPIC' make libquickjs.a\n

\nAt the module compilation step, also\nspecify the include (-I) and library (-L)\npaths with the\n--with-cc-opt= and\n--with-ld-opt= configuration parameters:\n

\n./configure --add-module=path-to-njs/nginx \\\n    --with-cc-opt=\"-I path-to-quickjs\" \\\n    --with-ld-opt=\"-L path-to-quickjs\"\n

\n

Building njs command-line utility

\nTo build only the njs command-line utility, run\n./configure and make njs commands\nfrom njs root directory.\nAfter building, the utility is available as ./build/njs.\n

\n", "encoding": "utf-8"} +{"path": "en\\docs\\njs\\native_modules.html", "extension": ".html", "size_bytes": 8514, "content": "\nNative modules
\n\nPlanning your ingress-nginx migration? Start here:\nkubernetes.nginx.org.\n\n

Native modules

Overview
When to use native modules
Loading native modules in NGINX
Building native modules
Additional resources

Overview

\nNative modules allow loading C-based shared libraries (.so files)\ninto NGINX JavaScript for performance-critical operations\nor system-level integrations.\nThis feature is available only with the\nQuickJS engine\nand is not supported by the njs native engine.\nNative module support has been available\nsince 0.9.5.\n

When to use native modules

\nNative modules are useful in the following scenarios:\n\n

\n

\nNative modules should be used for low-level primitives\nrather than for complex business logic,\nfor example, for cryptographic operations (hashing, encryption),\ndata compression/decompression, binary protocol parsing,\nhigh-performance string operations, or mathematical computations.\nComplex application logic should remain in JavaScript\nwhere it's easier to maintain, debug, and modify.\n

\nLimitations:\n\n

\n

Loading native modules in NGINX

\nNative modules are loaded using these directives\nspecified in the main context:\n\n

\n

\nExample configuration:\n

\njs_load_http_native_module /path/to/mylib.so;\njs_load_http_native_module /path/to/other.so as myalias;\n\nhttp {\n    js_import main.js;\n\n    server {\n        listen 8000;\n        location / {\n            js_content main.handler;\n        }\n    }\n}\n

\n

\nOnce loaded, the module can be imported in JavaScript code:\n

\n// Import by filename\nimport * as mylib from 'mylib.so';\n\n// Import by alias\nimport * as myalias from 'myalias';\n\nfunction handler(r) {\n    let result = mylib.add(5, 10);\n    r.return(200, `Result: ${result}\\n`);\n}\n\nexport default { handler };\n

\n

Building native modules

\nNative modules must implement the js_init_module\nfunction as the entry point.\nThis function is called by QuickJS when the module is loaded.\n

\nA complete example of a simple native module\nthat exports two functions:\n

\n#include <quickjs.h>\n\n#define countof(x) (sizeof(x) / sizeof((x)[0]))\n\n/* Add two numbers */\nstatic JSValue\njs_add(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv)\n{\n    int a, b;\n\n    if (argc < 2) {\n        return JS_ThrowTypeError(ctx, \"expected 2 arguments\");\n    }\n\n    if (JS_ToInt32(ctx, &a, argv[0]) < 0) {\n        return JS_EXCEPTION;\n    }\n\n    if (JS_ToInt32(ctx, &b, argv[1]) < 0) {\n        return JS_EXCEPTION;\n    }\n\n    return JS_NewInt32(ctx, a + b);\n}\n\n/* Reverse a string */\nstatic JSValue\njs_reverse_string(JSContext *ctx, JSValueConst this_val, int argc,\n    JSValueConst *argv)\n{\n    char        *reversed;\n    size_t       i, len;\n    JSValue      result;\n    const char  *str;\n\n    if (argc < 1) {\n        return JS_ThrowTypeError(ctx, \"expected 1 argument\");\n    }\n\n    str = JS_ToCStringLen(ctx, &len, argv[0]);\n    if (!str) {\n        return JS_EXCEPTION;\n    }\n\n    reversed = js_malloc(ctx, len + 1);\n    if (!reversed) {\n        JS_FreeCString(ctx, str);\n        return JS_EXCEPTION;\n    }\n\n    for (i = 0; i < len; i++) {\n        reversed[i] = str[len - 1 - i];\n    }\n    reversed[len] = '\\0';\n\n    result = JS_NewString(ctx, reversed);\n\n    js_free(ctx, reversed);\n    JS_FreeCString(ctx, str);\n\n    return result;\n}\n\n/* Module function list */\nstatic const JSCFunctionListEntry js_module_funcs[] = {\n    JS_CFUNC_DEF(\"add\", 2, js_add),\n    JS_CFUNC_DEF(\"reverseString\", 1, js_reverse_string),\n};\n\n/* Module initialization */\nstatic int\njs_module_init(JSContext *ctx, JSModuleDef *m)\n{\n    return JS_SetModuleExportList(ctx, m, js_module_funcs,\n                                  countof(js_module_funcs));\n}\n\n/* Required entry point */\nJSModuleDef *\njs_init_module(JSContext *ctx, const char *module_name)\n{\n    JSModuleDef  *m;\n\n    m = JS_NewCModule(ctx, module_name, js_module_init);\n    if (!m) {\n        return NULL;\n    }\n\n    JS_AddModuleExportList(ctx, m, js_module_funcs,\n                           countof(js_module_funcs));\n\n    return m;\n}\n

\n

\nTo compile the native module:\n

\ngcc -fPIC -shared -I/path/to/quickjs -o mymodule.so mymodule.c\n

\nwhere /path/to/quickjs is the directory\ncontaining the QuickJS header files.\n

\n

\nFor proper memory tracking, always use QuickJS memory allocation functions\n(js_malloc, js_free)\ninstead of standard library functions\n(malloc, free).\n

\n

Additional resources

\nFor more information about the QuickJS C API:\n\n

\n

\n", "encoding": "utf-8"} +{"path": "en\\docs\\njs\\node_modules.html", "extension": ".html", "size_bytes": 17380, "content": "\nUsing node modules with njs
\n\nPlanning your ingress-nginx migration? Start here:\nkubernetes.nginx.org.\n\n

Using node modules with njs

Environment
Protobufjs
DNS-packet

\nOften, a developer wants to use 3rd-party code,\nusually available as a library of some kind.\nIn the JavaScript world, the concept of a module is relatively new,\nso there was no standard until recently.\nMany platforms (browsers) still don't support modules, which makes code\nreuse harder.\nThis article describes ways to reuse\nNode.js code in njs.\n

\nExamples in this article use features that appeared in\nnjs\n0.3.8\n

\nThere is a number of issues\nthat may arise when 3rd-party code is added to njs:\n\n

\n

\nThe good news is that such problems are not something new or specific to njs.\nJavaScript developers face them daily\nwhen trying to support multiple disparate platforms\nwith very different properties.\nThere are instruments designed to resolve the above-mentioned issues.\n\n

\n

\nIn this guide, we will use two relatively large npm-hosted libraries:\n\n

\n

Environment

\n

\nThis document mostly employs a generic approach\nand avoids specific best practice advices concerning Node.js\nand JavaScript.\nMake sure to consult the corresponding package's manual\nbefore following the steps suggested here.\n

\nFirst (assuming Node.js is installed and operational), let's create an\nempty project and install some dependencies;\nthe commands below assume we are in the working directory:\n

\n$ mkdir my_project && cd my_project\n$ npx license choose_your_license_here > LICENSE\n$ npx gitignore node\n\n$ cat > package.json <<EOF\n{\n  \"name\":        \"foobar\",\n  \"version\":     \"0.0.1\",\n  \"description\": \"\",\n  \"main\":        \"index.js\",\n  \"keywords\":    [],\n  \"author\":      \"somename <some.email@example.com> (https://example.com)\",\n  \"license\":     \"some_license_here\",\n  \"private\":     true,\n  \"scripts\": {\n    \"test\": \"echo \\\"Error: no test specified\\\" && exit 1\"\n  }\n}\nEOF\n$ npm init -y\n$ npm install browserify\n

\n

Protobufjs

\nThe library provides a parser\nfor the .proto interface definitions\nand a code generator for message parsing and generation.\n

\nIn this example, we will use the\nhelloworld.proto\nfile\nfrom the gRPC examples.\nOur goal is to create two messages:\nHelloRequest and\nHelloResponse.\nWe will use the\nstatic\nmode of protobufjs instead of dynamically generating classes, because\nnjs doesn't support adding new functions dynamically\ndue to security considerations.\n

\nNext, the library is installed and\nthe JavaScript code implementing message marshalling\nis generated from the protocol definition:\n

\n$ npm install protobufjs\n$ npx pbjs -t static-module helloworld.proto > static.js\n

\n

\nThus, the static.js file becomes our new dependency,\nstoring all the code we need to implement message processing.\nThe set_buffer() function contains code that uses the\nlibrary to create a buffer with the serialized\nHelloRequest message.\nThe code resides in the code.js file:\n

\nvar pb = require('./static.js');\n\n// Example usage of protobuf library: prepare a buffer to send\nfunction set_buffer(pb)\n{\n    // set fields of gRPC payload\n    var payload = { name: \"TestString\" };\n\n    // create an object\n    var message = pb.helloworld.HelloRequest.create(payload);\n\n    // serialize object to buffer\n    var buffer = pb.helloworld.HelloRequest.encode(message).finish();\n\n    var n = buffer.length;\n\n    var frame = new Uint8Array(5 + buffer.length);\n\n    frame[0] = 0;                        // 'compressed' flag\n    frame[1] = (n & 0xFF000000) >>> 24;  // length: uint32 in network byte order\n    frame[2] = (n & 0x00FF0000) >>> 16;\n    frame[3] = (n & 0x0000FF00) >>>  8;\n    frame[4] = (n & 0x000000FF) >>>  0;\n\n    frame.set(buffer, 5);\n\n    return frame;\n}\n\nvar frame = set_buffer(pb);\n

\n

\nTo ensure it works, we execute the code using node:\n

\n$ node ./code.js\nUint8Array [\n    0,   0,   0,   0,  12, 10,\n   10,  84, 101, 115, 116, 83,\n  116, 114, 105, 110, 103\n]\n

\nYou can see that this got us a properly encoded gRPC frame.\nNow let's run it with njs:\n

\n$ njs ./code.js\nThrown:\nError: Cannot find module \"./static.js\"\n    at require (native)\n    at main (native)\n

\n

\nModules are not supported, so we've received an exception.\nTo overcome this issue, let's use browserify\nor other similar tool.\n

\nAn attempt to process our existing code.js file will result\nin a bunch of JS code that is supposed to run in a browser,\ni.e. immediately upon loading.\nThis isn't something we actually want.\nInstead, we want to have an exported function that\ncan be referenced from the nginx configuration.\nThis requires some wrapper code.\n

\nIn this guide, we use\nnjs cli in all examples for the sake of simplicity.\nIn real life, you will be using nginx njs module to run your code.\n

\n

\nThe load.js file contains the library-loading code that\nstores its handle in the global namespace:\n

\nglobal.hello = require('./static.js');\n

\nThis code will be replaced with merged content.\nOur code will be using the \"global.hello\" handle to access\nthe library.\n

\nNext, we process it with browserify\nto get all dependencies into a single file:\n

\n$ npx browserify load.js -o bundle.js -d\n

\nThe result is a huge file that contains all our dependencies:\n

\n(function(){function......\n...\n...\n},{\"protobufjs/minimal\":9}]},{},[1])\n//# sourceMappingURL..............\n

\nTo get final \"njs_bundle.js\" file we concatenate\n\"bundle.js\" and the following code:\n

\n// Example usage of protobuf library: prepare a buffer to send\nfunction set_buffer(pb)\n{\n    // set fields of gRPC payload\n    var payload = { name: \"TestString\" };\n\n    // create an object\n    var message = pb.helloworld.HelloRequest.create(payload);\n\n    // serialize object to buffer\n    var buffer = pb.helloworld.HelloRequest.encode(message).finish();\n\n    var n = buffer.length;\n\n    var frame = new Uint8Array(5 + buffer.length);\n\n    frame[0] = 0;                        // 'compressed' flag\n    frame[1] = (n & 0xFF000000) >>> 24;  // length: uint32 in network byte order\n    frame[2] = (n & 0x00FF0000) >>> 16;\n    frame[3] = (n & 0x0000FF00) >>>  8;\n    frame[4] = (n & 0x000000FF) >>>  0;\n\n    frame.set(buffer, 5);\n\n    return frame;\n}\n\n// functions to be called from outside\nfunction setbuf()\n{\n    return set_buffer(global.hello);\n}\n\n// call the code\nvar frame = setbuf();\nconsole.log(frame);\n

\nLet's run the file using node to make sure things still work:\n

\n$ node ./njs_bundle.js\nUint8Array [\n    0,   0,   0,   0,  12, 10,\n   10,  84, 101, 115, 116, 83,\n  116, 114, 105, 110, 103\n]\n

\nNow let's proceed further with njs:\n

\n$ njs ./njs_bundle.js\nUint8Array [0,0,0,0,12,10,10,84,101,115,116,83,116,114,105,110,103]\n

\nThe last thing will be to use njs-specific API to convert\narray into byte string, so it could be usable by nginx module.\nWe can add the following snippet before the line\nreturn frame; }:\n

\nif (global.njs) {\n    return String.bytesFrom(frame)\n}\n

\nFinally, we got it working:\n

\n$ njs ./njs_bundle.js |hexdump -C\n00000000  00 00 00 00 0c 0a 0a 54  65 73 74 53 74 72 69 6e  |.......TestStrin|\n00000010  67 0a                                             |g.|\n00000012\n

\nThis is the intended result.\nResponse parsing can be implemented similarly:\n

\nfunction parse_msg(pb, msg)\n{\n    // convert byte string into integer array\n    var bytes = msg.split('').map(v=>v.charCodeAt(0));\n\n    if (bytes.length < 5) {\n        throw 'message too short';\n    }\n\n    // first 5 bytes is gRPC frame (compression + length)\n    var head = bytes.splice(0, 5);\n\n    // ensure we have proper message length\n    var len = (head[1] << 24)\n              + (head[2] << 16)\n              + (head[3] << 8)\n              + head[4];\n\n    if (len != bytes.length) {\n        throw 'header length mismatch';\n    }\n\n    // invoke protobufjs to decode message\n    var response = pb.helloworld.HelloReply.decode(bytes);\n\n    console.log('Reply is:' + response.message);\n}\n

\n

DNS-packet

\nThis example uses a library for generation and parsing of DNS packets.\nThis a case worth considering because the library and its dependencies\nuse modern language constructions not yet supported by njs.\nIn turn, this requires from us an extra step: transpiling the source code.\n

\nAdditional node packages are needed:\n

\n$ npm install @babel/core @babel/cli @babel/preset-env babel-loader\n$ npm install webpack webpack-cli\n$ npm install buffer\n$ npm install dns-packet\n

\nThe configuration file, webpack.config.js:\n

\nconst path = require('path');\n\nmodule.exports = {\n    entry: './load.js',\n    mode: 'production',\n    output: {\n        filename: 'wp_out.js',\n        path: path.resolve(__dirname, 'dist'),\n    },\n    optimization: {\n        minimize: false\n    },\n    node: {\n        global: true,\n    },\n    module : {\n        rules: [{\n            test: /\\.m?js$$/,\n            exclude: /(bower_components)/,\n            use: {\n                loader: 'babel-loader',\n                options: {\n                    presets: ['@babel/preset-env']\n                }\n            }\n        }]\n    }\n};\n

\nNote we are using \"production\" mode.\nIn this mode webpack does not use \"eval\" construction\nnot supported by njs.\nThe referenced load.js file is our entry point:\n

\nglobal.dns = require('dns-packet')\nglobal.Buffer = require('buffer/').Buffer\n

\nWe start the same way, by producing a single file for the libraries:\n

\n$ npx browserify load.js -o bundle.js -d\n

\nNext, we process the file with webpack, which itself invokes babel:\n

\n$ npx webpack --config webpack.config.js\n

\nThis command produces the dist/wp_out.js file, which is a\ntranspiled version of bundle.js.\nWe need to concatenate it with code.js\nthat stores our code:\n

\nfunction set_buffer(dnsPacket)\n{\n    // create DNS packet bytes\n    var buf = dnsPacket.encode({\n        type: 'query',\n        id: 1,\n        flags: dnsPacket.RECURSION_DESIRED,\n        questions: [{\n            type: 'A',\n            name: 'google.com'\n        }]\n    })\n\n    return buf;\n}\n

\nNote that in this example generated code is not wrapped into function and we\ndo not need to call it explicitly.\nThe result is in the \"dist\" directory:\n

\n$ cat dist/wp_out.js code.js > njs_dns_bundle.js\n

\nLet's call our code at the end of a file:\n

\nvar b = set_buffer(global.dns);\nconsole.log(b);\n

\nAnd execute it using node:\n

\n$ node ./njs_dns_bundle_final.js\nBuffer [Uint8Array] [\n    0,   1,   1, 0,  0,   1,   0,   0,\n    0,   0,   0, 0,  6, 103, 111, 111,\n  103, 108, 101, 3, 99, 111, 109,   0,\n    0,   1,   0, 1\n]\n

\nMake sure this works as expected, and then run it with njs:\n

\n$ njs ./njs_dns_bundle_final.js\nUint8Array [0,1,1,0,0,1,0,0,0,0,0,0,6,103,111,111,103,108,101,3,99,111,109,0,0,1,0,1]\n

\n\n

\nThe response can be parsed as follows:\n

\nfunction parse_response(buf)\n{\n    var bytes = buf.split('').map(v=>v.charCodeAt(0));\n\n    var b = global.Buffer.from(bytes);\n\n    var packet = dnsPacket.decode(b);\n\n    var resolved_name = packet.answers[0].name;\n\n    // expected name is 'google.com', according to our request above\n}\n

\n

\n", "encoding": "utf-8"} +{"path": "en\\docs\\njs\\preload_objects.html", "extension": ".html", "size_bytes": 3502, "content": "\nUnderstanding preloaded objects
\n\nPlanning your ingress-nginx migration? Start here:\nkubernetes.nginx.org.\n\n

Understanding preloaded objects

\nFor each incoming request njs creates a separate virtual machine.\nThis brings a lot of benefits such as predictable memory consumption\nor requests isolation.\nHowever, as all requests are isolated,\nif a request handler needs to access some data,\nit has to read it by itself.\nThis is not efficient especially when the amount of data is large.\n

\nTo address this limitation,\na preloaded shared object was introduced.\nSuch objects are created immutable and do not have prototype chains:\ntheir values cannot be changed, properties cannot be added or removed.\n

Working with preload objects

\nHere are some examples of how to work with a preload object in njs:\n\n

\n

\n", "encoding": "utf-8"} +{"path": "en\\docs\\njs\\reference.html", "extension": ".html", "size_bytes": 220741, "content": "\nReference
\n\nPlanning your ingress-nginx migration? Start here:\nkubernetes.nginx.org.\n\n

Reference

nginx objects
     HTTP Request
     Stream Session
     Periodic Session
     Headers
     Request
     Response
     ngx
     ngx.shared
built-in objects
     console
     crypto
     CryptoKey
     CryptoKeyPair
     njs
     process
     String
web API
     Text Decoder
     Text Encoder
timers
     Global functions
built-in modules
     Buffer
     Crypto
     File System
     Query String
     XML
     zlib

\nnjs provides objects, methods and properties\nfor extending nginx functionality.\n

\nThis reference contains only njs specific properties, methods and modules\nnot compliant with ECMAScript.\nDefinitions of njs properties and methods compliant with ECMAScript\ncan be found in\nECMAScript\nspecification.\nList of all njs properties and methods can be found in\nCompatibility.\n

nginx objects

HTTP Request

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
r.args{}
r.decline()
r.done()
r.error()
r.finish()
r.headersIn{}
r.headersOut{}
r.httpVersion
r.internal
r.internalRedirect()
r.jsVarNames()
r.log()
r.method
r.parent
r.readRequestArrayBuffer()
r.readRequestForm()
r.readRequestJSON()
r.readRequestText()
r.remoteAddress
r.requestBody
r.requestBuffer
r.requestText
r.rawHeadersIn[]
r.rawHeadersOut[]
r.responseBody
r.responseBuffer
r.responseText
r.return()
r.send()
r.sendBuffer()
r.sendHeader()
r.setReturnValue()
r.status
r.subrequest()
r.uri
r.rawVariables{}
r.variables{}
r.warn()
\n

\nThe HTTP request object is available only in the\nngx_http_js_module module.\nBefore 0.8.5,\nall string properties of the object\nwere byte strings.\n\n

\n\n
r.args{}
\n
\nrequest arguments object, read-only.\n

\nThe query string is returned as an object.\nSince 0.7.6,\nduplicate keys are returned as an array,\nkeys are case-sensitive, both keys and values are percent-decoded.\n

\n\n

\nFor example, the query string\n

\n'a=1&b=%32&A=3&b=4&B=two%20words'\n

\nis converted to r.args as:\n

\n{a: \"1\", b: [\"2\", \"4\"], A: \"3\", B: \"two words\"}\n

\nMore advanced parsing scenarios can be achieved with the\nQuery String module\nand with the\n$args\nvariable, for example:\n\n

\nimport qs from 'querystring';\n\nfunction args(r) {\n    return qs.parse(r.variables.args);\n}\n

\nThe argument object\nis evaluated at the first access to r.args.\nIf only a single argument is needed, for example foo,\nnginx variables can be used:\n

\nr.variables.arg_foo\n

\nHere, nginx variables object\nreturns the first value for a given key,\ncase-insensitive, without percent-decoding.\n

\n\n

\nTo convert r.args back to a string,\nthe Query String\nstringify\nmethod can be used.\n

\n
\n\n
r.decline()
\n
\nmakes the\njs_access handler\nexpress no opinion about access, deferring the decision to other access\ncheckers under\nsatisfy any\n(0.9.9).\nA handler that returns without calling\nr.decline()\nor\nr.return()\nimplicitly grants access.\nMay be called only from the\njs_access function.\n
\n\n
r.done()
\n
\nafter calling this function,\nnext data chunks will be passed to client without calling\njs_body_filter\n(0.5.2).\nMay be called only from the\njs_body_filter function\n
\n\n
r.error(string)
\n
\nwrites a string to the error log\non the error level of logging\n

\n

\nAs nginx has a\nhardcoded\nmaximum line length limit,\nonly first 2048 bytes of the string can be logged.\n

\n

\n
\n\n
r.finish()
\n
\nfinishes sending a response to the client\n
\n\n
r.headersIn{}
\n
\nincoming headers object, read-only.\n

\nThe Foo request header\ncan be accessed with the syntax:\nheadersIn.foo or headersIn['Foo'].\n

\n\n

\nThe\n“Authorization”,\n“Content-Length”,\n“Content-Range”,\n“Content-Type”,\n“ETag”,\n“Expect”,\n“From”,\n“Host”,\n“If-Match”,\n“If-Modified-Since”,\n“If-None-Match”,\n“If-Range”,\n“If-Unmodified-Since”,\n“Max-Forwards”,\n“Proxy-Authorization”,\n“Referer”,\n“Transfer-Encoding”, and\n“User-Agent”\nrequest headers can have only one field value\n(0.4.1).\nDuplicate field values in “Cookie” headers\nare separated by semicolon (;).\nDuplicate field values in all other request headers are separated by commas.\n

\n
\n\n
r.headersOut{}
\n
\noutgoing headers object for the main request, writable.\n\n

\nIf r.headersOut{} is the response object of\na subrequest, it represents response headers.\nIn this case, field values in\n“Accept-Ranges”,\n“Connection”,\n“Content-Disposition”,\n“Content-Encoding”,\n“Content-Length”,\n“Content-Range”,\n“Date”,\n“Keep-Alive”,\n“Server”,\n“Transfer-Encoding”,\n“X-Accel-*”\nresponse headers may be omitted.\n

\n\n

\nThe “Foo” response header\ncan be accessed with the syntax:\nheadersOut.foo or headersOut['Foo'].\n

\n\n

\nOutgoing headers should be set before a response header is sent to a client,\notherwise header update will be ignored.\nThis means that r.headersOut{} is effectively writable in:\n\n

\n

\n\n

\nField values of multi-value response headers\n(0.4.0)\ncan be set with the syntax:\n

\nr.headersOut['Foo'] = ['a', 'b']\n

\nwhere the output will be:\n

\nFoo: a\nFoo: b\n

\nAll previous field values of the “Foo” response header\nwill be deleted.\n

\n\n

\nFor standard response headers\nthat accept only a single field value such as\n“Content-Type”,\nonly the last element of the array will take effect.\nField values of the “Set-Cookie” response header\nare always returned as an array.\nDuplicate field values in\n“Age”,\n“Content-Encoding”,\n“Content-Length”,\n“Content-Type”,\n“ETag”,\n“Expires”,\n“Last-Modified”,\n“Location”,\n“Retry-After”\nresponse headers are ignored.\nDuplicate field values in all other response headers\nare separated by commas.\n

\n
\n\n
r.httpVersion
\n
\nHTTP version, read-only\n
\n\n
r.internal
\n
\nboolean value, true for\ninternal\nlocations\n
\n\n
r.internalRedirect(uri)
\n
\nperforms an\ninternal\nredirect\nto the specified uri.\nIf the uri starts with the “@” prefix,\nit is considered a named location.\nIn a new location, all request processing is repeated\nstarting from NGX_HTTP_SERVER_REWRITE_PHASE\nfor ordinary locations and from NGX_HTTP_REWRITE_PHASE\nfor named locations.\nAs a result, a redirect to a named location\ndoes not check client_max_body_size\nlimit.\nSee dev guide\nfor more details.\nRedirected requests become internal and can access the\ninternal\nlocations.\nThe actual redirect happens after the handler execution is completed.\n

\n

\nAfter redirect,\na new njs VM is started in the target location,\nthe VM in the original location is stopped.\nValues of nginx variables are kept\nand can be used to pass information to the target location.\nSince 0.5.3,\nthe variable declared with the js_var directive for\nhttp or\nstream\ncan be used.\n

\n

\n\n

\n

\nSince 0.7.4,\nthe method accepts escaped URIs.\n

\n

\n\n
\n\n
r.log(string)
\n
\nwrites a string to the error log\non the info level of logging\n

\n

\nAs nginx has a\nhardcoded\nmaximum line length limit,\nonly first 2048 bytes of the string can be logged.\n

\n

\n
\n\n
r.method
\n
\nHTTP method, read-only\n
\n\n
r.parent
\n
\nreferences the parent request object\n
\n\n
r.remoteAddress
\n
\nclient address, read-only\n
\n\n
r.readRequestArrayBuffer()
\n
\nreturns a Promise that resolves with the client\nrequest body as an ArrayBuffer\n(0.9.9).\nSee\nr.readRequestText()\nfor availability, body caching, and concurrency semantics.\n
\n\n
r.readRequestForm([options])
\n
\nreads the client request body and parses it as an HTML form,\nreturning a Promise that resolves with a form object\n(0.9.9).\nSupported content types are\napplication/x-www-form-urlencoded\nand multipart/form-data.\n\n

\nThe form object provides the following methods:\n

\n\n
get(name)
\n
\nreturns the first value for name,\nor null if absent.\n
\n\n
getAll(name)
\n
\nreturns an array with all values for name.\n
\n\n
has(name)
\n
\nreturns true if at least one entry exists\nfor name.\n
\n\n
forEach(callback[,\nthisArg])
\n
\ninvokes callback for each entry with arguments\n(value, key, form).\n
\n\n
hasFiles()
\n
\nreturns true if the form contains any file parts.\n
\n\n

\n

\n\n

\nFor text fields, values are decoded strings.\nFor file parts, the value is an object with the client-supplied\nfilename available as the name property;\nfile contents are not exposed.\nThe filename is client-supplied and is not sanitized.\n

\n\n

\nThe optional options object accepts the following\nproperties:\n

\n\n
maxKeys\nnumber
\n
\nthe maximum number of fields to parse,\nby default is 128.\nExceeding the limit rejects the returned promise.\n
\n\n

\n

\n\n

\nSee\nr.readRequestText()\nfor availability, body caching, and concurrency semantics.\nThe parsed form is itself cached on the request:\na subsequent call returns the same form object and ignores any\nnew options argument.\n

\n
\n\n
r.readRequestJSON()
\n
\nreturns a Promise that resolves with the client\nrequest body parsed as JSON\n(0.9.9).\nSee\nr.readRequestText()\nfor availability, body caching, and concurrency semantics.\n
\n\n
r.readRequestText()
\n
\nreturns a Promise that resolves with the client\nrequest body as a string\n(0.9.9).\nThe size of the request body is limited by\nclient_max_body_size.\nThe method is available in the\njs_access\nand\njs_content directives.\n\n

\nThe body is read once and cached on the request:\nsubsequent calls to\nr.readRequestText(),\nr.readRequestArrayBuffer(),\nr.readRequestJSON(),\nor\nr.readRequestForm()\nresolve from the cached body without re-reading the wire.\nA second call issued while a previous read is still pending throws\n\"request body is already being read\".\n

\n\n

\nNote that\nit may convert bytes invalid in UTF-8 encoding into the replacement\ncharacter.\n

\n
\n\n
r.requestBody
\n
\nthe property was made obsolete in\n0.5.0\nand was removed in 0.8.0.\nThe r.requestBuffer or\nr.requestText property\nshould be used instead.\n
\n\n
r.requestBuffer
\n
\nclient request body if it has not been written to a temporary file\n(since 0.5.0).\nTo ensure that the client request body is in memory,\nits size should be limited by\nclient_max_body_size,\nand a sufficient buffer size should be set using\nclient_body_buffer_size.\nThe property is available only in the\njs_content directive.\nFor asynchronous access, or for use in\njs_access, see\nr.readRequestText()\nand other “r.readRequest*()” methods.\n
\n\n
r.requestText
\n
\nthe same as r.requestBuffer,\nbut returns a string.\nNote that\nit may convert bytes invalid in UTF-8 encoding into the replacement character.\nFor asynchronous access, or for use in\njs_access, see\nr.readRequestText().\n
\n\n
r.rawHeadersIn[]
\n
\nreturns an array of key-value pairs\nexactly as they were received from the client\n(0.4.1).\n

\nFor example, with the following request headers:\n

\nHost: localhost\nFoo:  bar\nfoo:  bar2\n

\nthe output of r.rawHeadersIn will be:\n

\n[\n    ['Host', 'localhost'],\n    ['Foo', 'bar'],\n    ['foo', 'bar2']\n]\n

\nAll foo headers\ncan be collected with the syntax:\n

\nr.rawHeadersIn.filter(v=>v[0].toLowerCase() == 'foo').map(v=>v[1])\n

\nthe output will be:\n

\n['bar', 'bar2']\n

\nHeader field names are not converted to lower case,\nduplicate field values are not merged.\n

\n
\n\n
r.rawHeadersOut[]
\n
\nreturns an array of key-value pairs of response headers\n(0.4.1).\nHeader field names are not converted to lower case,\nduplicate field values are not merged.\n
\n\n
r.responseBody
\n
\nthe property was made obsolete in\n0.5.0\nand was removed in 0.8.0.\nThe r.responseBuffer\nor\nthe r.responseText\nproperty\nshould be used instead.\n
\n\n
r.responseBuffer
\n
\nholds the subrequest response body,\nread-only\n(since 0.5.0).\nThe size of r.responseBuffer is limited by the\nsubrequest_output_buffer_size\ndirective.\n
\n\n
r.responseText
\n
\nthe same as r.responseBuffer\nbut returns a string\n(since 0.5.0).\nNote that\nit may convert bytes invalid in UTF-8 encoding into the replacement character.\n
\n\n
r.return(status[,\nstring | Buffer])
\n
\nsends the entire response\nwith the specified status to the client.\nThe response can be a string or Buffer\n(0.5.0).\n

\nMay be called from the\njs_content\nor, since 0.9.9,\njs_access handler.\n

\n

\nIt is possible to specify either a redirect URL\n(for codes 301, 302, 303, 307, and 308)\nor the response body text (for other codes) as the second argument\n

\n
\n\n
r.send(string\n| Buffer)
\n
\nsends a part of the response body to the client.\nThe data sent can be a string or Buffer\n(0.5.0)\n
\n\n
r.sendBuffer(data[,\noptions])
\n
\nadds data to the chain of data chunks to be forwarded to the next body filter\n(0.5.2).\nThe actual forwarding happens later,\nwhen the all the data chunks of the current chain are processed.\n

\nThe data can be a string or Buffer.\nThe options is an object used\nto override nginx buffer flags derived from an incoming data chunk buffer.\nThe flags can be overridden with the following flags:\n

\n\n
last
\n
\nboolean,\ntrue if the buffer is the last buffer\n
\n\n
flush
\n
\nboolean,\ntrue if the buffer should have the flush flag\n
\n

\n

\nThe method may be called only from the\njs_body_filter function.\n
\n\n
r.sendHeader()
\n
\nsends the HTTP headers to the client\n
\n\n
r.setReturnValue(value)
\n
\nsets the return value of the\njs_set handler\n(0.7.0).\nUnlike an ordinary return statement,\nthis method should be used when the handler is JS async function.\nFor example:\n
\nasync function js_set(r) {\n    const digest = await crypto.subtle.digest('SHA-256', r.headersIn.host);\n    r.setReturnValue(digest);\n}\n
\n
\n\n
r.status
\n
\nstatus, writable\n
\n\n
r.subrequest(uri[,\noptions[, callback]])
\n
\ncreates a subrequest with the given uri and\noptions, and installs\nan optional completion callback.\n\n

\nA\nsubrequest\nshares its input headers with the client request.\nTo send headers different from original headers to a proxied server, the\nproxy_set_header\ndirective can be used.\nTo send a completely new set of headers to a proxied server, the\nproxy_pass_request_headers\ndirective can be used.\n

\n\n

\nIf options is a string, then it\nholds the subrequest arguments string.\nOtherwise, options is expected to be\nan object with the following keys:\n

\n
args
\n
\narguments string, by default an empty string is used\n
\n
body
\n
\nrequest body,\nby default the request body of the parent request object is used\n
\n\n
method
\n
\nHTTP method, by default the GET method is used\n
\n\n
detached
\n
\nboolean flag (0.3.9),\nif true, the created subrequest is a detached subrequest.\nResponses to detached subrequests are ignored.\nUnlike ordinary subrequests, a detached subrequest\ncan be created inside a variable handler.\nThe detached flag and callback argument\nare mutually exclusive.\n
\n\n

\n

\n\n

\nThe completion callback receives\na subrequest response object with methods and properties\nidentical to the parent request object.\n

\n\n

\nSince 0.3.8,\nif a callback is not provided,\nthe Promise object\nthat resolves to the subrequest response object\nis returned.\n

\n\n

\nFor example, to view all response headers in the subrequest:\n

\nasync function handler(r) {\n    const reply = await r.subrequest('/path');\n\n    for (const h in reply.headersOut) {\n        r.log(`${h}: ${reply.headersOut[h]}`);\n    }\n\n    r.return(200);\n}\n

\n

\n\n
\n\n
r.uri
\n
\ncurrent URI\nin request,\nnormalized,\nread-only\n
\n\n
r.rawVariables{}
\n
\nnginx variables as Buffers,\nwritable\n(since 0.5.0)\n
\n\n
r.jsVarNames([prefix])
\n
\nreturns a new array of names of nginx variables declared with\nthe js_var\ndirective\n(since 0.9.9).\nThe optional prefix argument must be a string.\nIf it is specified, only names that start with the prefix are returned.\n
\n\n
r.variables{}
\n
\nnginx variables object, writable\n(since 0.2.8).\n\n

\nFor example, to get the $foo variable,\none of the following syntax can be used:\n

\nr.variables['foo']\nr.variables.foo\n

\nSince 0.8.6,\nregular expression captures can be accessed using the following syntax:\n

\nr.variables['1']\nr.variables[1]\n

\n

\n\n

\nnginx treats variables referenced in nginx.conf\nand unreferenced variables differently.\nWhen a variable is referenced, it may be cacheable,\nbut when it is unreferenced it is always uncacheable.\nFor example, when the\n$request_id\nvariable is only accessed from njs,\nit has a new value every time it is evaluated.\nBut, when the\n$request_id\nis referenced, for example:\n

\nproxy_set_header X-Request-Id $request_id;\n

\nthe r.variables.request_id returns the same value every time.\n

\n\n

\nA variable is writable if:\n

    \n\n
  • \nit was created using the js_var directive for\nhttp or\nstream\n(since 0.5.3)\n
  • \n\n
  • \nit is referenced in nginx configuration file\n
  • \n\n

\nEven so, some embedded variables still cannot be assigned a value (for example,\n$http_).\n

\n
\n\n
r.warn(string)
\n
\nwrites a string to the error log\non the warning level of logging\n

\n

\nAs nginx has a\nhardcoded\nmaximum line length limit,\nonly first 2048 bytes of the string can be logged.\n

\n

\n
\n\n

\n

Stream Session

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
s.allow()
s.decline()
s.deny()
s.done()
s.error()
s.jsVarNames()
s.log()
s.off()
s.on()
s.remoteAddress
s.rawVariables{}
s.send()
s.sendDownstream()
s.sendUpstream()
s.status
s.setReturnValue()
s.variables{}
s.warn()
\n

\nThe stream session object is available only in the\nngx_stream_js_module\nmodule.\nBefore 0.8.5,\nall string properties of the object\nwere byte strings.\n

\n

\n\n
s.allow()
\n
\nan alias to\ns.done(0)\n(0.2.4)\n
\n\n
s.decline()
\n
\nan alias to\ns.done(-5)\n(0.2.4)\n
\n\n
s.deny()
\n
\nan alias to\ns.done(403)\n(0.2.4)\n
\n\n
s.done([code])
\n
\nsets an exit code for the current\nphase handler\nto a code value, by default 0.\nThe actual finalization happens when the js handler is completed\nand all pending events, for example, from\nngx.fetch() or\nsetTimeout(),\nare processed\n(0.2.4).\n

\nPossible code values:\n

    \n\n
  • \n0 — \nsuccessful finalization, passing control to the next phase\n
  • \n\n
  • \n-5 — \nundecided, passing control to the next handler of the current phase (if any)\n
  • \n\n
  • \n403 — \naccess is forbidden\n
  • \n\n

\n

\nMay be called only from a phase handler function:\njs_access\nor\njs_preread.\n
\n\n
s.error(string)
\n
\nwrites a sent string to the error log\non the error level of logging\n

\n

\nAs nginx has a\nhardcoded\nmaximum line length limit,\nonly first 2048 bytes of the string can be logged.\n

\n

\n
\n\n
s.log(string)
\n
\nwrites a sent string to the error log\non the info level of logging\n

\n

\nAs nginx has a\nhardcoded\nmaximum line length limit,\nonly first 2048 bytes of the string can be logged.\n

\n

\n
\n\n
s.off(eventName)
\n
\nunregisters the callback set by the s.on() method\n(0.2.4)\n
\n\n
s.on(event,\ncallback)
\n
\nregisters a callback\nfor the specified event\n(0.2.4).\n\n

\nAn event may be one of the following strings:\n

\n
upload
\n
\nnew data (string) from a client\n
\n\n
download
\n
\nnew data (string) to a client\n
\n\n
upstream
\n
\nnew data (Buffer) from a client\n(since 0.5.0)\n
\n\n
downstream
\n
\nnew data (Buffer) to a client\n(since 0.5.0)\n
\n\n

\n

\n\n

\nThe completion callback has the following prototype:\ncallback(data, flags), where\ndata is string or Buffer (depending on the event type)\nflags is an object\nwith the following properties:\n

\n
last
\n
\na boolean value, true if data is a last buffer.\n
\n\n

\n

\n
\n\n
s.remoteAddress
\n
\nclient address, read-only\n
\n\n
s.rawVariables
\n
\nnginx variables as Buffers,\nwritable\n(since 0.5.0)\n
\n\n
s.jsVarNames([prefix])
\n
\nreturns a new array of names of nginx variables declared with\nthe js_var\ndirective\n(since 0.9.9).\nThe optional prefix argument must be a string.\nIf it is specified, only names that start with the prefix are returned.\n
\n\n
s.send(data[,\noptions])
\n
\nadds data to the chain of data chunks that will be forwarded in\nthe forward direction:\nin download callback to a client; in upload to an upstream server\n(0.2.4).\nThe actual forwarding happens later,\nwhen the all the data chunks of the current chain are processed.\n

\nThe data can be a string or Buffer\n(0.5.0).\nThe options is an object used\nto override nginx buffer flags derived from an incoming data chunk buffer.\nThe flags can be overridden with the following flags:\n

\n\n
last
\n
\nboolean,\ntrue if the buffer is the last buffer\n
\n\n
flush
\n
\nboolean,\ntrue if the buffer should have the flush flag\n
\n

\n

\nThe method can be called multiple times per callback invocation.\n
\n\n
s.sendDownstream()
\n
\nis identical to s.send(),\nexcept for it always sends data to a client\n(since 0.7.8).\n
\n\n
s.sendUpstream()
\n
\nis identical to s.send(),\nexcept for it always sends data from a client\n(since 0.7.8).\n
\n\n
s.status
\n
\nsession status code, an alias to the\n$status\nvariable,\nread only\n(since 0.5.2)\n
\n\n
s.setReturnValue(value)
\n
\nsets the return value of the\njs_set handler\n(0.7.0).\nUnlike an ordinary return statement,\nthis method should be used when the handler is JS async function.\nFor example:\n
\nasync function js_set(r) {\n    const digest = await crypto.subtle.digest('SHA-256', r.headersIn.host);\n    r.setReturnValue(digest);\n}\n
\n
\n\n
s.variables{}
\n
\nnginx variables object, writable\n(since 0.2.8).\nA variable can be writable only\nif it is referenced in nginx configuration file.\nEven so, some embedded variables still cannot be assigned a value.\n
\n\n
s.warn(string)
\n
\nwrites a sent string to the error log\non the warning level of logging\n

\n

\nAs nginx has a\nhardcoded\nmaximum line length limit,\nonly first 2048 bytes of the string can be logged.\n

\n

\n
\n\n

\n

Periodic Session

\n\n\n\n
PeriodicSession.rawVariables{}
PeriodicSession.variables{}
\n

\nThe Periodic Session object is provided as the first argument\nfor the js_periodic handler for\nhttp\nand\nstream\n(since 0.8.1).\n

\n

\n\n
PeriodicSession.rawVariables{}
\n
\nnginx variables as Buffers,\nwritable.\n
\n\n
PeriodicSession.variables{}
\n
\nnginx variables object, writable.\n
\n\n

\n

Headers

\n\n\n\n\n\n\n\n\n\n
Headers()
Headers.append()
Headers.delete()
Headers.get()
Headers.getAll()
Headers.forEach()
Headers.has()
Headers.set()
\n

\nThe Headers interface of the\nFetch API\nis available since 0.5.1.\n

\nA new Headers object can be created using the\nHeaders() constructor:\n(since 0.7.10):\n\n

\n\n
Headers([init])
\n
\n\n
\n\n
init
\n
\nAn object containing HTTP headers for\nprepopulating the Headers object,\ncan be a string,\nan array of name-value pairs,\nor an existing Headers object.\n
\n\n
\n
\n\n

\n

\nA new Headers object can be created\nwith the following properties and methods:\n\n

\n\n
append()
\n
\nAppends a new value into an existing header in the\nHeaders object,\nor adds the header if it does not already exist\n(since 0.7.10).\n
\n\n
delete()
\n
\nDeletes a header from the Headers object\n(since 0.7.10).\n
\n\n
get()
\n
\nReturns a string containing the values of all headers with the specified name\nseparated by a comma and a space.\n
\n\n
getAll(name)
\n
\nReturns an array containing the values of all headers with the specified name.\n
\n\n
forEach()
\n
\nExecutes a provided function once for each key/value pair\nin the Headers object\n(since 0.7.10).\n
\n\n
has()
\n
\nReturns a boolean value\nindicating whether a header with the specified name exists.\n
\n\n
set()
\n
\nSets a new value for an existing header inside\nthe Headers object,\nor adds the header if it does not already exist\n(since 0.7.10).\n
\n\n

\n

Request

\n\n\n\n\n\n\n\n\n\n\n\n\n
Request()
Request.arrayBuffer()
Request.bodyUsed
Request.cache
Request.credentials
Request.headers
Request.json()
Request.method
Request.mode
Request.text()
Request.url
\n

\nThe Request interface of the\nFetch API\nis available since 0.7.10.\n

\nA new Request object can be created using the\nRequest() constructor:\n\n

\n\n
Request[resource[,\noptions]])
\n
\n\nCreates a Request object to fetch\nthat can be passed later to\nngx.fetch().\nThe resource can be a URL\nor an existing Request object.\nThe options is an optional argument\nthat is expected to be an object with the following keys:\n\n
\n\n
body
\n
\nThe request body, by default is empty.\n
\n\n
headers
\n
\nThe response headers object — \nthe object containing HTTP headers for\nprepopulating the Headers object,\ncan be a string,\nan array of name-value pairs,\nor an existing Headers object.\n
\n\n
method
\n
\nThe HTTP method, by default the GET method is used.\n
\n\n
\n
\n\n

\n

\nA new Request object can be created\nwith the following properties and methods:\n\n

\n\n
arrayBuffer()
\n
\nReturns a Promise that resolves with\nan ArrayBuffer.\n
\n\n
bodyUsed
\n
\nA boolean value, true\nif the body was used in the request.\n
\n\n
cache
\n
\nContains the cache mode of the request.\n
\n\n
credentials
\n
\nContains the credentials of the request,\nby default is same-origin.\n
\n\n
headers
\n
\nThe Headers read-only object\nassociated with the\nRequest.\n
\n\n
json()
\n
\nReturns a Promise that resolves with\nthe result of parsing the request body as JSON.\n
\n\n
method
\n
\nContains the request method.\n
\n\n
mode
\n
\nContains the mode of the request.\n
\n\n
text()
\n
\nReturns a Promise that resolves with a\nstring representation of the request body.\n
\n\n
url
\n
\nContains the URL of the request.\n
\n\n

\n

Response

\n\n\n\n\n\n\n\n\n\n\n\n\n\n
Response()
Response.arrayBuffer()
Response.bodyUsed
Response.headers
Response.json()
Response.ok
Response.redirected
Response.status
Response.statusText
Response.text()
Response.type
Response.url
\n

\nThe Response interface is available since\n0.5.1.\n

\nA new Response object can be created using the\nResponse() constructor\n(since 0.7.10):\n\n

\n\n
Response[body[,\noptions]])
\n
\nCreates a Response object.\nThe body is an optional argument,\ncan be a string or a buffer,\nby default is null.\nThe options is an optional argument\nthat is expected to be an object with the following keys:\n\n
\n\n
headers
\n
\nThe response headers object — \nthe object containing HTTP headers for\nprepopulating the Headers object,\ncan be a string,\nan array of name-value pairs,\nor an existing Headers object.\n
\n\n
status
\n
\nThe status code of the response.\n
\n\n
statusText
\n
\nThe status message corresponding to the status code.\n
\n\n
\n
\n\n

\n

\nA new Response() object can be created\nwith the following properties and methods:\n\n

\n\n
arrayBuffer()
\n
\nTakes a Response stream and reads it to completion.\nReturns a Promise that resolves with\nan ArrayBuffer.\n
\n\n
bodyUsed
\n
\nA boolean value, true\nif the body was read.\n
\n\n
headers
\n
\nThe Headers read-only object\nassociated with the\nResponse.\n
\n\n
json()
\n
\nTakes a Response stream and reads it to completion.\nReturns a Promise that resolves with\nthe result of parsing the body text as JSON.\n
\n\n
ok
\n
\nA boolean value, true\nif the response was successful (status codes between 200–299).\n
\n\n
redirected
\n
\nA boolean value, true\nif the response is the result of a redirect.\n
\n\n
status
\n
\nThe status code of the response.\n
\n\n
statusText
\n
\nThe status message corresponding to the status code.\n
\n\n
text()
\n
\nTakes a Response stream and reads it to completion.\nReturns a Promise that resolves with a string.\n
\n\n
type
\n
\nThe type of the response.\n
\n\n
url
\n
\nThe URL of the response.\n
\n\n

\n

ngx

\n\n\n\n\n\n\n\n\n\n\n\n
ngx.build
ngx.conf_file_path
ngx.conf_prefix
ngx.error_log_path
ngx.fetch()
ngx.log()
ngx.prefix
ngx.version
ngx.version_number
ngx.worker_id
\n

\nThe ngx global object is available\nsince 0.5.0.\n

\n\n
ngx.build
\n
\na string containing an optional nginx build name, corresponds to the\n--build=name\nargument\nof the configure script,\nby default is \"\"\n(0.8.0)\n
\n\n
ngx.conf_file_path
\n
\na string containing the file path to current nginx configuration file\n(0.8.0)\n
\n\n
ngx.conf_prefix
\n
\na string containing the file path to\nnginx configuration prefix — \nthe directory where nginx is currently looking for configuration\n(0.7.8)\n
\n\n
ngx.error_log_path
\n
\na string containing the file path to the current\nerror log file\n(0.8.0)\n
\n\n
ngx.fetch(resource,\n[options])
\n
\n

\nMakes a request to fetch a resource\n(0.5.1), which can be an\nURL or the Request object\n(0.7.10).\nReturns a Promise that resolves with\nthe Response object.\nSince 0.7.0,\nthe https:// scheme is supported,\nredirects are not handled.\n

\n\n

\nIf the URL in the resource is specified as a domain name,\nit is determined using a\nresolver.\nIf the https:// scheme is specified, the\njs_fetch_trusted_certificate\ndirective should be configured\nfor the authentication of the resource's HTTPS server.\n

\n\n

\nThe options parameter is expected to be an object\nwith the following keys:\n

\n\n
body
\n
\nrequest body,\nby default is empty\n
\n\n
buffer_size
\n
\nthe buffer size for reading the response,\nby default is 4096\n
\n\n
headers
\n
\nrequest headers object\n
\n\n
max_response_body_size
\n
\nthe maximum size of the response body in bytes,\nby default is 32768\n
\n\n
method
\n
\nHTTP method,\nby default the GET method is used\n
\n\n
verify
\n
\nenables or disables verification of the HTTPS server certificate,\nby default is true\n(0.7.0)\n
\n\n

\nExample:\n

\nlet reply = await ngx.fetch('http://nginx.org/');\nlet body = await reply.text();\n\nr.return(200, body);\n

\n

\n
\n\n
ngx.log(level,\nmessage)
\n
\nwrites a message to the error log with the specified level of logging.\nThe level parameter specifies one of the log levels,\nthe message parameter can be a string or Buffer.\nThe following log levels can be specified:\nngx.INFO,\nngx.WARN, and\nngx.ERR.\n

\n

\nAs nginx has a\nhardcoded\nmaximum line length limit,\nonly first 2048 bytes of the string can be logged.\n

\n

\n
\n\n
ngx.prefix
\n
\na string containing the file path to\nnginx prefix — \na directory that keeps server files\n(0.8.0)\n
\n\n
ngx.version
\n
\na string containing nginx version,\nfor example: 1.25.0\n(0.8.0)\n
\n\n
ngx.version_number
\n
\na number containing nginx version,\nfor example: 1025000\n(0.8.0)\n
\n\n
ngx.worker_id
\n
\na number that corresponds to nginx internal worker id,\nthe value is between 0 and the value specified in the\nworker_processes directive\n(0.8.0)\n
\n\n

\n

ngx.shared

\nThe ngx.shared global object is available\nsince 0.8.0.\n

SharedDict

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
ngx.shared.SharedDict.add()
ngx.shared.SharedDict.capacity
ngx.shared.SharedDict.clear()
ngx.shared.SharedDict.delete()
ngx.shared.SharedDict.freeSpace()
ngx.shared.SharedDict.get()
ngx.shared.SharedDict.has()
ngx.shared.SharedDict.incr()
ngx.shared.SharedDict.items()
ngx.shared.SharedDict.keys()
ngx.shared.SharedDict.name
ngx.shared.SharedDict.pop()
ngx.shared.SharedDict.replace()
ngx.shared.SharedDict.set()
ngx.shared.SharedDict.size()
ngx.shared.SharedDict.ttl()
ngx.shared.SharedDict.type
\n

\nThe shared dictionary object is available\nsince 0.8.0.\nThe shared dictionary name, type, and size\nare set with the js_shared_dict_zone directive in\nhttp\nor\nstream.\n

\nA SharedDict() object\nhas the following properties and methods:\n

\n\n
ngx.shared.SharedDict.add(key,\nvalue [,timeout])
\n
\nSets the value\nfor the specified key in the dictionary\nonly if the key does not exist yet.\nThe key is a string representing\nthe key of the item to add,\nthe value is the value of the item to add.\n

\nThe optional timeout argument is specified in milliseconds\nand overrides the timeout parameter of the\njs_shared_dict_zone directive in\nhttp\nor\nstream\n(since 0.8.5).\nIt can be useful when some keys are expected to have unique timeouts.\n

\n\n

\nReturns true if the value has been successfully added\nto the SharedDict dictionary,\nfalse if the key already exists in the dictionary.\nThrows SharedMemoryError if\nthere is not enough free space in the SharedDict dictionary.\nThrows TypeError if the value is\nof a different type than expected by this dictionary.\n

\n
\n\n
ngx.shared.SharedDict.capacity
\n
\nReturns the capacity of the SharedDict dictionary,\ncorresponds to the size parameter of\njs_shared_dict_zone directive in\nhttp\nor\nstream.\n
\n\n
ngx.shared.SharedDict.clear()
\n
\nRemoves all items from the SharedDict dictionary.\n
\n\n
ngx.shared.SharedDict.delete(key)
\n
\nRemoves the item associated with the specified key\nfrom the SharedDict dictionary,\ntrue if the item in the dictionary existed and was removed,\nfalse otherwise.\n
\n\n
ngx.shared.SharedDict.freeSpace()
\n
\nReturns the free page size in bytes.\nIf the size is zero, the SharedDict dictionary\nwill still accept new values if there is space in the occupied pages.\n
\n\n
ngx.shared.SharedDict.get(key)
\n
\nRetrieves the item by its key,\nreturns the value associated with the key\nor undefined if there is none.\n
\n\n
ngx.shared.SharedDict.has(key)
\n
\nSearches for an item by its key,\nreturns true if such item exists or\nfalse otherwise.\n
\n\n
ngx.shared.SharedDict.incr(key,delta[[,init], timeout]))
\n
\nIncrements the integer value associated with the key\nby delta.\nThe key is a string,\nthe delta is the number\nto increment or decrement the value by.\nIf the key does not exist,\nthe item will be initialized to an optional init argument,\nby default is 0.\n\n

\nThe optional timeout argument is specified in milliseconds\nand overrides the timeout parameter of the\njs_shared_dict_zone directive in\nhttp\nor\nstream\n(since 0.8.5).\nIf the timeout argument is not specified,\nthe existing per-entry TTL is preserved\n(since 0.9.7).\nBefore version 0.9.7,\nomitting timeout would reset the entry expiry\nto the directive default.\n

\n\n

\nReturns the new value.\nThrows SharedMemoryError if\nthere is not enough free space in the SharedDict dictionary.\nThrows TypeError if this dictionary does not expect numbers.\n

\n\n

\n

\nThis method can be used only if the dictionary type was declared with\ntype=number parameter of the\njs_shared_dict_zone directive in\nhttp\nor\nstream.\n

\n

\n
\n\n
ngx.shared.SharedDict.items([maxCount])
\n
\nReturns an array of the SharedDict dictionary\nkey-value items (since 0.8.1).\nThe maxCount parameter\nsets maximum number of items to retrieve,\nby default is 1024.\n\n
\n\n
ngx.shared.SharedDict.keys([maxCount])
\n
\nReturns an array of the SharedDict dictionary keys.\nThe maxCount parameter\nsets maximum number of keys to retrieve,\nby default is 1024.\n
\n\n
ngx.shared.SharedDict.name
\n
\nReturns the name of the SharedDict dictionary,\ncorresponds to the zone= parameter of\njs_shared_dict_zone directive in\nhttp\nor\nstream.\n
\n\n
ngx.shared.SharedDict.pop(key)
\n
\nRemoves the item associated with the specified key\nfrom the SharedDict dictionary,\nreturns the value associated with the key\nor undefined if there is none.\n
\n\n
ngx.shared.SharedDict.replace(key,\nvalue)
\n
\nReplaces the value\nfor the specified key only if the key already exists,\nreturns true if the value was successfully replaced,\nfalse if the key does not exist\nin the SharedDict dictionary.\nThrows SharedMemoryError if\nthere is not enough free space in the SharedDict dictionary.\nThrows TypeError if the value is\nof a different type than expected by this dictionary.\n
\n\n
ngx.shared.SharedDict.set(key,\nvalue [,timeout])
\n
\nSets the value for the specified key,\nreturns this SharedDict dictionary (for method chaining).\n\n

\nThe optional timeout argument is specified in milliseconds\nand overrides the timeout parameter of the\njs_shared_dict_zone directive in\nhttp\nor\nstream\n(since 0.8.5).\nIt can be useful when some keys are expected to have unique timeouts.\n

\n
\n\n
ngx.shared.SharedDict.size()
\n
\nReturns the number of items for the SharedDict dictionary.\n
\n\n
ngx.shared.SharedDict.ttl(key)
\n
\nReturns the remaining time-to-live in milliseconds\nfor the specified key,\nor undefined if the key does not exist\nor has expired\n(since 0.9.7).\n\n

\nThrows TypeError if the dictionary was declared\nwithout the timeout parameter of the\njs_shared_dict_zone directive in\nhttp\nor\nstream.\n

\n
\n\n
ngx.shared.SharedDict.type
\n
\nReturns string or number that\ncorresponds to the SharedDict dictionary type\nset by the type= parameter of\njs_shared_dict_zone directive in\nhttp\nor\nstream.\n
\n\n

\n

built-in objects

console

\n\n\n\n\n\n\n\n
console.error()
console.info()
console.log()
console.time()
console.timeEnd()
console.warn()
\n

\nThe console object is available\nin nginx since 0.8.2,\nin CLI since 0.2.6.\n

\n\n
console.error(msg[, msg2 ...])
\n
\nOutputs one or more error messages.\nThe message may be a string or an object.\n
\n\n
console.info(msg[, msg2 ...])
\n
\nOutputs one or more info messages.\nThe message may be a string or an object.\n
\n\n
console.log(msg[, msg2 ...])
\n
\nOutputs one or more log messages.\nThe message may be a string or an object.\n
\n\n
console.time(label)
\n
\nStarts a timer that can track how long an operation takes.\nThe label parameter allows naming different timers.\nIf console.timeEnd()\nwith the same name is called,\nthe time that elapsed since the timer was started will be output,\nin milliseconds.\n
\n\n
console.timeEnd(label)
\n
\nStops a timer previously started by\nconsole.time()\nThe label parameter allows naming different timers.\n
\n\n
console.warn(msg[, msg2 ...])
\n
\nOutputs one or more warning messages.\nThe message may be a string or an object.\n
\n\n

\n

crypto

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
сrypto.getRandomValues()
сrypto.randomUUID()
сrypto.subtle.encrypt()
сrypto.subtle.decrypt()
сrypto.subtle.deriveBits()
сrypto.subtle.deriveKey()
сrypto.subtle.digest()
сrypto.subtle.exportKey()
сrypto.subtle.generateKey()
сrypto.subtle.importKey()
сrypto.subtle.sign()
сrypto.subtle.verify()
сrypto.subtle.wrapKey()
сrypto.subtle.unwrapKey()
\n

\nThe crypto object is a global object\nthat allows using cryptographic functionality\n(since 0.7.0).\nSince 0.9.7,\nthe full\nWeb Crypto API\nspecification is supported.\n

\n

\n\n
сrypto.getRandomValues(typedArray)
\n
\nGets cryptographically strong random values.\nReturns the same array passed as typedArray\nbut with its contents replaced with the newly generated random numbers.\nPossible values:\n\n
\n
typedArray
\n
\ncan be\nInt8Array,\nInt16Array,\nUint16Array,\nInt32Array, or\nUint32Array\n
\n
\n\n
\n\n
сrypto.randomUUID()
\n
\nReturns a randomly generated, 36 character long v4 UUID string,\nfor example \"36b8f84d-df4e-4d49-b662-bcde71a8764f\"\n(since 0.9.7).\n
\n\n
сrypto.subtle.encrypt(algorithm,\nkey,\ndata)
\n
\nEncrypts data\nusing the provided\nalgorithm and\nkey.\nReturns a Promise that fulfills with\nan ArrayBuffer containing the ciphertext.\nPossible values:\n\n
\n
algorithm
\n
\nan object that specifies\nthe algorithm to be used and any extra parameters if required:\n\n
    \n
  • \nfor RSA-OAEP,\npass the object with the following keys:\n\n
      \n\n
    • \nname is a string,\nshould be set to RSA-OAEP:\n

      \n

      \ncrypto.subtle.encrypt({name: \"RSA-OAEP\"}, key, data)\n

      \n

      \n
    • \n
    \n\n
  • \n\n
  • \nfor AES-CTR,\npass the object with the following keys:\n\n
      \n\n
    • \nname is a string,\nshould be set to AES-CTR\n
    • \n\n
    • \ncounter is an\nArrayBuffer,\nTypedArray, or\nDataView —\nthe initial value of the counter block,\nmust be 16 bytes long (the AES block size).\nThe rightmost length bits of this block are used for the counter,\nand the rest is used for the nonce.\nFor example, if length is set to 64,\nthen the first half of counter is the nonce\nand the second half is used for the counter\n
    • \n\n
    • \nlength is the number of bits in the counter block\nthat are used for the actual counter.\nThe counter must be big enough that it doesn't wrap.\n
    • \n
    \n\n
  • \n\n
  • \nfor AES-CBC, pass the object with the following keys:\n\n
      \n\n
    • \nname is a string,\nshould be set to AES-CBC\n
    • \n\n
    • \niv or the initialization vector, is an\nArrayBuffer,\nTypedArray, or\nDataView,\nmust be 16 bytes, unpredictable,\nand preferably cryptographically random.\nHowever, it need not be secret,\nfor example, it may be transmitted unencrypted along with the ciphertext.\n
    • \n
    \n\n
  • \n\n
  • \nfor AES-GCM, pass the object with the following keys:\n\n
      \n\n
    • \nname is a string,\nshould be set to AES-GCM\n
    • \n\n
    • \niv or the initialization vector, is an\nArrayBuffer,\nTypedArray, or\nDataView,\nmust be 16 bytes,\nand must be unique for every encryption operation carried out with a given key\n
    • \n\n
    • \nadditionalData (optional) is an\nArrayBuffer,\nTypedArray, or\nDataView\nthat contains additional data that\nwill not be encrypted but will be authenticated along with the encrypted data.\nIf additionalData is specified,\nthen the same data must be specified in the corresponding call to\ndecrypt():\nif the data given to the decrypt() call\ndoes not match the original data,\nthe decryption will throw an exception.\nThe bit length of additionalData\nmust be smaller than 2^64 - 1.\n
    • \n\n
    • \ntagLength (optional, default is 128) -\na number that determines the size in bits\nof the authentication tag generated in the encryption operation\nand used for authentication in the corresponding decryption\nPossible values:\n32,\n64,\n96,\n104,\n112,\n120, or\n128.\nThe AES-GCM specification recommends that it should be\n96,\n104,\n112,\n120, or\n128,\nalthough\n32 or\n64\nbits may be acceptable in some applications.\n
    • \n
    \n\n
  • \n
\n\n
\n\n
key
\n
\na CryptoKey that contains\nthe key to be used for encryption\n
\n\n
data
\n
\nan\nArrayBuffer,\nTypedArray, or\nDataView\nthat contains\nthe data to be encrypted (also known as the plaintext)\n
\n
\n\n
\n\n
сrypto.subtle.decrypt(algorithm,\nkey,\ndata)
\n
\nDecrypts encrypted data.\nReturns a Promise with the decrypted data.\nPossible values:\n\n
\n\n
algorithm
\n
\nan object\nthat specifies the algorithm to be used, and any extra parameters as required.\nThe values given for the extra parameters must match\nthose passed into the corresponding encrypt() call.\n\n
    \n
  • \nfor RSA-OAEP,\npass the object with the following keys:\n\n
      \n\n
    • \nname is a string,\nshould be set to RSA-OAEP:\n

      \n

      \ncrypto.subtle.encrypt({name: \"RSA-OAEP\"}, key, data)\n

      \n

      \n
    • \n
    \n
  • \n\n
  • \nfor AES-CTR,\npass the object with the following keys:\n\n
      \n\n
    • \nname is a string,\nshould be set to AES-CTR\n
    • \n\n
    • \ncounter is an\nArrayBuffer,\nTypedArray, or\nDataView —\nthe initial value of the counter block,\nmust be 16 bytes long (the AES block size).\nThe rightmost length bits of this block are used for the counter,\nand the rest is used for the nonce.\nFor example, if length is set to 64,\nthen the first half of counter is the nonce\nand the second half is used for the counter.\n
    • \n\n
    • \nlength is the number of bits in the counter block\nthat are used for the actual counter.\nThe counter must be big enough that it doesn't wrap.\n
    • \n
    \n\n
  • \n\n
  • \nfor AES-CBC, pass the object with the following keys:\n\n
      \n\n
    • \nname is a string,\nshould be set to AES-CBC\n
    • \n\n
    • \niv or the initialization vector, is an\nArrayBuffer,\nTypedArray, or\nDataView,\nmust be 16 bytes, unpredictable,\nand preferably cryptographically random.\nHowever, it need not be secret\n(for example, it may be transmitted unencrypted along with the ciphertext).\n
    • \n
    \n\n
  • \n\n
  • \nfor AES-GCM, pass the object with the following keys:\n\n
      \n\n
    • \nname is a string,\nshould be set to AES-GCM\n
    • \n\n
    • \niv or the initialization vector, is an\nArrayBuffer,\nTypedArray, or\nDataView,\nmust be 16 bytes,\nand must be unique for every encryption operation carried out with a given key\n
    • \n\n
    • \nadditionalData (optional) is an\nArrayBuffer,\nTypedArray, or\nDataView\nthat contains additional data that\nwill not be encrypted but will be authenticated along with the encrypted data.\nIf additionalData is specified,\nthen the same data must be specified in the corresponding call to\ndecrypt():\nif the data given to the decrypt() call\ndoes not match the original data,\nthe decryption will throw an exception.\nThe bit length of additionalData\nmust be smaller than 2^64 - 1.\n
    • \n\n
    • \ntagLength (optional, default is 128) -\na number that determines the size in bits\nof the authentication tag generated in the encryption operation\nand used for authentication in the corresponding decryption.\nPossible values:\n32,\n64,\n96,\n104,\n112,\n120, or\n128.\nThe AES-GCM specification recommends that it should be\n96,\n104,\n112,\n120, or\n128,\nalthough\n32 or\n64\nbits may be acceptable in some applications.\n
    • \n
    \n\n
  • \n
\n\n
\n\n
key
\n
\na CryptoKey\nthat contains the key to be used for decryption.\nIf RSA-OAEP is used, this is the\nprivateKey property of the\nCryptoKeyPair object.\n
\n\n
data
\n
\nan\nArrayBuffer,\nTypedArray, or\nDataView\nthat contains the data to be decrypted (also known as ciphertext)\n
\n
\n\n
\n\n
сrypto.subtle.deriveBits(algorithm,\nbaseKey,\nlength)
\n
\nDerives an array of bits from a base key.\nReturns a Promise\nwhich will be fulfilled with an\nArrayBuffer that contains the derived bits.\nPossible values:\n\n
\n
algorithm
\n
\nis an object that defines the derivation algorithm to use:\n\n
    \n
  • \nfor HKDF,\npass the object with the following keys:\n\n
      \n\n
    • \nname is a string,\nshould be set to HKDF\n
    • \n\n
    • \nhash is a string with the digest algorithm to use:\nSHA-1,\nSHA-256,\nSHA-384, or\nSHA-512\n
    • \n\n
    • \nsalt is an\nArrayBuffer,\nTypedArray, or\nDataView\nthat represents random or pseudo-random value\nwith the same length as the output of the digest function.\nUnlike the input key material passed into deriveKey(),\nsalt does not need to be kept secret.\n
    • \n\n
    • \ninfo is an\nArrayBuffer,\nTypedArray, or\nDataView\nthat represents application-specific contextual information\nused to bind the derived key to an application or context,\nand enables deriving different keys for different contexts\nwhile using the same input key material.\nThis property is required but may be an empty buffer.\n
    • \n
    \n\n
  • \n\n
  • \nfor PBKDF2,\npass the object with the following keys:\n\n
      \n\n
    • \nname is a string,\nshould be set to PBKDF2\n
    • \n\n
    • \nhash is a string with the digest algorithm to use:\nSHA-1,\nSHA-256,\nSHA-384, or\nSHA-512\n
    • \n\n
    • \nsalt is an\nArrayBuffer,\nTypedArray, or\nDataView\nthat represents random or pseudo-random value\nof at least 16 bytes.\nUnlike the input key material passed into deriveKey(),\nsalt does not need to be kept secret.\n
    • \n\n
    • \niterations is a number\nthat represents the number of times the hash function will be executed\nin deriveKey()\n
    • \n
    \n\n
  • \n\n
  • \nfor ECDH,\npass the object with the following keys\n(since 0.9.1):\n\n
      \n\n
    • \nname is a string,\nshould be set to ECDH\n
    • \n\n
    • \npublic is a CryptoKey\nthat represents the public key of the other party.\nThe key must be generated using the same curve as the base key.\n
    • \n
    \n\n
  • \n\n
  • \nfor X25519,\npass the object with the following keys\n(since 0.9.7):\n\n
      \n\n
    • \nname is a string,\nshould be set to X25519\n
    • \n\n
    • \npublic is a CryptoKey\nthat represents the public key of the other party\n
    • \n
    \n\n
  • \n
\n\n
\n\n
baseKey
\n
\nis a CryptoKey\nthat represents the input to the derivation algorithm\n- the initial key material for the derivation function:\nfor example, for PBKDF2 it might be a password,\nimported as a CryptoKey using\nсrypto.subtle.importKey()\n
\n\n
length
\n
\nis a number representing the number of bits to derive.\nFor browsers compatibility,\nthe number should be a multiple of 8\n
\n
\n\n
\n\n
сrypto.subtle.deriveKey(algorithm,\nbaseKey,\nderivedKeyAlgorithm,\nextractable,\nkeyUsages)
\n
\nDerives a secret key from a master key.\nPossible values:\n\n
\n
algorithm
\n
\nis an object that defines the derivation algorithm to use:\n\n
    \n
  • \nfor HKDF,\npass the object with the following keys:\n\n
      \n\n
    • \nname is a string,\nshould be set to HKDF\n
    • \n\n
    • \nhash is a string with the digest algorithm to use:\nSHA-1,\nSHA-256,\nSHA-384, or\nSHA-512\n
    • \n\n
    • \nsalt is an\nArrayBuffer,\nTypedArray, or\nDataView\nthat represents random or pseudo-random value\nwith the same length as the output of the digest function.\nUnlike the input key material passed into deriveKey(),\nsalt does not need to be kept secret.\n
    • \n\n
    • \ninfo is an\nArrayBuffer,\nTypedArray, or\nDataView\nthat represents application-specific contextual information\nused to bind the derived key to an application or context,\nand enables deriving different keys for different contexts\nwhile using the same input key material.\nThis property is required but may be an empty buffer.\n
    • \n
    \n\n
  • \n\n
  • \nfor PBKDF2,\npass the object with the following keys:\n\n
      \n\n
    • \nname is a string,\nshould be set to PBKDF2\n
    • \n\n
    • \nhash is a string with the digest algorithm to use:\nSHA-1,\nSHA-256,\nSHA-384, or\nSHA-512\n
    • \n\n
    • \nsalt is an\nArrayBuffer,\nTypedArray, or\nDataView\nthat represents random or pseudo-random value\nof at least 16 bytes.\nUnlike the input key material passed into deriveKey(),\nsalt does not need to be kept secret.\n
    • \n\n
    • \niterations is a number\nthat represents the number of times the hash function will be executed\nin deriveKey()\n
    • \n
    \n\n
  • \n\n
  • \nfor ECDH,\npass the object with the following keys\n(since 0.9.1):\n\n
      \n\n
    • \nname is a string,\nshould be set to ECDH\n
    • \n\n
    • \npublic is a CryptoKey\nthat represents the public key of the other party.\nThe key must be generated using the same curve as the base key.\n
    • \n
    \n\n
  • \n\n
  • \nfor X25519,\npass the object with the following keys\n(since 0.9.7):\n\n
      \n\n
    • \nname is a string,\nshould be set to X25519\n
    • \n\n
    • \npublic is a CryptoKey\nthat represents the public key of the other party\n
    • \n
    \n\n
  • \n
\n\n
\n\n
baseKey
\n
\nis a CryptoKey\nthat represents the input to the derivation algorithm\n- the initial key material for the derivation function:\nfor example, for PBKDF2 it might be a password,\nimported as a CryptoKey using\nсrypto.subtle.importKey().\n
\n\n
derivedKeyAlgorithm
\n
\nis an object\nthat defines the algorithm the derived key will be used for:\n\n
    \n
  • \nfor HMAC,\npass the object with the following keys:\n\n
      \n\n
    • \nname is a string,\nshould be set to HMAC\n
    • \n\n
    • \nhash is a string with the name of the digest function to use:\nSHA-1,\nSHA-256,\nSHA-384, or\nSHA-512\n
    • \n\n
    • \nlength (optional) is a number\nthat represents the length in bits of the key.\nIf not specified, the length of the key is equal to\nthe block size of the chozen hash function\n
    • \n
    \n\n
  • \n\n
  • \nfor\nAES-CTR,\nAES-CBC,\nAES-GCM, or\nAES-KW\n(since 0.9.7),\npass the object with the following keys:\n\n
      \n\n
    • \nname is a string,\nshould be set to\nAES-CTR,\nAES-CBC,\nAES-GCM, or\nAES-KW,\ndepending on the algorithm used\n
    • \n\n
    • \nlength is a number that represents\nthe length in bits of the key to generate:\n128,\n192, or\n256\n
    • \n
    \n\n
  • \n
\n\n
\n\n
extractable
\n
\nis a boolean value\nthat indicates whether it will be possible to export the key\n
\n\n
keyUsages
\n
\nis an Array\nthat indicates what can be done with the derived key.\nThe key usages must be allowed by the algorithm\nset in derivedKeyAlgorithm.\nPossible values:\n
\n\n
encrypt
\n
\nkey for encrypting messages\n
\n\n
decrypt
\n
\nkey for decrypting messages\n
\n\n
sign
\n
\nkey for signing messages\n
\n\n
verify
\n
\nkey for verifying signatures\n
\n\n
deriveKey
\n
\nkey for deriving a new key\n
\n\n
deriveBits
\n
\nkey for deriving bits\n
\n\n
wrapKey
\n
\nkey for wrapping a key\n
\n\n
unwrapKey
\n
\nkey for unwrapping a key\n
\n
\n\n
\n
\n\n
\n\n
сrypto.subtle.digest(algorithm,\ndata)
\n
\nGenerates a digest of the given data.\nTakes as its arguments an identifier for the digest algorithm to use\nand the data to digest.\nReturns a Promise which will be fulfilled with the digest.\nPossible values:\n\n
\n
algorithm
\n
\nis a string that defines the hash function to use:\nSHA-1 (not for cryptographic applications),\nSHA-256,\nSHA-384, or\nSHA-512\n
\n\n
data
\n
\nis an\nArrayBuffer,\nTypedArray, or\nDataView\nthat contains the data to be digested\n
\n
\n\n
\n\n
сrypto.subtle.exportKey(format,\nkey)
\n
\nExports a key: takes a key as\na CryptoKey object\nand returns the key in an external, portable format\n(since 0.7.10).\nIf the format was jwk,\nthen the Promise fulfills with a JSON object\ncontaining the key.\nOtherwise, the promise fulfills with an\nArrayBuffer containing the key.\nPossible values:\n
\n\n
format
\n
\na string that describes the data format in which the key should be exported,\ncan be the following:\n
\n\n
raw
\n
\nthe raw data format\n
\n\n
pkcs8
\n
\nthe\nPKCS #8\nformat\n
\n\n
spki
\n
\nthe\nSubjectPublicKeyInfo\nformat\n
\n\n
jwk
\n
\nthe\nJSON Web Key\n(JWK) format (since 0.7.10)\n
\n\n
\n
\n\n
key
\n
\nthe CryptoKey\nthat contains the key to be exported\n
\n
\n\n
\n\n
сrypto.subtle.generateKey(algorithm,\nextractable,\nusage)
\n
\nGenerates a new key for symmetric algorithms\nor key pair for public-key algorithms\n(since 0.7.10).\nReturns a Promise that fulfills with the generated key\nas\na CryptoKey\nor CryptoKeyPair object.\nPossible values:\n
\n\n
algorithm
\n
\na dictionary object that defines the type of key to generate\nand provides extra algorithm-specific parameters:\n\n
    \n
  • \nfor\nRSASSA-PKCS1-v1_5,\nRSA-PSS, or\nRSA-OAEP,\npass the object with the following keys:\n\n
      \n
    • \nname is a string, should be set to\nRSASSA-PKCS1-v1_5,\nRSA-PSS, or\nRSA-OAEP,\ndepending on the used algorithm\n
    • \n\n
    • \nhash is a string that represents\nthe name of the digest function to use, can be\nSHA-256,\nSHA-384, or\nSHA-512\n
    • \n
    \n\n
  • \n\n
  • \nfor\nECDSA,\npass the object with the following keys:\n\n
      \n
    • \nname is a string, should be set to ECDSA\n
    • \n\n
    • \nnamedCurve is a string that represents\nthe name of the elliptic curve to use, may be\nP-256,\nP-384, or\nP-521\n
    • \n\n
    \n
  • \n\n
  • \nfor\nHMAC,\npass the object with the following keys:\n\n
      \n
    • \nname is a string, should be set to HMAC\n
    • \n\n\n
    • \nhash is a string that represents\nthe name of the digest function to use, can be\nSHA-256,\nSHA-384, or\nSHA-512\n
    • \n\n
    • \nlength (optional) is a number that represents\nthe length in bits of the key.\nIf omitted, the length of the key is equal to the length of the digest\ngenerated by the chosen digest function.\n
    • \n
    \n\n
  • \n\n
  • \nfor\nAES-CTR,\nAES-CBC,\nAES-GCM, or\nAES-KW\n(since 0.9.7),\npass the string identifying the algorithm or an object\nof the form { \"name\": \"ALGORITHM\" },\nwhere ALGORITHM is the name of the algorithm\n
  • \n\n
  • \nfor\nECDH,\npass the object with the following keys\n(since 0.9.1):\n\n
      \n
    • \nname is a string, should be set to ECDH\n
    • \n\n
    • \nnamedCurve is a string that represents\nthe name of the elliptic curve to use, may be\nP-256,\nP-384, or\nP-521\n
    • \n\n
    \n
  • \n\n
  • \nfor Ed25519,\npass the Ed25519 string\nor an object of the form { \"name\": \"Ed25519\" }\n(since 0.9.7)\n
  • \n\n
  • \nfor X25519,\npass the X25519 string\nor an object of the form { \"name\": \"X25519\" }\n(since 0.9.7)\n
  • \n\n
\n
\n\n
extractable
\n
\nboolean value that indicates if it is possible to export the key\n
\n\n
usage
\n
\nan array that indicates possible actions with the key:\n
\n\n
encrypt
\n
\nkey for encrypting messages\n
\n\n
decrypt
\n
\nkey for decrypting messages\n
\n\n
sign
\n
\nkey for signing messages\n
\n\n
verify
\n
\nkey for verifying signatures\n
\n\n
deriveKey
\n
\nkey for deriving a new key\n
\n\n
deriveBits
\n
\nkey for deriving bits\n
\n\n
wrapKey
\n
\nkey for wrapping a key\n
\n\n
unwrapKey
\n
\nkey for unwrapping a key\n
\n
\n\n
\n
\n\n
\n\n
сrypto.subtle.importKey(format,\nkeyData,\nalgorithm,\nextractable,\nkeyUsages)
\n
\nImports a key: takes as input a key in an external, portable format\nand gives a CryptoKey object.\nReturns a Promise that fulfills with the imported key\nas a CryptoKey object.\nPossible values:\n
\n\n
format
\n
\na string that describes the data format of the key to import,\ncan be the following:\n
\n\n
raw
\n
\nthe raw data format\n
\n\n
pkcs8
\n
\nthe\nPKCS #8\nformat\n
\n\n
spki
\n
\nthe\nSubjectPublicKeyInfo\nformat\n
\n\n
jwk
\n
\nthe\nJSON Web Key\n(JWK) format (since 0.7.10)\n
\n\n
\n\n
\n\n
keyData
\n
\nthe\nArrayBuffer,\nTypedArray, or\nDataView\nobject that contains the key in the given format\n
\n\n
algorithm
\n
\na dictionary object that defines the type of key to import\nand provides extra algorithm-specific parameters:\n\n
    \n
  • \nfor\nRSASSA-PKCS1-v1_5,\nRSA-PSS, or\nRSA-OAEP,\npass the object with the following keys:\n\n
      \n
    • \nname is a string, should be set to\nRSASSA-PKCS1-v1_5,\nRSA-PSS, or\nRSA-OAEP,\ndepending on the used algorithm\n
    • \n\n
    • \nhash is a string that represents\nthe name of the digest function to use, can be\nSHA-1,\nSHA-256,\nSHA-384, or\nSHA-512\n
    • \n
    \n\n
  • \n\n
  • \nfor\nECDSA,\npass the object with the following keys:\n\n
      \n
    • \nname is a string, should be set to ECDSA\n
    • \n\n
    • \nnamedCurve is a string that represents\nthe name of the elliptic curve to use, may be\nP-256,\nP-384, or\nP-521\n
    • \n\n
    \n
  • \n\n
  • \nfor\nHMAC,\npass the object with the following keys:\n\n
      \n
    • \nname is a string, should be set to HMAC\n
    • \n\n\n
    • \nhash is a string that represents\nthe name of the digest function to use, can be\nSHA-256,\nSHA-384, or\nSHA-512\n
    • \n\n
    • \nlength (optional) is a number that represents\nthe length in bits of the key.\nIf omitted, the length of the key is equal to the length of the digest\ngenerated by the chosen digest function.\n
    • \n
    \n\n
  • \n\n
  • \nfor\nAES-CTR,\nAES-CBC,\nAES-GCM, or\nAES-KW\n(since 0.9.7),\npass the string identifying the algorithm or an object\nof the form { \"name\": \"ALGORITHM\" },\nwhere ALGORITHM is the name of the algorithm\n
  • \n\n
  • \nfor\nPBKDF2,\npass the PBKDF2 string\n
  • \n\n
  • \nfor\nHKDF,\npass the HKDF string\n
  • \n\n
  • \nfor\nECDH,\npass the object with the following keys\n(since 0.9.1):\n\n
      \n
    • \nname is a string, should be set to ECDH\n
    • \n\n
    • \nnamedCurve is a string that represents\nthe name of the elliptic curve to use, may be\nP-256,\nP-384, or\nP-521\n
    • \n\n
    \n
  • \n\n
  • \nfor Ed25519,\npass the Ed25519 string\nor an object of the form { \"name\": \"Ed25519\" }\n(since 0.9.7)\n
  • \n\n
  • \nfor X25519,\npass the X25519 string\nor an object of the form { \"name\": \"X25519\" }\n(since 0.9.7)\n
  • \n\n
\n
\n\n
extractable
\n
\nboolean value that indicates if it is possible to export the key\n
\n\n
keyUsages
\n
\nan array that indicates possible actions with the key:\n
\n\n
encrypt
\n
\nkey for encrypting messages\n
\n\n
decrypt
\n
\nkey for decrypting messages\n
\n\n
sign
\n
\nkey for signing messages\n
\n\n
verify
\n
\nkey for verifying signatures\n
\n\n
deriveKey
\n
\nkey for deriving a new key\n
\n\n
deriveBits
\n
\nkey for deriving bits\n
\n\n
wrapKey
\n
\nkey for wrapping a key\n
\n\n
unwrapKey
\n
\nkey for unwrapping a key\n
\n
\n\n
\n
\n\n
\n\n
сrypto.subtle.sign(algorithm,\nkey,\ndata)
\n
\nReturns signature as a Promise\nthat fulfills with an ArrayBuffer containing the signature.\nPossible values:\n\n
\n
algorithm
\n
\nis a string or object that specifies the signature algorithm to use\nand its parameters:\n\n
    \n\n
  • \nfor RSASSA-PKCS1-v1_5,\npass the string identifying the algorithm or an object\nof the form { \"name\": \"ALGORITHM\" }\n
  • \n\n
  • \nfor RSA-PSS,\npass the object with the following keys:\n
      \n\n
    • \nname is a string, should be set to\nRSA-PSS\n
    • \n\n
    • \nsaltLength is a long integer\nthat represents the length of the random salt to use, in bytes\n
    • \n\n
    \n
  • \n\n
  • \nfor ECDSA,\npass the object with the following keys:\n
      \n\n
    • \nname is a string, should be set to\nECDSA\n
    • \n\n
    • \nhash is an identifier for the digest algorithm to use,\ncan be\nSHA-256,\nSHA-384, or\nSHA-512\n
    • \n\n
    \n
  • \n\n
  • \nfor HMAC,\npass the string identifying the algorithm or an object\nof the form { \"name\": \"ALGORITHM\" }\n
  • \n\n
  • \nfor Ed25519,\npass the Ed25519 string\nor an object of the form { \"name\": \"Ed25519\" }\n(since 0.9.7)\n
  • \n
\n\n
\n\n
key
\n
\nis a CryptoKey object\nthat the key to be used for signing.\nIf algorithm identifies a public-key cryptosystem, this is the private key.\n
\n\n
data
\n
\nis an\nArrayBuffer,\nTypedArray, or\nDataView\nobject that contains the data to be signed\n
\n
\n\n
\n\n\n
сrypto.subtle.verify(algorithm,\nkey,\nsignature,\ndata)
\n
\nVerifies a digital signature,\nreturns a Promise that fulfills with a boolean value:\ntrue if the signature is valid,\notherwise false.\nPossible values:\n\n
\n
algorithm
\n
\nis a string or object that specifies the algorithm to use\nand its parameters:\n\n
    \n\n
  • \nfor RSASSA-PKCS1-v1_5,\npass the string identifying the algorithm or an object\nof the form { \"name\": \"ALGORITHM\" }\n
  • \n\n
  • \nfor RSA-PSS,\npass the object with the following keys:\n
      \n\n
    • \nname is a string, should be set to\nRSA-PSS\n
    • \n\n
    • \nsaltLength is a long integer\nthat represents the length of the random salt to use, in bytes\n
    • \n\n
    \n
  • \n\n
  • \nfor ECDSA,\npass the object with the following keys:\n
      \n\n
    • \nname is a string, should be set to\nECDSA\n
    • \n\n
    • \nhash is an identifier for the digest algorithm to use,\ncan be\nSHA-256,\nSHA-384, or\nSHA-512\n
    • \n\n
    \n
  • \n\n
  • \nfor HMAC,\npass the string identifying the algorithm or an object\nof the form { \"name\": \"ALGORITHM\" }\n
  • \n\n
  • \nfor Ed25519,\npass the Ed25519 string\nor an object of the form { \"name\": \"Ed25519\" }\n(since 0.9.7)\n
  • \n
\n\n
\n\n
key
\n
\nis a CryptoKey object\nthat the key to be used for verifying.\nIt is the secret key for a symmetric algorithm\nand the public key for a public-key system.\n
\n\n
signature
\n
\nis an\nArrayBuffer,\nTypedArray, or\nDataView\nthat contains the signature to verify\n
\n\n
data
\n
\nis an\nArrayBuffer,\nTypedArray, or\nDataView\nobject that contains the data whose signature is to be verified\n
\n
\n\n
\n\n\n
сrypto.subtle.wrapKey(format,\nkey,\nwrappingKey,\nwrapAlgorithm)
\n
\nWraps a key: exports a key in an external, portable format,\nthen encrypts the exported key\n(since 0.9.7).\nReturns a Promise that fulfills with\nan ArrayBuffer containing the encrypted exported key.\nPossible values:\n\n
\n\n
format
\n
\na string that describes the data format of the key to export\nbefore it is encrypted,\ncan be the following:\n
\n\n
raw
\n
\nthe raw data format\n
\n\n
pkcs8
\n
\nthe\nPKCS #8\nformat\n
\n\n
spki
\n
\nthe\nSubjectPublicKeyInfo\nformat\n
\n\n
jwk
\n
\nthe\nJSON Web Key\n(JWK) format\n
\n\n
\n
\n\n
key
\n
\na CryptoKey\nthat contains the key to be wrapped.\nThe key must have\nCryptoKey.extractable\nset to true.\n
\n\n
wrappingKey
\n
\na CryptoKey\nthat contains the key used to encrypt the exported key.\nThe key must have the wrapKey usage set.\n
\n\n
wrapAlgorithm
\n
\nan object that specifies the algorithm to be used\nto encrypt the exported key, and any extra parameters as required:\n\n
    \n\n
  • \nfor AES-CBC,\nAES-CTR, or\nAES-GCM,\npass the corresponding algorithm parameters\nas described in\nсrypto.subtle.encrypt()\n
  • \n\n
  • \nfor AES-KW,\npass the AES-KW string\nor an object of the form { \"name\": \"AES-KW\" }\n
  • \n\n
  • \nfor RSA-OAEP,\npass the corresponding algorithm parameters\nas described in\nсrypto.subtle.encrypt()\n
  • \n\n
\n\n
\n
\n\n
\n\n\n
сrypto.subtle.unwrapKey(format,\nwrappedKey,\nunwrappingKey,\nunwrapAlgorithm,\nunwrappedKeyAlgorithm,\nextractable,\nkeyUsages)
\n
\nUnwraps a key: decrypts a wrapped key\nand creates a CryptoKey object\nfrom the result\n(since 0.9.7).\nReturns a Promise that fulfills with\nthe unwrapped key as a CryptoKey.\nPossible values:\n\n
\n\n
format
\n
\na string that describes the data format of the key\nthat was wrapped,\ncan be the following:\n
\n\n
raw
\n
\nthe raw data format\n
\n\n
pkcs8
\n
\nthe\nPKCS #8\nformat\n
\n\n
spki
\n
\nthe\nSubjectPublicKeyInfo\nformat\n
\n\n
jwk
\n
\nthe\nJSON Web Key\n(JWK) format\n
\n\n
\n
\n\n
wrappedKey
\n
\nan\nArrayBuffer,\nTypedArray, or\nDataView\nthat contains the wrapped key in the given format\n
\n\n
unwrappingKey
\n
\na CryptoKey\nthat contains the key used to decrypt the wrapped key.\nThe key must have the unwrapKey usage set.\n
\n\n
unwrapAlgorithm
\n
\nan object that specifies the algorithm to be used\nto decrypt the wrapped key, and any extra parameters as required:\n\n
    \n\n
  • \nfor AES-CBC,\nAES-CTR, or\nAES-GCM,\npass the corresponding algorithm parameters\nas described in\nсrypto.subtle.encrypt()\n
  • \n\n
  • \nfor AES-KW,\npass the AES-KW string\nor an object of the form { \"name\": \"AES-KW\" }\n
  • \n\n
  • \nfor RSA-OAEP,\npass the corresponding algorithm parameters\nas described in\nсrypto.subtle.encrypt()\n
  • \n\n
\n\n
\n\n
unwrappedKeyAlgorithm
\n
\na dictionary object that defines the type of key to unwrap\nand provides extra algorithm-specific parameters.\nThe same algorithm descriptions as in\nсrypto.subtle.importKey()\napply.\n
\n\n
extractable
\n
\nboolean value that indicates if it is possible to export the key\n
\n\n
keyUsages
\n
\nan array that indicates possible actions with the key:\n
\n\n
encrypt
\n
\nkey for encrypting messages\n
\n\n
decrypt
\n
\nkey for decrypting messages\n
\n\n
sign
\n
\nkey for signing messages\n
\n\n
verify
\n
\nkey for verifying signatures\n
\n\n
deriveKey
\n
\nkey for deriving a new key\n
\n\n
deriveBits
\n
\nkey for deriving bits\n
\n\n
wrapKey
\n
\nkey for wrapping a key\n
\n\n
unwrapKey
\n
\nkey for unwrapping a key\n
\n
\n\n
\n
\n\n
\n\n

\n

CryptoKey

\n\n\n\n\n\n
CryptoKey.algorithm
CryptoKey.extractable
CryptoKey.type
CryptoKey.usages
\n

\nThe CryptoKey object\nrepresents a cryptographic key obtained\nfrom one of the SubtleCrypto methods:\nсrypto.subtle.generateKey(),\nсrypto.subtle.deriveKey(),\nсrypto.subtle.importKey().\n

\n

\n\n
CryptoKey.algorithm
\n
\nreturns an object describing the algorithm for which this key can be used\nand any associated extra parameters\n(since 0.8.0),\nread-only\n
\n\n
CryptoKey.extractable
\n
\na boolean value, true if the key can be exported\n(since 0.8.0),\nread-only\n
\n\n
CryptoKey.type
\n
\na string value that indicates which kind of key is represented by the object,\nread-only.\nPossible values:\n
\n\n
secret
\n
\nThis key is a secret key for use with a symmetric algorithm.\n
\n\n
private
\n
\nThis key is the private half of an asymmetric algorithm's\nCryptoKeyPair\n
\n\n
public
\n
\nThis key is the public half of an asymmetric algorithm's\nCryptoKeyPair.\n
\n\n
\n
\n\n
CryptoKey.usages
\n
\nAn array of strings indicating what this key can be used for\n(since 0.8.0),\nread-only.\nPossible array values:\n
\n\n
encrypt
\n
\nkey for encrypting messages\n
\n\n
decrypt
\n
\nkey for decrypting messages\n
\n\n
sign
\n
\nkey for signing messages\n
\n\n
verify
\n
\nkey for verifying signatures\n
\n\n
deriveKey
\n
\nkey for deriving a new key\n
\n\n
deriveBits
\n
\nkey for deriving bits\n
\n\n
\n
\n\n

\n

CryptoKeyPair

\n\n\n\n
CryptoKeyPair.privateKey
CryptoKeyPair.publicKey
\n

\nThe CryptoKeyPair is a dictionary object\nof the WebCrypto API\nthat represents an asymmetric key pair.\n

\n

\n\n
CryptoKeyPair.privateKey
\n
\nA CryptoKey object\nrepresenting the private key.\n
\n\n
CryptoKeyPair.publicKey
\n
\nA CryptoKey object\nrepresenting the public key.\n
\n\n

\n

njs

\n\n\n\n\n\n\n
njs.version
njs.version_number
njs.dump()
njs.memoryStats
njs.on()
\n

\nThe njs object is a global object\nthat represents the current VM instance\n(since 0.2.0).\n

\n

\n\n
njs.version
\n
\nReturns a string with the current version of njs\n(for example, “0.7.4”).\n
\n\n
njs.version_number
\n
\nReturns a number with the current version of njs.\nFor example, “0.7.4” is returned as 0x000704\n(since 0.7.4).\n
\n\n
njs.dump(value)
\n
\nReturns the pretty-print string representation for a value.\n
\n\n
njs.memoryStats
\n
\nObject containing memory statistics for current VM instance\n(since 0.7.8).\n
\n\n
size
\n
\namount of memory in bytes njs memory pool claimed from the operating system.\n
\n\n
\n
\n\n
njs.on(event,\ncallback)
\n
\nRegisters a callback for the specified VM event\n(since 0.5.2).\nAn event may be one of the following strings:\n
\n\n
exit
\n
\nis called before the VM is destroyed.\nThe callback is called without arguments.\n
\n\n
\n
\n\n

\n

process

\n\n\n\n\n\n\n
process.argv
process.env
process.kill()
process.pid
process.ppid
\n

\nThe process object is a global object\nthat provides information about the current process\n(0.3.3).\n

\n

\n\n
process.argv
\n
\nReturns an array that contains the command line arguments\npassed when the current process was launched.\n
\n\n
process.env
\n
\nReturns an object containing the user environment.\n
\nBy default, nginx removes all environment variables inherited\nfrom its parent process except the TZ variable.\nUse the env directive\nto preserve some of the inherited variables.\n
\n
\n\n
process.kill(pid,\nnumber | string)
\n
\nSends the signal to the process identified by pid.\nSignal names are numbers or strings such as 'SIGINT' or 'SIGHUP'.\nSee kill(2)\nfor more information.\n
\n\n
process.pid
\n
\nReturns the PID of the current process.\n
\n\n
process.ppid
\n
\nReturns the PID of the current parent process.\n
\n\n

\n

String

\nBy default all strings in njs are Unicode strings.\nThey correspond to ECMAScript strings that contain Unicode characters.\nBefore 0.8.0,\nbyte strings were also supported.\n

Byte strings

\n

\nSince 0.8.0,\nthe support for byte strings and byte string methods were removed.\nWhen working with byte sequence,\nthe Buffer object\nand Buffer properties, such as\nr.requestBuffer,\nr.rawVariables,\nshould be used.\n

\n

\nByte strings contain a sequence of bytes\nand are used to serialize Unicode strings\nto external data and deserialize from external sources.\nFor example, the toUTF8() method serializes\na Unicode string to a byte string using UTF-8 encoding:\n

\n>> '£'.toUTF8().toString('hex')\n'c2a3'  /* C2 A3 is the UTF-8 representation of 00A3 ('£') code point */\n

\nThe toBytes() method serializes\na Unicode string with code points up to 255 into a byte string,\notherwise, null is returned:\n

\n>> '£'.toBytes().toString('hex')\n'a3'  /* a3 is a byte equal to 00A3 ('£') code point  */\n

\n\n

\n\n
String.bytesFrom(array\n| string, encoding)
\n
\nThe method was made obsolete in\n0.4.4\nand was removed in 0.8.0.\nThe Buffer.from method should be used instead:\n
\n>> Buffer.from([0x62, 0x75, 0x66, 0x66, 0x65, 0x72]).toString()\n'buffer'\n\n>> Buffer.from('YnVmZmVy', 'base64').toString()\n'buffer'\n
\nBefore 0.4.4,\ncreated a byte string either from an array that contained octets,\nor from an encoded string\n(0.2.3),\nthe encoding could be\nhex,\nbase64, and\nbase64url.\n
\n\n
String.prototype.fromBytes(start[,\nend])
\n
\nthe property was made obsolete in\n0.7.7\nand was removed in 0.8.0.\nBefore 0.7.7,\nreturned a new Unicode string from a byte string\nwhere each byte was replaced with a corresponding Unicode code point.\n
\n\n
String.prototype.fromUTF8(start[,\nend])
\n
\nthe property was made obsolete in\n0.7.7\nand was removed in 0.8.0.\nThe TextDecoder method\nshould be used instead.\nBefore 0.7.7,\nconverted a byte string containing a valid UTF-8 string\ninto a Unicode string,\notherwise null was returned.\n
\n\n
String.prototype.toBytes(start[,\nend])
\n
\nthe property was made obsolete in\n0.7.7\nand was removed in 0.8.0.\nBefore 0.7.7,\nserialized a Unicode string to a byte string,\nreturned null if a character larger than 255 was\nfound in the string.\n
\n\n
String.prototype.toString(encoding)
\n
\n

\nthe property was made obsolete in\n0.7.7\nand was removed in 0.8.0.\nBefore 0.7.7,\nencoded a string to\nhex,\nbase64, or\nbase64url:\n

\n>>  'αβγδ'.toString('base64url')\n'zrHOss6zzrQ'\n

\nBefore version 0.4.3,\nonly a byte string could be encoded:\n

\n>>  'αβγδ'.toUTF8().toString('base64url')\n'zrHOss6zzrQ'\n

\n

\n
\n\n
String.prototype.toUTF8(start[,\nend])
\n
\nthe property was made obsolete in\n0.7.7\nand was removed in 0.8.0.\nThe TextEncoder method\nshould be used instead.\nBefore 0.7.7,\nserialized a Unicode string\nto a byte string using UTF-8 encoding:\n
\n>> 'αβγδ'.toUTF8().length\n8\n>> 'αβγδ'.length\n4\n
\n
\n\n

\n

web API

Text Decoder

\n\n\n\n\n\n\n
TextDecoder()
TextDecoder.prototype.encoding
TextDecoder.prototype.fatal
TextDecoder.prototype.ignoreBOM
TextDecoder.prototype.decode()
\n

\nThe TextDecoder\nproduces a stream of code points\nfrom a stream of bytes\n(0.4.3).\n

\n

\n\n
TextDecoder([[encoding],\noptions])
\n
\nCreates a new TextDecoder object\nfor specified encoding,\ncurrently, only UTF-8 is supported.\nThe options is\nTextDecoderOptions dictionary with the property:\n\n
\n\n
fatal
\n
\nboolean flag indicating if\nTextDecoder.decode()\nmust throw the TypeError exception when\na coding error is found, by default is false.\n
\n\n
\n
\n\n
TextDecoder.prototype.encoding
\n
\nReturns a string with the name of the encoding used by\nTextDecoder(),\nread-only.\n
\n\n
TextDecoder.prototype.fatal
\n
\nboolean flag, true if\nthe error mode is fatal,\nread-only.\n
\n\n
TextDecoder.prototype.ignoreBOM
\n
\nboolean flag, true if\nthe byte order marker is ignored,\nread-only.\n
\n\n
TextDecoder.prototype.decode(buffer,\n[options])
\n
\nReturns a string with the text\ndecoded from the buffer by\nTextDecoder().\nThe buffer can be ArrayBuffer.\nThe options is\nTextDecodeOptions dictionary with the property:\n\n
\n\n
stream
\n
\nboolean flag indicating if\nadditional data will follow in subsequent calls to decode():\ntrue if processing the data in chunks, and\nfalse for the final chunk\nor if the data is not chunked.\nBy default is false.\n
\n\n
\n
\n>> (new TextDecoder()).decode(new Uint8Array([206,177,206,178]))\nαβ\n
\n
\n\n

\n

Text Encoder

\n\n\n\n\n
TextEncoder()
TextEncoder.prototype.encode()
TextEncoder.prototype.encodeInto()
\n

\nThe TextEncoder object\nproduces a byte stream with UTF-8 encoding\nfrom a stream of code points\n(0.4.3).\n

\n

\n\n
TextEncoder()
\n
\nReturns a newly constructed TextEncoder\nthat will generate a byte stream with UTF-8 encoding.\n
\n\n
TextEncoder.prototype.encode(string)
\n
\nEncodes string into a Uint8Array\nwith UTF-8 encoded text.\n
\n\n
TextEncoder.prototype.encodeInto(string,\nuint8Array)
\n
\nEncodes a string to UTF-8,\nputs the result into destination Uint8Array, and\nreturns a dictionary object that shows the progress of the encoding.\nThe dictionary object contains two members:\n\n
\n\n
read
\n
\nthe number of UTF-16 units of code from the source string\nconverted to UTF-8\n
\n\n
written
\n
\nthe number of bytes modified in the destination Uint8Array\n
\n\n
\n
\n\n

\n

timers

\n\n\n\n
clearTimeout()
setTimeout()
\n

\n

\n\n
clearTimeout(timeout)
\n
\nCancels a timeout object\ncreated by setTimeout().\n
\n\n
setTimeout(function,\nmilliseconds[,\nargument1,\nargumentN])
\n
\nCalls a function\nafter a specified number of milliseconds.\nOne or more optional arguments\ncan be passed to the specified function.\nReturns a timeout object.\n
\nfunction handler(v)\n{\n    // ...\n}\n\nt = setTimeout(handler, 12);\n\n// ...\n\nclearTimeout(t);\n
\n
\n\n

\n

Global functions

\n\n\n\n
atob()
btoa()
\n

\n

\n\n
atob(encodedData)
\n
\nDecodes a string of data which has been encoded\nusing Base64 encoding.\nThe encodedData parameter is a binary string\nthat contains Base64-encoded data.\nReturns a string that contains decoded data from encodedData.\n

\nThe similar btoa() method\ncan be used to encode and transmit data\nwhich may otherwise cause communication problems,\nthen transmit it and use the atob() method\nto decode the data again.\nFor example, you can encode, transmit, and decode control characters\nsuch as ASCII values 0 through 31.\n

\nconst encodedData = btoa(\"text to encode\"); // encode a string\nconst decodedData = atob(encodedData); // decode the string\n

\n

\n
\n\n
btoa(stringToEncode)
\n
\nCreates a Base64-encoded ASCII string from a binary string.\nThe stringToEncode parameter is a binary string to encode.\nReturns an ASCII string containing the Base64 representation of\nstringToEncode.\n

\nThe method can be used to encode data\nwhich may otherwise cause communication problems, transmit it,\nthen use the atob() method\nto decode the data again.\nFor example, you can encode control characters\nsuch as ASCII values 0 through 31.\n

\nconst encodedData = btoa(\"text to encode\"); // encode a string\nconst decodedData = atob(encodedData); // decode the string\n

\n

\n
\n\n

\n

built-in modules

Buffer

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
Buffer.alloc()
Buffer.allocUnsafe()
Buffer.byteLength()
Buffer.compare()
Buffer.concat()
Buffer.from(array)
Buffer.from(arrayBuffer)
Buffer.from(buffer)
Buffer.from(object)
Buffer.from(string)
Buffer.isBuffer()
Buffer.isEncoding()
buffer[]
buf.buffer
buf.byteOffset
buf.compare()
buf.copy()
buf.equals()
buf.fill()
buf.includes()
buf.indexOf()
buf.lastIndexOf()
buf.length
buf.readIntBE()
buf.readIntLE()
buf.readUIntBE()
buf.readUIntLE()
buf.readDoubleBE
buf.readDoubleLE()
buf.readFloatBE()
buf.readFloatLE()
buf.subarray()
buf.slice()
buf.swap16()
buf.swap32()
buf.swap64()
buf.toJSON()
buf.toString()
buf.write()
buf.writeIntBE()
buf.writeIntLE()
buf.writeUIntBE()
buf.writeUIntLE()
buf.writeDoubleBE()
buf.writeDoubleLE()
buf.writeFloatBE()
buf.writeFloatLE()
\n

\n

\n\n
Buffer.alloc(size[,\nfill[,\nencoding]]))
\n
\n

\nAllocates a new Buffer of a specified size.\nIf fill is not specified, the Buffer will be zero-filled.\nIf fill is specified,\nthe allocated Buffer will be initialized by calling\nbuf.fill(fill).\nIf fill and encoding are specified,\nthe allocated Buffer will be initialized by calling\nbuf.fill(fill,\nencoding).\n

\n\n

\nThe fill parameter may be a\nstring,\nBuffer,\nUint8Array, or\ninteger.\n

\n
\n\n
Buffer.allocUnsafe(size)
\n
\n

\nThe same as\nBuffer.alloc(),\nwith the difference that the memory allocated for the buffer is not initialized,\nthe contents of the new buffer is unknown and may contain sensitive data.\n

\n
\n\n
Buffer.byteLength(value[,\nencoding])
\n
\nReturns the byte length of a specified value,\nwhen encoded using encoding.\nThe value can be a\nstring,\nBuffer,\nTypedArray,\nDataView, or\nArrayBuffer.\nIf the value is a string,\nthe encoding parameter is its encoding, can be\nutf8,\nhex,\nbase64,\nbase64url;\nby default is utf8.\n
\n\n
Buffer.compare(buffer1,\nbuffer2)
\n
\nCompares buffer1 with buffer2\nwhen sorting arrays of Buffer instances.\nReturns\n0 if\nbuffer1 is the same as buffer2,\n1 if\nbuffer2 should come before buffer1 when sorted, or\n-1 if\nbuffer2 should come after buffer1 when sorted.\n
\n\n
Buffer.concat(list[,\ntotalLength])
\n
\nReturns a new Buffer\nwhich is the result of concatenating all the Buffer instances in the list.\nIf there are no items in the list or the total length is 0,\na new zero-length Buffer is returned.\nIf totalLength is not specified,\nit is calculated from the Buffer instances in list by adding their lengths.\nIf totalLength is specified,\nit is coerced to an unsigned integer.\nIf the combined length of the Buffers in list exceeds\ntotalLength,\nthe result is truncated to totalLength.\n
\n\n
Buffer.from(array)
\n
\nAllocates a new Buffer using an array of bytes\nin the range 0255.\nArray entries outside that range will be truncated.\n
\n\n
Buffer.from(arrayBuffer,\nbyteOffset[,\nlength]])
\n
\nCreates a view of the ArrayBuffer\nwithout copying the underlying memory.\nThe optional byteOffset and length arguments\nspecify a memory range within the arrayBuffer\nthat will be shared by the Buffer.\n
\n\n
Buffer.from(buffer)
\n
\nCopies the passed buffer data onto a new Buffer instance.\n
\n\n
Buffer.from(object[,\noffsetOrEncoding[,\nlength]])
\n
\nFor objects whose valueOf() function\nreturns a value not strictly equal to object,\nreturns\nBuffer.from(object.valueOf(),\noffsetOrEncoding,\nlength).\n
\n\n
Buffer.from(string[,\nencoding])
\n
\nCreates a new Buffer with a string.\nThe encoding parameter identifies the character encoding\nto be used when converting a string into bytes.\nThe encoding can be\nutf8,\nhex,\nbase64,\nbase64url;\nby default is utf8.\n
\n\n
Buffer.isBuffer(object)
\n
\nA boolean value,\nreturns true if object is a Buffer.\n
\n\n
Buffer.isEncoding(encoding)
\n
\nA boolean value,\nreturns true\nif encoding is the name of a supported character encoding.\n
\n\n
buffer[index]
\n
\nThe index operator that can be used to get and set the octet\nat position index in buffer.\nThe values refer to individual bytes,\nso the legal value range is between 0 and 255 (decimal).\n
\n\n
buf.buffer
\n
\nThe underlying ArrayBuffer object\nbased on which this Buffer object is created.\n
\n\n
buf.byteOffset
\n
\nAn integer,\nspecifying the byteOffset of the Buffers\nunderlying ArrayBuffer object.\n
\n\n
buf.compare(target[,\ntargetStart[,\ntargetEnd[,\nsourceStart[,\nsourceEnd]]]])
\n
\nCompares buffer with target and returns a number\nindicating whether buffer comes before, after, or is the same\nas target in sort order.\nComparison is based on the actual sequence of bytes in each Buffer.\nThe targetStart is an integer specifying\nthe offset within target at which to begin comparison,\nby default is 0.\nThe targetEnd is an integer specifying\nthe offset within target at which to end comparison,\nby default is target.length.\nThe sourceStart is an integer specifying\nthe offset within buffer at which to begin comparison,\nby default is 0.\nThe sourceEnd is an integer specifying\nthe offset within buffer at which to end comparison (not inclusive),\nby default is buf.length.\n
\n\n
buf.copy(target[,\ntargetStart[,\nsourceStart[,\nsourceEnd]]])
\n
\nCopies data from a region of buffer to a region in target,\neven if the target memory region overlaps with buffer.\nThe target parameter is a\nBuffer or Uint8Array to copy into.\n\n

\nThe targetStart is an integer specifying\nthe offset within target at which to begin writing,\nby default is 0.\nThe sourceStart is an integer specifying\nthe offset within buffer from which to begin copying,\nby default is 0.\nThe sourceEnd is an integer specifying\nthe offset within buffer at which to stop copying (not inclusive)\nby default is buf.length.\n

\n
\n\n
buf.equals(otherBuffer)
\n
\nA boolean value,\nreturns true if both Buffer and otherBuffer\nhave exactly the same bytes.\n
\n\n
buf.fill(value[,\noffset[,\nend]][,\nencoding])
\n
\nFills the Buffer with the specified value.\nIf the offset and end are not specified,\nthe entire Buffer will be filled.\nThe value is coerced to uint32 if it is not a\nstring,\nBuffer, or\ninteger.\nIf the resulting integer is greater than 255,\nthe Buffer will be filled with value and 255.\n
\n\n
buf.includes(value[,\nbyteOffset][,\nencoding])
\n
\nEquivalent to\nbuf.indexOf()\n!== -1,\nreturns true if the value was found\nin Buffer.\n
\n\n
buf.indexOf(value[,\nbyteOffset][,\nencoding])
\n
\nReturns an integer which is the index of the first occurrence of\nvalue in Buffer, or -1\nif Buffer does not contain value.\nThe value can be a\nstring with specified encoding\n(by default utf8),\nBuffer,\nUnit8Array,\nor a number between 0 and 255.\n
\n\n
buf.lastIndexOf(value[,\nbyteOffset][,\nencoding])
\n
\nThe same as\nbuf.indexOf(),\nexcept the last occurrence of the value is found\ninstead of the first occurrence.\nThe value can be a string, Buffer, or\ninteger between 1 and 255.\nIf the value is an empty string or empty Buffer,\nbyteOffset will be returned.\n
\n\n
buf.length
\n
\nReturns the number of bytes in Buffer.\n
\n\n
buf.readIntBE(offset,\nbyteLength)
\n
\nReads the byteLength from buf\nat the specified offset\nand interprets the result as a big-endian,\ntwo's complement signed value supporting up to 48 bits of accuracy.\nThe byteLength parameter is an integer between 1 and 6\nspecifying the number of bytes to read.\n

\nThe similar methods are also supported:\nbuf.readInt8([offset]),\nbuf.readInt16BE([offset]),\nbuf.readInt32BE([offset]).\n

\n
\n\n
buf.readIntLE(offset,\nbyteLength)
\n
\nReads the byteLength from buf\nat the specified offset\nand interprets the result as a little-endian,\ntwo's complement signed value supporting up to 48 bits of accuracy.\nThe byteLength parameter is an integer between 1 and 6\nspecifying the number of bytes to read.\n

\nThe similar methods are also supported:\nbuf.readInt8([offset]),\nbuf.readInt16LE([offset]),\nbuf.readInt32LE([offset]).\n

\n
\n\n
buf.readUIntBE(offset,\nbyteLength)
\n
\nReads the byteLength from buf\nat the specified offset\nand interprets the result as a big-endian\ninteger supporting up to 48 bits of accuracy.\nThe byteLength parameter is an integer between 1 and 6\nspecifying the number of bytes to read.\n

\nThe similar methods are also supported:\nbuf.readUInt8([offset]),\nbuf.readUInt16BE([offset]),\nbuf.readUInt32BE([offset]).\n

\n
\n\n
buf.readUIntLE(offset,\nbyteLength)
\n
\nReads the byteLength from buf\nat the specified offset\nand interprets the result as a little-endian\ninteger supporting up to 48 bits of accuracy.\nThe byteLength parameter is an integer between 1 and 6\nspecifying the number of bytes to read.\n

\nThe similar methods are also supported:\nbuf.readUInt8([offset]),\nbuf.readUInt16LE([offset]),\nbuf.readUInt32LE([offset]).\n

\n
\n\n
buf.readDoubleBE([offset])
\n
\nReads a 64-bit, big-endian double from buf\nat the specified offset.\n
\n\n
buf.readDoubleLE([offset])
\n
\nReads a 64-bit, little-endian double from buf\nat the specified offset.\n
\n\n
buf.readFloatBE([offset])
\n
\nReads a 32-bit, big-endian float from buf\nat the specified offset.\n
\n\n
buf.readFloatLE([offset])
\n
\nReads a 32-bit, little-endian float from buf\nat the specified offset.\n
\n\n
buf.subarray([start[,\nend]])
\n
\nReturns a new buf\nthat references the same memory as the original,\nbut offset and cropped by\nstart and end.\nIf end is greater than\nbuf.length,\nthe same result as that of end equal to\nbuf.length\nis returned.\n
\n\n
buf.slice([start[,\nend]])
\n
\nReturns a new buf\nthat references the same memory as the original,\nbut offset and cropped by the\nstart and end values.\nThe method is not compatible with the\nUint8Array.prototype.slice(),\nwhich is a superclass of Buffer.\nTo copy the slice, use\nUint8Array.prototype.slice().\n
\n\n
buf.swap16()
\n
\nInterprets buf as an array of unsigned 16-bit numbers\nand swaps the byte order in-place.\nThrows an error if\nbuf.length\nis not a multiple of 2.\n
\n\n
buf.swap32()
\n
\nInterprets buf as an array of unsigned 32-bit numbers\nand swaps the byte order in-place.\nThrows an error if\nbuf.length\nis not a multiple of 4.\n
\n\n
buf.swap64()
\n
\nInterprets buf as an array of 64-bit numbers\nand swaps byte order in-place.\nThrows an error if\nbuf.length\nis not a multiple of 8.\n
\n\n
buf.toJSON()
\n
\nReturns a JSON representation of buf.\nJSON.stringify()\nimplicitly calls this function when stringifying a Buffer instance.\n
\n\n
buf.toString([encoding[,\nstart[,\nend]]])
\n
\nDecodes buf to a string\naccording to the specified character encoding\nwhich can be utf8,\nhex,\nbase64,\nbase64url.\nThe start and end parameters\nmay be passed to decode only a subset of Buffer.\n
\n\n
buf.write(string[,\noffset[,\nlength]][,\nencoding])
\n
\nWrites a string to buf\nat offset\naccording to the character encoding.\nThe length parameter is the number of bytes to write.\nIf Buffer did not contain enough space to fit the entire string,\nonly part of string will be written,\nhowever, partially encoded characters will not be written.\nThe encoding can be\nutf8,\nhex,\nbase64,\nbase64url.\n
\n\n
buf.writeIntBE(value,\noffset,\nbyteLength)
\n
\nWrites byteLength bytes of value\nto buf\nat the specified offset as big-endian.\nSupports up to 48 bits of accuracy.\nThe byteLength parameter is an integer between 1 and 6\nspecifying the number of bytes to read.\n

\nThe following similar methods are also supported:\nbuf.writeInt8,\nbuf.writeInt16BE,\nbuf.writeInt32BE.\n

\n
\n\n
buf.writeIntLE(value,\noffset,\nbyteLength)
\n
\nWrites byteLength bytes of value\nto buf\nat the specified offset as little-endian.\nSupports up to 48 bits of accuracy.\nThe byteLength parameter is an integer between 1 and 6\nspecifying the number of bytes to read.\n

\nThe following similar methods are also supported:\nbuf.writeInt8,\nbuf.writeInt16LE,\nbuf.writeInt32LE.\n

\n
\n\n
buf.writeUIntBE(value,\noffset,\nbyteLength)
\n
\nWrites byteLength bytes of value\nto buf\nat the specified offset as big-endian.\nSupports up to 48 bits of accuracy.\nThe byteLength parameter is an integer between 1 and 6\nspecifying the number of bytes to read.\n

\nThe following similar methods are also supported:\nbuf.writeUInt8,\nbuf.writeUInt16BE,\nbuf.writeUInt32BE.\n

\n
\n\n
buf.writeUIntLE(value,\noffset,\nbyteLength)
\n
\nWrites byteLength bytes of value\nto buf\nat the specified offset as little-endian.\nSupports up to 48 bits of accuracy.\nThe byteLength parameter is an integer between 1 and 6\nspecifying the number of bytes to read.\n

\nThe following similar methods are also supported:\nbuf.writeUInt8,\nbuf.writeUInt16LE,\nbuf.writeUInt32LE.\n

\n
\n\n
buf.writeDoubleBE(value,\n[offset])
\n
\nWrites the value to buf\nat the specified offset as big-endian.\n
\n\n
buf.writeDoubleLE(value,\n[offset])
\n
\nWrites the value to buf\nat the specified offset as little-endian.\n
\n\n
buf.writeFloatBE(value,\n[offset])
\n
\nWrites the value to buf\nat the specified offset as big-endian.\n
\n\n
buf.writeFloatLE(value,\n[offset])
\n
\nWrites the value to buf\nat the specified offset as little-endian.\n
\n\n

\n

Crypto

\n\n\n\n
crypto.createHash()
crypto.createHmac()
\n

\n

\nSince 0.7.0,\nextended crypto API is available as a global\ncrypto object.\n

\nThe Crypto module provides cryptographic functionality support.\nThe Crypto module object is imported using import crypto from 'crypto'.\n

\nSince 0.9.7,\nthe Crypto module requires OpenSSL\nand uses OpenSSL EVP for hashing,\nmaking any digest algorithm supported by the linked OpenSSL library\navailable to JavaScript code.\n

\n

\n

\n\n
crypto.createHash(algorithm)
\n
\nCreates and returns a Hash object\nthat can be used to generate hash digests\nusing the given algorithm.\nThe algorithm can be\nmd5,\nsha1,\nsha256,\nsha384,\nsha512,\nand any other digest supported by the linked OpenSSL library\n(since 0.9.7).\nBefore version 0.9.7,\nonly md5, sha1,\nand sha256 were supported.\n
\n\n
crypto.createHmac(algorithm,\nsecret key)
\n
\nCreates and returns an HMAC object that uses\nthe given algorithm and secret key.\nThe algorithm can be\nmd5,\nsha1,\nsha256,\nsha384,\nsha512,\nand any other digest supported by the linked OpenSSL library\n(since 0.9.7).\nBefore version 0.9.7,\nonly md5, sha1,\nand sha256 were supported.\n
\n\n

\n

Hash

\n\n\n\n
hash.update()
hash.digest()
\n

\n

\n\n
hash.update(data)
\n
\nUpdates the hash content with the given data.\n
\n\n
hash.digest([encoding])
\n
\nCalculates the digest of all of the data passed using\nhash.update().\nThe encoding can be\nhex,\nbase64, and\nbase64url.\nIf encoding is not provided, a Buffer object\n(0.4.4) is returned.\n
\nBefore version (0.4.4),\na byte string was returned instead of a Buffer object.\n
\n
\n\n
hash.copy()
\n
\nMakes a copy of the current state of the hash\n(since 0.7.12).\n
\n\n

\n

\n

\nimport crypto from 'crypto';\n\ncrypto.createHash('sha1').update('A').update('B').digest('base64url');\n/* BtlFlCqiamG-GMPiK_GbvKjdK10 */\n

\n

HMAC

\n\n\n\n
hmac.update()
hmac.digest()
\n

\n

\n\n
hmac.update(data)
\n
\nUpdates the HMAC content with the given data.\n
\n\n
hmac.digest([encoding])
\n
\nCalculates the HMAC digest of all of the data passed using\nhmac.update().\nThe encoding can be\nhex,\nbase64, and\nbase64url.\nIf encoding is not provided, a Buffer object\n(0.4.4) is returned.\n
\nBefore version 0.4.4,\na byte string was returned instead of a Buffer object.\n
\n
\n

\n

\n

\nimport crypto from 'crypto';\n\ncrypto.createHmac('sha1', 'secret.key').update('AB').digest('base64url');\n/* Oglm93xn23_MkiaEq_e9u8zk374 */\n

\n

File System

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
fs.accessSync()
fs.appendFileSync()
fs.closeSync()
fs.existsSync()
fs.fstatSync()
fs.lstatSync()
fs.mkdirSync()
fs.openSync()
fs.promises.open()
fs.readdirSync()
fs.readFileSync()
fs.readlinkSync()
fs.readSync()
fs.realpathSync()
fs.renameSync()
fs.rmdirSync()
fs.statSync()
fs.symlinkSync()
fs.unlinkSync()
fs.writeFileSync()
fs.writeSync()
fs.writeSync()
\n

\n\n\n\n\n\n\n
fs.Dirent
fs.FileHandle
fs.Stats
File Access Constants
File System Flags
\n

\nThe File System module provides operations with files.\n

\nThe module object is imported using import fs from 'fs'.\nSince 0.3.9,\npromissified versions of file system methods are available through\nfs.promises object after importing with import fs from 'fs':\n

\nimport fs from 'fs';\n\nfs.promises.readFile(\"/file/path\").then((data) => {\n    /* <file data> */\n});\n

\n

\n\n
accessSync(path[,\nmode])
\n
\nSynchronously tests permissions for a file or directory\nspecified in the path\n(0.3.9).\nIf the check fails, an error will be returned,\notherwise, the method will return undefined.\n
\n\n
mode
\n
\nan optional integer\nthat specifies the accessibility checks to be performed,\nby default is fs.constants.F_OK\n
\ntry {\n    fs.accessSync('/file/path', fs.constants.R_OK | fs.constants.W_OK);\n    console.log('has access');\n} catch (e) {\n    console.log('no access');)\n}\n
\n
\n\n
\n
\n\n
appendFileSync(filename,\ndata[, options])
\n
\nSynchronously appends specified data\nto a file with provided filename.\nThe data is expected to be a string\nor a Buffer object (0.4.4).\nIf the file does not exist, it will be created.\nThe options parameter is expected to be\nan object with the following keys:\n
\n\n
mode
\n
\nmode option, by default is 0o666\n
\n\n
flag
\n
\nfile system flag,\nby default is a\n
\n\n
\n
\n\n
closeSync(fd)
\n
\nCloses the fd file descriptor represented by an integer\nused by the method.\nReturns undefined.\n
\n\n
existsSync(path)
\n
\nBoolean value, returns\ntrue if the specified path exists.\n(0.8.2)\n
\n\n
fstatSync(fd)
\n
\nRetrieves the fs.Stats object\nfor the file descriptor\n(0.7.7).\nThe fd parameter is an integer\nrepresenting the file descriptor used by the method.\n
\n\n
lstatSync(path[,\noptions])
\n
\nSynchronously retrieves\nthe fs.Stats object\nfor the symbolic link referred to by path\n(0.7.1).\nThe options parameter is expected to be\nan object with the following keys:\n
\n
throwIfNoEntry
\n
\na boolean value which indicates\nwhether an exception is thrown if no file system entry exists,\nrather than returning undefined,\nby default is false.\n
\n
\n
\n\n
mkdirSync(path[,\noptions])
\n
\nSynchronously creates a directory at the specified path\n(0.4.2).\nThe options parameter is expected to be an\ninteger that specifies\nthe mode,\nor an object with the following keys:\n
\n\n
mode
\n
\nmode option, by default is 0o777.\n
\n\n
\n
\n\n
openSync(path[,\nflags[, mode]])
\n
\nReturns an integer\nrepresenting the file descriptor for the opened file path\n(0.7.7).\n
\n\n
flags
\n
\nfile system flag,\nby default is r\n
\n\n
mode
\n
\nmode option, by default is 0o666\n
\n\n
\n
\n\n
promises.open(path[,\nflags[, mode]])
\n
\nReturns a FileHandle object\nrepresenting the opened file path\n(0.7.7).\n
\n\n
flags
\n
\nfile system flag,\nby default is r\n
\n\n
mode
\n
\nmode option, by default is 0o666\n
\n\n
\n
\n\n
readdirSync(path[,\noptions])
\n
\nSynchronously reads the contents of a directory\nat the specified path\n(0.4.2).\nThe options parameter is expected to be\na string that specifies encoding\nor an object with the following keys:\n
\n\n
encoding
\n
\nencoding, by default is utf8.\nThe encoding can be utf8 and buffer\n(0.4.4).\n
\n\n
withFileTypes
\n
\nif set to true, the files array will contain\nfs.Dirent objects,\nby default is false.\n
\n\n
\n
\n\n
readFileSync(filename[,\noptions])
\n
\nSynchronously returns the contents of the file\nwith provided filename.\nThe options parameter holds\nstring that specifies encoding.\nIf an encoding is specified, a string is returned,\notherwise, a Buffer object\n(0.4.4) is returned.\n
\nBefore version 0.4.4,\na byte string was returned\nif encoding was not specified.\n
\nOtherwise, options is expected to be\nan object with the following keys:\n
\n\n
encoding
\n
\nencoding, by default is not specified.\nThe encoding can be utf8,\nhex\n(0.4.4),\nbase64\n(0.4.4),\nbase64url\n(0.4.4).\n
\n\n
flag
\n
\nfile system flag,\nby default is r\n
\n\n
\n
\nimport fs from 'fs';\n\nvar file = fs.readFileSync('/file/path.tar.gz');\nconsole.log(file.slice(0,2).toString('hex')) /* '1f8b' */\n
\n
\n\n
readlinkSync(path[,\noptions])
\n
\nSynchronously gets the contents of the symbolic link path\nusing\nreadlink(2)\n(0.8.7).\nThe options argument can be a string specifying an encoding,\nor an object with encoding property\nspecifying the character encoding to use.\nIf the encoding is buffer,\nthe result is returned as a Buffer object,\notherwise as a string.\n
\n\n
readSync(fd,\nbuffer, offset[,\nlength[, position]])
\n
\nReads the content of a file path using file descriptor fd,\nreturns the number of bytes read\n(0.7.7).\n\n
\n\n
buffer
\n
\nthe buffer value can be a\nBuffer,\nTypedArray, or\nDataView\n
\n\n
offset
\n
\nis an integer representing\nthe position in buffer to write the data to\n
\n\n
length
\n
\nis an integer representing\nthe number of bytes to read\n
\n\n
position
\n
\nspecifies where to begin reading from in the file,\nthe value can be\ninteger or\nnull,\nby default is null.\nIf position is null,\ndata will be read from the current file position,\nand the file position will be updated.\nIf position is an integer,\nthe file position will be unchanged\n
\n
\n\n
\n\n
realpathSync(path[,\noptions])
\n
\nSynchronously computes the canonical pathname by resolving\n., .. and symbolic links using\nrealpath(3).\nThe options argument can be a string specifying an encoding,\nor an object with an encoding property specifying the character encoding\nto use for the path passed to the callback\n(0.3.9).\n
\n\n
renameSync(oldPath,\nnewPath)
\n
\nSynchronously changes the name or location of a file from\noldPath to newPath\n(0.3.4).\n
\nimport fs from 'fs';\n\nfs.renameSync('hello.txt', 'HelloWorld.txt');\n
\n
\n\n
rmdirSync(path)
\n
\nSynchronously removes a directory at the specified path\n(0.4.2).\n
\n\n
statSync(path,[\noptions])
\n
\nSynchronously retrieves\nthe fs.Stats object\nfor the specified path\n(0.7.1).\nThe path can be a\nstring or\nbuffer.\nThe options parameter is expected to be\nan object with the following keys:\n
\n
throwIfNoEntry
\n
\na boolean value which indicates whether\nan exception is thrown if no file system entry exists\nrather than returning undefined,\nby default is true.\n
\n
\n
\n\n
symlinkSync(target,\npath)
\n
\nSynchronously creates the link called path\npointing to target using\nsymlink(2)\n(0.3.9).\nRelative targets are relative to the link’s parent directory.\n
\n\n
unlinkSync(path)
\n
\nSynchronously unlinks a file by path\n(0.3.9).\n
\n\n
writeFileSync(filename,\ndata[,\noptions])
\n
\nSynchronously writes data to a file\nwith provided filename.\nThe data is expected to be a string\nor a Buffer object (0.4.4).\nIf the file does not exist, it will be created,\nif the file exists, it will be replaced.\nThe options parameter is expected to be\nan object with the following keys:\n
\n
mode
\n
\nmode option, by default is 0o666\n
\n\n
flag
\n
\nfile system flag,\nby default is w\n
\n\n
\n
\nimport fs from 'fs';\n\nfs.writeFileSync('hello.txt', 'Hello world');\n
\n
\n\n
writeSync(fd,\nbuffer, offset[,\nlength[, position]])
\n
\nWrites a buffer to a file using file descriptor,\nreturns the number of bytes written\n(0.7.7).\n\n
\n\n
fd
\n
\nan integer representing the file descriptor\n
\n\n
buffer
\n
\nthe buffer value can be a\nBuffer,\nTypedArray, or\nDataView\n
\n\n
offset
\n
\nis an integer that determines\nthe part of the buffer to be written,\nby default 0\n
\n\n
length
\n
\nis an integer specifying the number of bytes to write,\nby default is an offset of\nBuffer.byteLength\n
\n\n
position
\n
\nrefers to the offset from the beginning of the file\nwhere this data should be written,\ncan be an\ninteger or\nnull,\nby default is null.\nSee also\npwrite(2).\n
\n
\n\n
\n\n
writeSync(fd,\nstring[,\nposition[,\nencoding]])
\n
\nWrites a string to a file\nusing file descriptor fd,\nreturns the number of bytes written\n(0.7.7).\n\n
\n\n
fd
\n
\nis an integer representing a file descriptor\n
\n\n
position
\n
\nrefers to the offset from the beginning of the file\nwhere this data should be written,\ncan be an\ninteger or\nnull, by default is null.\nSee also\npwrite(2)\n
\n\n
encoding
\n
\nis a string,\nby default is utf8\n
\n
\n\n
\n\n

\n

fs.Dirent

\nfs.Dirent is a representation of a directory entry — \na file or a subdirectory.\nWhen\nreaddirSync()\nis called with the\nwithFileTypes\noption,\nthe resulting array contains fs.Dirent objects.\n\n

\n

fs.FileHandle

\n\n\n\n\n\n\n\n
filehandle.close()
filehandle.fd
filehandle.read()
filehandle.stat()
filehandle.write(buf)
filehandle.write(str)
\n

\nThe FileHandle object is an object wrapper\nfor a numeric file descriptor\n(0.7.7).\nInstances of the FileHandle object are created by the\nfs.promises.open() method.\nIf a FileHandle is not closed using the\nfilehandle.close() method,\nit will try to automatically close the file descriptor,\nhelping to prevent memory leaks.\nPlease do not rely on this behavior because it can be unreliable.\nInstead, always explicitly close a FileHandle.\n

\n

\n\n
filehandle.close()
\n
\nCloses the file handle after waiting for any pending operation on the handle\nto complete.\nReturns a promise, fulfills with undefined upon success.\n
\n\n
filehandle.fd
\n
\nThe numeric file descriptor\nmanaged by the FileHandle object.\n
\n\n
filehandle.read(buffer,\noffset[,\nlength[,\nposition]])
\n
\nReads data from the file and stores that in the given buffer.\n\n
\n\n
buffer
\n
\na buffer that will be filled with the file data read,\nthe value can be a\nBuffer,\nTypedArray, or\nDataView\n
\n\n
offset
\n
\nis an integer\nrepresenting the location in the buffer at which to start filling\n
\n\n
length
\n
\nis an integer\nrepresenting the number of bytes to read\n
\n\n
position
\n
\nthe location where to begin reading data from the file,\nthe value can be\ninteger,\nnull.\nIf null, data will be read from the current file position\nand the position will be updated.\nIf position is an integer,\nthe current file position will remain unchanged.\n
\n
\n\nReturns a Promise which fulfills upon success\nwith an object with two properties:\n
\n\n
bytesRead
\n
\nis an integer representing the number of bytes read\n
\n\n
buffer
\n
\nis a reference to the passed argument in buffer, can be\nBuffer,\nTypedArray, or\nDataView\n
\n
\n\n
\n\n
filehandle.stat()
\n
\nFulfills with an\nfs.Stats for the file,\nreturns a promise.\n
\n\n
filehandle.write(buffer,\noffset[,\nlength[,\nposition]])
\n
\nWrites a buffer to the file.\n\n
\n\n
buffer
\n
\nthe buffer value can be a\nBuffer,\nTypedArray, or\nDataView\n
\n\n
offset
\n
\nis an integer representing\nthe start position from within buffer where the data to write begins\n
\n\n
length
\n
\nis an integer representing\nthe number of bytes from buffer to write, by default\nis an offset of\nBuffer.byteLength\n
\n\n
position
\n
\nthe offset from the beginning of the file\nwhere the data from buffer should be written,\ncan be an\ninteger or\nnull,\nby default is null.\nIf position is not a number,\nthe data will be written at the current position.\nSee the POSIX\npwrite(2)\ndocumentation for details.\n
\n
\nReturns a Promise which is resolved with an object\ncontaining two properties:\n
\n\n
bytesWritten
\n
\nis an integer representing the number of bytes written\n
\n\n
buffer
\n
\na reference to the buffer written, can be a\nBuffer,\nTypedArray, or\nDataView\n
\n
\n

\n

\nIt is unsafe to use filehandle.write() multiple times\non the same file without waiting for the promise to be resolved or rejected.\n

\n

\n\n
\n\n
filehandle.write(string[,\nposition[,\nencoding]])
\n
\nWrites a string to the file.\n\n
\n\n
position
\n
\nthe offset from the beginning of the file\nwhere the data from buffer should be written,\ncan be an\ninteger or\nnull,\nby default is null.\nIf position is not a number,\nthe data will be written at the current position.\nSee the POSIX\npwrite(2)\ndocumentation for details.\n
\n\n
encoding
\n
\nthe expected encoding of the string, by default utf8\n
\n\n
\nReturns a Promise which is resolved with an object\ncontaining two properties:\n
\n\n
bytesWritten
\n
\nis an integer representing the number of bytes written\n
\n\n
buffer
\n
\na reference to the buffer written, can be a\nBuffer,\nTypedArray, or\nDataView\n
\n
\n

\n

\nIt is unsafe to use filehandle.write() multiple times\non the same file without waiting for the promise to be resolved or rejected.\n

\n

\n\n
\n\n

\n

fs.Stats

\nThe fs.Stats object provides information about a file.\nThe object is returned from\nfs.statSync() and\nfs.lstatSync().\n\n

\n

File Access Constants

\nThe access() method\ncan accept the following flags.\nThese flags are exported by fs.constants:\n\n

\n

File System Flags

\nThe flag option can accept the following values:\n\n

\n

Query String

\n\n\n\n\n\n\n\n
querystring.decode()
querystring.encode()
querystring.escape()
querystring.parse()
querystring.stringify()
querystring.unescape()
\n

\nThe Query String module provides support\nfor parsing and formatting URL query strings\n(0.4.3).\nThe Query String module object is imported using\nimport qs from 'querystring'.\n

\n

\n\n
querystring.decode()
\n
\nis an alias for\nquerystring.parse().\n
\n\n
querystring.encode()
\n
\nis an alias for\nquerystring.stringify().\n
\n\n
querystring.escape(string)
\n
\n

\nPerforms URL encoding of the given string,\nreturns an escaped query string.\nThe method is used by\nquerystring.stringify()\nand should not be used directly.\n

\n
\n\n
querystring.parse(string[,\nseparator[,\nequal[,\noptions]]])
\n
\n

\nParses the query string URL and returns an object.\n

\n\n

\nThe separator parameter is a substring\nfor delimiting key and value pairs in the query string,\nby default is “&”.\n

\n\n

\nThe equal parameter is a substring\nfor delimiting keys and values in the query string,\nby default is “=”.\n

\n\n

\nThe options parameter is expected to be\nan object with the following keys:\n

\n
decodeURIComponent\nfunction
\n
\nFunction used\nto decode percent-encoded characters in the query string,\nby default is\nquerystring.unescape()\n
\n\n
maxKeys\nnumber
\n
\nthe maximum number of keys to parse,\nby default is 1000.\nThe 0 value removes limitations for counting keys.\n
\n\n

\nBy default, percent-encoded characters within the query string are assumed\nto use the UTF-8 encoding,\ninvalid UTF-8 sequences will be replaced with\nthe U+FFFD replacement character.\n

\n\n

\nFor example, for the following query string\n

\n'foo=bar&abc=xyz&abc=123'\n

\nthe output will be:\n

\n{\n  foo: 'bar',\n  abc: ['xyz', '123']\n}\n

\n

\n\n
\n\n
querystring.stringify(object[,\nseparator[,\nequal[,\noptions]]])
\n
\n

\nSerializes an object and returns a URL query string.\n

\n\n

\nThe separator parameter is a substring\nfor delimiting key and value pairs in the query string,\nby default is “&”.\n

\n\n

\nThe equal parameter is a substring\nfor delimiting keys and values in the query string,\nby default is “=”.\n

\n\n

\nThe options parameter is expected to be\nan object with the following keys:\n

\n
encodeURIComponent\nfunction
\n
\nThe function to use when converting\nURL-unsafe characters to percent-encoding in the query string,\nby default is\nquerystring.escape().\n
\n\n

\n

\n\n

\nBy default, characters that require percent-encoding within the query string\nare encoded as UTF-8.\nIf other encoding is required, then\nencodeURIComponent option should be specified.\n

\n\n

\nFor example, for the following command\n

\nquerystring.stringify({ foo: 'bar', baz: ['qux', 'quux'], 123: '' });\n

\nthe query string will be:\n

\n'foo=bar&baz=qux&baz=quux&123='\n

\n

\n\n
\n\n
querystring.unescape(string)
\n
\n

\nPerforms decoding of URL percent-encoded characters\nof the string,\nreturns an unescaped query string.\nThe method is used by\nquerystring.parse()\nand should not be used directly.\n

\n
\n\n

\n

XML

\n\n\n\n\n\n\n\n\n\n
xml.parse()
xml.c14n()
xml.exclusiveC14n()
xml.serialize()
xml.serializeToString()
XMLDoc
XMLNode
XMLAttr
\n

\nThe XML module allows working with XML documents\n(since 0.7.10).\nThe XML module object is imported using\nimport xml from 'xml'.\n

\nExample:\n

\nimport xml from 'xml';\n\nlet data = `<note><to b=\"bar\" a= \"foo\" >Tove</to><from>Jani</from></note>`;\nlet doc = xml.parse(data);\n\nconsole.log(doc.note.to.$text) /* 'Tove' */\nconsole.log(doc.note.to.$attr$b) /* 'bar' */\nconsole.log(doc.note.$tags[1].$text) /* 'Jani' */\n\nlet dec = new TextDecoder();\nlet c14n = dec.decode(xml.exclusiveC14n(doc.note));\nconsole.log(c14n) /* '<note><to a=\"foo\" b=\"bar\">Tove</to><from>Jani</from></note>' */\n\nc14n = dec.decode(xml.exclusiveC14n(doc.note.to));\nconsole.log(c14n) /* '<to a=\"foo\" b=\"bar\">Tove</to>' */\n\nc14n = dec.decode(xml.exclusiveC14n(doc.note, doc.note.to /* excluding 'to' */));\nconsole.log(c14n) /* '<note><from>Jani</from></note>' */\n

\n

\n

\n\n
parse(string |\nBuffer)
\n
\nParses a string or Buffer for an XML document,\nreturns an\nXMLDoc wrapper object\nrepresenting the parsed XML document.\n
\n\n
c14n(root_node[,\nexcluding_node])
\n
\nCanonicalizes root_node and its children according to\nCanonical XML Version 1.1.\nThe root_node can be\nXMLNode or\nXMLDoc wrapper object\naround XML structure.\nReturns Buffer object that contains canonicalized output.\n\n

\n

\n\n
excluding_node
\n
\nallows omitting from the output a part of the document\n
\n\n

\n

\n\n
\n\n
exclusiveC14n(root_node[,\nexcluding_node[,\nwithComments\n[,prefix_list]]])
\n
\nCanonicalizes root_node and its children according to\nExclusive XML\nCanonicalization Version 1.0.\n\n

\n

\n\n
root_node
\n
\nis\nXMLNode or\nXMLDoc wrapper object\naround XML structure\n
\n\n
excluding_node
\n
\nallows omitting from the output a part of the document\ncorresponding to the node and its children\n
\n\n
withComments
\n
\na boolean value, false by default.\nIf true, canonicalization corresponds to\nExclusive XML\nCanonicalization Version 1.0.\nReturns Buffer object that contains canonicalized output.\n
\n\n
prefix_list
\n
\nan optional string with a space separated namespace prefixes\nfor namespaces that should also be included into the output\n
\n\n

\n

\n\n
\n\n
serialize()
\n
\nThe same as\nxml.c14n()\n(since 0.7.11).\n
\n\n
serializeToString()
\n
\nThe same as\nxml.c14n()\nexcept it returns the result as a string\n(since 0.7.11).\n
\n\n
XMLDoc
\n
\nAn XMLDoc wrapper object around XML structure,\nthe root node of the document.\n\n

\n

\n\n
doc.$root
\n
\nthe document's root by its name or undefined\n
\n\n
doc.abc
\n
\nthe first root tag named abc as\nXMLNode wrapper object\n
\n\n

\n

\n\n
\n\n
XMLNode
\n
\nAn XMLNode wrapper object around XML tag node.\n

\n

\n\n
node.abc
\n
\nthe same as\nnode.$tag$abc\n
\n\n
node.$attr$abc
\n
\nthe node's attribute value of abc,\nwritable\nsince 0.7.11\n
\n\n
node.$attr$abc=xyz
\n
\nthe same as\nnode.setAttribute('abc',\nxyz)\n(since 0.7.11)\n
\n\n
node.$attrs
\n
\nan XMLAttr wrapper object\nfor all attributes of the node\n
\n\n
node.$name
\n
\nthe name of the node\n
\n\n
node.$ns
\n
\nthe namespace of the node\n
\n\n
node.$parent
\n
\nthe parent node of the current node\n
\n\n
node.$tag$abc
\n
\nthe first child tag of the node named abc,\nwritable\nsince 0.7.11\n
\n\n
node.$tags
\n
\nan array of all children tags\n
\n\n
node.$tags = [node1, node2, ...]
\n
\nthe same as\nnode.removeChildren();\nnode.addChild(node1);\nnode.addChild(node2)\n(since 0.7.11).\n
\n\n
node.$tags$abc
\n
\nall children tags named abc of the node,\nwritable\nsince 0.7.11\n
\n\n
node.$text
\n
\nthe content of the node,\nwritable\nsince 0.7.11\n
\n\n
node.$text = 'abc'
\n
\nthe same as\nnode.setText('abc')\n(since 0.7.11)\n
\n\n
node.addChild(nd)
\n
\nadds XMLNode as a child to node\n(since 0.7.11).\nnd is recursively copied before adding to the node\n
\n\n
node.removeAllAttributes()
\n
\nremoves all attributes of the node\n(since 0.7.11)\n
\n\n
node.removeAttribute(attr_name)
\n
\nremoves the attribute named attr_name\n(since 0.7.11)\n
\n\n
node.removeChildren(tag_name)
\n
\nremoves all the children tags named tag_name\n(since 0.7.11).\nIf tag_name is absent, all children tags are removed\n
\n\n
node.removeText()
\n
\nremoves the node's text value\n(0.7.11)\n
\n\n
node.setAttribute(attr_name,\nvalue)
\n
\nsets a value for an attr_name\n(since 0.7.11).\nWhen the value is null,\nthe attribute named attr_name is deleted\n
\n\n
node.setText(value)
\n
\nsets a text value for the node\n(since 0.7.11).\nWhen the value is null, the text of the node is deleted.\n
\n\n

\n

\n\n
\n\n
XMLAttr
\n
\nAn XMLAttrs wrapper object around XML node attributes.\n\n

\n

\n\n
attr.abc
\n
\nthe attribute value of abc\n
\n\n

\n

\n\n
\n\n

\n

zlib

\n\n\n\n\n\n
zlib.deflateRawSync()
zlib.deflateSync()
zlib.inflateRawSync()
zlib.inflateSync()
\n

\nThe zlib module provides compression functionality using the\n“deflate” and “inflate” algorithms\n(since 0.7.12).\nThe zlib module object is imported using\nimport zlib from 'zlib'.\n

\n

\n\n
deflateRawSync(string |\nBuffer[,\noptions])
\n
\nCompresses data using the “deflate” algorithm provided as a string or Buffer\nand does not append a zlib header.\nThe buffer value can be a\nBuffer,\nTypedArray, or\nDataView.\nOptions is an optional object that contains\nzlib_options.\nReturns Buffer instance that contains the compressed data.\n
\n\n
deflateSync(string |\nBuffer[,\noptions])
\n
\nCompresses data using the “deflate” algorithm provided as a string or Buffer.\nThe Buffer value can be a\nBuffer,\nTypedArray, or\nDataView.\nOptions is an optional object that contains\nzlib_options.\nReturns Buffer instance that contains the compressed data.\n
\n\n
inflateRawSync(string |\nBuffer)
\n
\nDecompresses a raw stream by using the “deflate” algorithm.\nReturns Buffer instance that contains the decompressed data.\n
\n\n
inflateSync(string |\nBuffer)
\n
\nDecompresses a stream by using the “deflate” algorithm.\nReturns Buffer instance that contains the decompressed data.\n
\n\n

\n

zlib options

\n

\n

zlib compression levels

\n\n\n\n\n\n\n
NameDescription
zlib.constants.Z_NO_COMPRESSIONno compression
zlib.constants.Z_BEST_SPEEDfastest, produces the least compression
zlib.constants.Z_DEFAULT_COMPRESSIONtrade-off between speed and compression
zlib.constants.Z_BEST_COMPRESSIONslowest, produces the most compression
\n

zlib compression strategy

\n\n\n\n\n\n\n\n
NameDescription
zlib.constants.Z_FILTEREDFiltered strategy: for the data produced by a filter or predictor
zlib.constants.Z_HUFFMAN_ONLYHuffman-only strategy: only Huffman encoding, no string matching
zlib.constants.Z_RLERun Length Encoding strategy: limit match distances to one, better compression of PNG image data
zlib.constants.Z_FIXEDFixed table strategy: prevents the use of dynamic Huffman codes, a simpler decoder for special applications
zlib.constants.Z_DEFAULT_STRATEGYDefault strategy, suitable for general purpose compression
\n

\n", "encoding": "utf-8"} +{"path": "en\\docs\\njs\\security.html", "extension": ".html", "size_bytes": 3854, "content": "\nSecurity
\n\nPlanning your ingress-nginx migration? Start here:\nkubernetes.nginx.org.\n\n

Security

\nAll nginx security issues should be reported to\nF5SIRT@f5.com\nor via one of the methods listed\nhere.\n

\nPatches are signed using one of the\nPGP public keys.\n

Special considerations

\nnjs does not evaluate dynamic code,\nespecially code received from the network, in any way.\nThe only way to evaluate that code using njs\nis to configure the\njs_import\ndirective in nginx.\nJavaScript code is loaded once during nginx start.\n

\nIn the nginx/njs threat model, JavaScript code is considered a trusted source\nin the same way as nginx.conf and sites certificates.\nWhat this means in practice:\n\n

\n

Advisories

\n", "encoding": "utf-8"} +{"path": "en\\docs\\njs\\typescript.html", "extension": ".html", "size_bytes": 4615, "content": "\nWriting njs code using TypeScript definition files
\n\nPlanning your ingress-nginx migration? Start here:\nkubernetes.nginx.org.\n\n

Writing njs code using TypeScript definition files

Compiling TypeScript definition files
API checks and autocompletions
Writing njs type-safe code

\nTypeScript is\na typed superset of JavaScript\nthat compiles to plain JavaScript.\n

\nTypeScript supports definition files that contain\ntype information of existing JavaScript libraries.\nThis enables other programs to use the values defined in the files\nas if they were statically typed TypeScript entities.\n

\nnjs provides TypeScript definition files for its\nAPI which can be used to:\n

\n

Compiling TypeScript definition files

\n

\n$ git clone https://github.com/nginx/njs\n$ cd njs && ./configure && make ts\n$ ls build/ts/\nnjs_core.d.ts\nnjs_shell.d.ts\nngx_http_js_module.d.ts\nngx_stream_js_module.d.ts\n

\n

API checks and autocompletions

\nPut *.d.ts files to a place where you editor can find it.\n

\ntest.js:\n

\n/// <reference path=\"ngx_http_js_module.d.ts\" />\n/**\n * @param {NginxHTTPRequest} r\n * */\nfunction content_handler(r) {\n    r.headersOut['content-type'] = 'text/plain';\n    r.return(200, \"Hello\");\n}\n

\n

Writing njs type-safe code

\ntest.ts:\n

\n/// <reference path=\"ngx_http_js_module.d.ts\" />\nfunction content_handler(r: NginxHTTPRequest) {\n    r.headersOut['content-type'] = 'text/plain';\n    r.return(200, \"Hello from TypeScript\");\n}\n

\nTypeScript installation:\n

\n# npm install -g typescript\n

\nTypeScript compilation:\n

\n$ tsc test.ts\n$ cat test.js\n

\nThe resulting test.js file can be used directly with njs.\n

\n", "encoding": "utf-8"} +{"path": "en\\docs\\stream\\ngx_stream_access_module.html", "extension": ".html", "size_bytes": 5332, "content": "\nModule ngx_stream_access_module
\n\nPlanning your ingress-nginx migration? Start here:\nkubernetes.nginx.org.\n\n

Module ngx_stream_access_module

Example Configuration
Directives
     allow
     deny
\n\n

\nThe ngx_stream_access_module module (1.9.2) allows\nlimiting access to certain client addresses.\n

\n\n\n

Example Configuration

\n

\nserver {\n    ...\n    deny  192.168.1.1;\n    allow 192.168.1.0/24;\n    allow 10.1.1.0/16;\n    allow 2001:0db8::/32;\n    deny  all;\n}\n

\n

\nThe rules are checked in sequence until the first match is found.\nIn this example, access is allowed only for IPv4 networks\n10.1.1.0/16 and 192.168.1.0/24\nexcluding the address 192.168.1.1,\nand for IPv6 network 2001:0db8::/32.\n

\n\n\n

Directives

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n allow \n address |\n CIDR |\n unix: |\n all;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n stream, server
\n

\nAllows access for the specified network or address.\nIf the special value unix: is specified,\nallows access for all UNIX-domain sockets.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n deny \n address |\n CIDR |\n unix: |\n all;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n stream, server
\n

\nDenies access for the specified network or address.\nIf the special value unix: is specified,\ndenies access for all UNIX-domain sockets.\n

\n\n
\n", "encoding": "utf-8"} +{"path": "en\\docs\\stream\\ngx_stream_core_module.html", "extension": ".html", "size_bytes": 38997, "content": "\nModule ngx_stream_core_module
\n\nPlanning your ingress-nginx migration? Start here:\nkubernetes.nginx.org.\n\n

Module ngx_stream_core_module

Example Configuration
Directives
     listen
     preread_buffer_size
     preread_timeout
     proxy_protocol_timeout
     resolver
     resolver_timeout
     server
     server_name
     server_names_hash_bucket_size
     server_names_hash_max_size
     stream
     tcp_nodelay
     variables_hash_bucket_size
     variables_hash_max_size
Embedded Variables
\n\n

\nThe ngx_stream_core_module module\nis available since version 1.9.0.\nThis module is not built by default, it should be enabled with the\n--with-stream\nconfiguration parameter.\n

\n\n\n

Example Configuration

\n

\nworker_processes auto;\n\nerror_log /var/log/nginx/error.log info;\n\nevents {\n    worker_connections  1024;\n}\n\nstream {\n    upstream backend {\n        hash $remote_addr consistent;\n\n        server backend1.example.com:12345 weight=5;\n        server 127.0.0.1:12345            max_fails=3 fail_timeout=30s;\n        server unix:/tmp/backend3;\n    }\n\n    upstream dns {\n       server 192.168.0.1:53535;\n       server dns.example.com:53;\n    }\n\n    server {\n        listen 12345;\n        proxy_connect_timeout 1s;\n        proxy_timeout 3s;\n        proxy_pass backend;\n    }\n\n    server {\n        listen 127.0.0.1:53 udp reuseport;\n        proxy_timeout 20s;\n        proxy_pass dns;\n    }\n\n    server {\n        listen [::1]:12345;\n        proxy_pass unix:/tmp/stream.socket;\n    }\n}\n

\n

\n\n\n

Directives

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n listen \n address:port\n [default_server]\n [ssl]\n [udp]\n [proxy_protocol]\n [setfib=number]\n [fastopen=number]\n [backlog=number]\n [rcvbuf=size]\n [sndbuf=size]\n [accept_filter=filter]\n [deferred]\n [bind]\n [ipv6only=on|off]\n [reuseport]\n [multipath]\n [so_keepalive=on|off|[keepidle]:[keepintvl]:[keepcnt]];
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n server
\n

\nSets the address and port for the socket\non which the server will accept connections.\nIt is possible to specify just the port.\nThe address can also be a hostname, for example:\n

\nlisten 127.0.0.1:12345;\nlisten *:12345;\nlisten 12345;     # same as *:12345\nlisten localhost:12345;\n

\nIPv6 addresses are specified in square brackets:\n

\nlisten [::1]:12345;\nlisten [::]:12345;\n

\nUNIX-domain sockets are specified with the “unix:”\nprefix:\n

\nlisten unix:/var/run/nginx.sock;\n

\n

\nPort ranges (1.15.10) are specified with the\nfirst and last port separated by a hyphen:\n

\nlisten 127.0.0.1:12345-12399;\nlisten 12345-12399;\n

\n

\nThe default_server parameter, if present,\nwill cause the server to become the default server for the specified\naddress:port pair (1.25.5).\nIf none of the directives have the default_server\nparameter then the first server with the\naddress:port pair will be\nthe default server for this pair.\n

\nThe ssl parameter allows specifying that all\nconnections accepted on this port should work in SSL mode.\n

\nThe udp parameter configures a listening socket\nfor working with datagrams (1.9.13).\nIn order to handle packets from the same address and port in the same session,\nthe reuseport parameter\nshould also be specified.\n

\nThe proxy_protocol parameter (1.11.4)\nallows specifying that all connections accepted on this port should use the\nPROXY\nprotocol.\n

\nThe PROXY protocol version 2 is supported since version 1.13.11.\n

\n

\nThe listen directive\ncan have several additional parameters specific to socket-related system calls.\nThese parameters can be specified in any\nlisten directive, but only once for a given\naddress:port pair.\n

\n\n
\nsetfib=number\n
\n
\nthis parameter (1.25.5) sets the associated routing table, FIB\n(the SO_SETFIB option) for the listening socket.\nThis currently works only on FreeBSD.\n
\n\n
\nfastopen=number\n
\n
\nenables\n“TCP Fast Open”\nfor the listening socket (1.21.0) and\nlimits\nthe maximum length for the queue of connections that have not yet completed\nthe three-way handshake.\n
\nDo not enable this feature unless the server can handle\nreceiving the\n\nsame SYN packet with data more than once.\n
\n
\n\n
\nbacklog=number\n
\n
\nsets the backlog parameter in the\nlisten() call that limits\nthe maximum length for the queue of pending connections (1.9.2).\nBy default,\nbacklog is set to -1 on FreeBSD, DragonFly BSD, and macOS,\nand to 511 on other platforms.\n
\n\n
\nrcvbuf=size\n
\n
\nsets the receive buffer size\n(the SO_RCVBUF option) for the listening socket (1.11.13).\n
\n\n
\nsndbuf=size\n
\n
\nsets the send buffer size\n(the SO_SNDBUF option) for the listening socket (1.11.13).\n
\n\n
\naccept_filter=filter\n
\n
\nsets the name of accept filter\n(the SO_ACCEPTFILTER option) for the listening socket\nthat filters incoming connections before passing them to\naccept() (1.25.5).\nThis works only on FreeBSD and NetBSD 5.0+.\nPossible values are\ndataready\nand\nhttpready.\n
\n\n
\ndeferred\n
\n
\ninstructs to use a deferred accept()\n(the TCP_DEFER_ACCEPT socket option) on Linux (1.25.5).\n
\n\n
\nbind\n
\n
\nthis parameter instructs to make a separate bind()\ncall for a given address:port pair.\nThe fact is that if there are several listen directives with\nthe same port but different addresses, and one of the\nlisten directives listens on all addresses\nfor the given port (*:port), nginx will\nbind() only to *:port.\nIt should be noted that the getsockname() system call will be\nmade in this case to determine the address that accepted the connection.\nIf the setfib,\nfastopen,\nbacklog, rcvbuf,\nsndbuf, accept_filter,\ndeferred, ipv6only,\nreuseport, multipath,\nor so_keepalive parameters\nare used then for a given\naddress:port pair\na separate bind() call will always be made.\n
\n\n
\nipv6only=on|off\n
\n
\nthis parameter determines\n(via the IPV6_V6ONLY socket option)\nwhether an IPv6 socket listening on a wildcard address [::]\nwill accept only IPv6 connections or both IPv6 and IPv4 connections.\nThis parameter is turned on by default.\nIt can only be set once on start.\n
\n\n
\nreuseport\n
\n
\nthis parameter (1.9.1) instructs to create an individual listening socket\nfor each worker process\n(using the\nSO_REUSEPORT socket option on Linux 3.9+ and DragonFly BSD,\nor SO_REUSEPORT_LB on FreeBSD 12+), allowing a kernel\nto distribute incoming connections between worker processes.\nThis currently works only on Linux 3.9+, DragonFly BSD,\nand FreeBSD 12+ (1.15.1).\n
\nInappropriate use of this option may have its security\nimplications.\n
\n
\n\n
\nmultipath\n
\n
\nthis parameter (1.29.7) configures the\nMultipath TCP\nprotocol (IPPROTO_MPTCP) for the listening socket.\nThis currently works only on Linux 5.6+.\n
\nAdding or removing this parameter will also enable\nthe SO_REUSEPORT socket option, which may have its security\nimplications.\n
\n
\n\n
\nso_keepalive=on|off|[keepidle]:[keepintvl]:[keepcnt]\n
\n
\nthis parameter configures the “TCP keepalive” behavior\nfor the listening socket.\nIf this parameter is omitted then the operating system’s settings will be\nin effect for the socket.\nIf it is set to the value “on”, the\nSO_KEEPALIVE option is turned on for the socket.\nIf it is set to the value “off”, the\nSO_KEEPALIVE option is turned off for the socket.\nSome operating systems support setting of TCP keepalive parameters on\na per-socket basis using the TCP_KEEPIDLE,\nTCP_KEEPINTVL, and TCP_KEEPCNT socket options.\nOn such systems\n(currently, Linux, NetBSD, Dragonfly, FreeBSD, and macOS),\nthey can be configured\nusing the keepidle, keepintvl, and\nkeepcnt parameters.\nOne or two parameters may be omitted, in which case the system default setting\nfor the corresponding socket option will be in effect.\nFor example,\n
so_keepalive=30m::10
\nwill set the idle timeout (TCP_KEEPIDLE) to 30 minutes,\nleave the probe interval (TCP_KEEPINTVL) at its system default,\nand set the probes count (TCP_KEEPCNT) to 10 probes.\n
\n\n

\n

\n

\nBefore version 1.25.5, different servers must listen on different\naddress:port pairs.\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n preread_buffer_size size;
\n
\n Default:\n \n
preread_buffer_size 16k;
\n
\n Context:\n \n stream, server
\n

This directive appeared in version 1.11.5.\n

\nSpecifies a size of the\npreread buffer.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n preread_timeout timeout;
\n
\n Default:\n \n
preread_timeout 30s;
\n
\n Context:\n \n stream, server
\n

This directive appeared in version 1.11.5.\n

\nSpecifies a timeout of the\npreread phase.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n proxy_protocol_timeout timeout;
\n
\n Default:\n \n
proxy_protocol_timeout 30s;
\n
\n Context:\n \n stream, server
\n

This directive appeared in version 1.11.4.\n

\nSpecifies a timeout for\nreading the PROXY protocol header to complete.\nIf no entire header is transmitted within this time,\nthe connection is closed.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n resolver \n address ...\n [valid=time]\n [ipv4=on|off]\n [ipv6=on|off]\n [status_zone=zone];
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n stream, server
\n

This directive appeared in version 1.11.3.\n

\nConfigures name servers used to resolve names of upstream servers\ninto addresses, for example:\n

\nresolver 127.0.0.1 [::1]:5353;\n

\nThe address can be specified as a domain name or IP address,\nwith an optional port.\nIf port is not specified, the port 53 is used.\nName servers are queried in a round-robin fashion.\n

\nBy default, nginx will look up both IPv4 and IPv6 addresses while resolving.\nIf looking up of IPv4 or IPv6 addresses is not desired,\nthe ipv4=off (1.23.1) or\nthe ipv6=off parameter can be specified.\n

\nBy default, nginx caches answers using the TTL value of a response.\nThe optional valid parameter allows overriding it:\n

\nresolver 127.0.0.1 [::1]:5353 valid=30s;\n

\n

\nTo prevent DNS spoofing, it is recommended\nconfiguring DNS servers in a properly secured trusted local network.\n

\n

\nThe optional status_zone parameter (1.17.1)\nenables\ncollection\nof DNS server statistics of requests and responses\nin the specified zone.\nThe parameter is available as part of our\ncommercial subscription.\n

\n

\nBefore version 1.11.3, this directive was available as part of our\ncommercial subscription.\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n resolver_timeout time;
\n
\n Default:\n \n
resolver_timeout 30s;
\n
\n Context:\n \n stream, server
\n

This directive appeared in version 1.11.3.\n

\nSets a timeout for name resolution, for example:\n

\nresolver_timeout 5s;\n

\n

\nBefore version 1.11.3, this directive was available as part of our\ncommercial subscription.\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n server { ... }
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n stream
\n

\nSets the configuration for a virtual server.\nThere is no clear separation between IP-based (based on the IP address)\nand name-based (based on the\nTLS\nServer Name Indication extension (SNI, RFC 6066)) (1.25.5)\nvirtual servers.\nInstead, the listen directives describe all\naddresses and ports that should accept connections for the server, and the\nserver_name directive lists all server names.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n server_name name ...;
\n
\n Default:\n \n
server_name \"\";
\n
\n Context:\n \n server
\n

This directive appeared in version 1.25.5.\n

\nSets names of a virtual server, for example:\n

\nserver {\n    server_name example.com www.example.com;\n}\n

\n

\nThe first name becomes the primary server name.\n

\nServer names can include an asterisk (“*”)\nreplacing the first or last part of a name:\n

\nserver {\n    server_name example.com *.example.com www.example.*;\n}\n

\nSuch names are called wildcard names.\n

\nThe first two of the names mentioned above can be combined in one:\n

\nserver {\n    server_name .example.com;\n}\n

\n

\nIt is also possible to use regular expressions in server names,\npreceding the name with a tilde (“~”):\n

\nserver {\n    server_name www.example.com ~^www\\d+\\.example\\.com$;\n}\n

\n

\nRegular expressions can contain captures that can later\nbe used in other directives:\n

\nserver {\n    server_name ~^(www\\.)?(.+)$;\n\n    proxy_pass www.$2:12345;\n}\n

\n

\nNamed captures in regular expressions create variables\nthat can later be used in other directives:\n

\nserver {\n    server_name ~^(www\\.)?(?<domain>.+)$;\n\n    proxy_pass www.$domain:12345;\n}\n

\n

\nIf the directive’s parameter is set to “$hostname”, the\nmachine’s hostname is inserted.\n

\nThe search is performed in the following order of priority\nand terminates on the first matching variant:\n

    \n\n
  1. \nthe exact name\n
  2. \n\n
  3. \nthe longest wildcard name starting with an asterisk,\ne.g. “*.example.com”\n
  4. \n\n
  5. \nthe longest wildcard name ending with an asterisk,\ne.g. “mail.*”\n
  6. \n\n
  7. \nthe first matching regular expression\n(in order of appearance in the configuration file)\n
  8. \n\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n server_names_hash_bucket_size size;
\n
\n Default:\n \n
server_names_hash_bucket_size 32|64|128;
\n
\n Context:\n \n stream
\n

This directive appeared in version 1.25.5.\n

\nSets the bucket size for the server names hash tables.\nThe default value depends on the size of the processor’s cache line.\nThe details of setting up hash tables are provided in a separate\ndocument.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n server_names_hash_max_size size;
\n
\n Default:\n \n
server_names_hash_max_size 512;
\n
\n Context:\n \n stream
\n

This directive appeared in version 1.25.5.\n

\nSets the maximum size of the server names hash tables.\nThe details of setting up hash tables are provided in a separate\ndocument.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n stream { ... }
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n main
\n

\nProvides the configuration file context in which the stream server directives\nare specified.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n tcp_nodelay on | off;
\n
\n Default:\n \n
tcp_nodelay on;
\n
\n Context:\n \n stream, server
\n

This directive appeared in version 1.9.4.\n

\nEnables or disables the use of the TCP_NODELAY option.\nThe option is enabled for both client and proxied server connections.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n variables_hash_bucket_size size;
\n
\n Default:\n \n
variables_hash_bucket_size 64;
\n
\n Context:\n \n stream
\n

This directive appeared in version 1.11.2.\n

\nSets the bucket size for the variables hash table.\nThe details of setting up hash tables are provided in a separate\ndocument.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n variables_hash_max_size size;
\n
\n Default:\n \n
variables_hash_max_size 1024;
\n
\n Context:\n \n stream
\n

This directive appeared in version 1.11.2.\n

\nSets the maximum size of the variables hash table.\nThe details of setting up hash tables are provided in a separate\ndocument.\n

\n\n\n

Embedded Variables

\nThe ngx_stream_core_module module supports variables\nsince 1.11.2.\n

\n\n
$binary_remote_addr
\n
\nclient address in a binary form, value’s length is always 4 bytes\nfor IPv4 addresses or 16 bytes for IPv6 addresses\n
\n\n
$bytes_received
\n
\nnumber of bytes received from a client (1.11.4)\n
\n\n
$bytes_sent
\n
\nnumber of bytes sent to a client\n
\n\n
$connection
\n
\nconnection serial number\n
\n\n
$hostname
\n
\nhost name\n
\n\n
$msec
\n
\ncurrent time in seconds with the milliseconds resolution\n
\n\n
$nginx_version
\n
\nnginx version\n
\n\n
$pid
\n
\nPID of the worker process\n
\n\n
$protocol
\n
\nprotocol used to communicate with the client:\nTCP or UDP (1.11.4)\n
\n\n
$proxy_protocol_addr
\n
\nclient address from the PROXY protocol header (1.11.4)\n

\nThe PROXY protocol must be previously enabled by setting the\nproxy_protocol parameter\nin the listen directive.\n

\n
\n\n
$proxy_protocol_port
\n
\nclient port from the PROXY protocol header (1.11.4)\n

\nThe PROXY protocol must be previously enabled by setting the\nproxy_protocol parameter\nin the listen directive.\n

\n
\n\n
$proxy_protocol_server_addr
\n
\nserver address from the PROXY protocol header (1.17.6)\n

\nThe PROXY protocol must be previously enabled by setting the\nproxy_protocol parameter\nin the listen directive.\n

\n
\n\n
$proxy_protocol_server_port
\n
\nserver port from the PROXY protocol header (1.17.6)\n

\nThe PROXY protocol must be previously enabled by setting the\nproxy_protocol parameter\nin the listen directive.\n

\n
\n\n
$proxy_protocol_tlv_name
\n
\nTLV from the PROXY Protocol header (1.23.2).\nThe name can be a TLV type name or its numeric value.\nIn the latter case, the value is hexadecimal\nand should be prefixed with 0x:\n\n
\n$proxy_protocol_tlv_alpn\n$proxy_protocol_tlv_0x01\n
\nSSL TLVs can also be accessed by TLV type name or its numeric value,\nboth prefixed by ssl_:\n
\n$proxy_protocol_tlv_ssl_version\n$proxy_protocol_tlv_ssl_0x21\n
\n\n

\nThe following TLV type names are supported:\n

    \n\n
  • \nalpn (0x01) - \nupper layer protocol used over the connection\n
  • \n\n
  • \nauthority (0x02) - \nhost name value passed by the client\n
  • \n\n
  • \nunique_id (0x05) - \nunique connection id\n
  • \n\n
  • \nnetns (0x30) - \nname of the namespace\n
  • \n\n
  • \nssl (0x20) - \nbinary SSL TLV structure\n
  • \n\n

\n

\n\n

\nThe following SSL TLV type names are supported:\n

    \n\n
  • \nssl_version (0x21) - \nSSL version used in client connection\n
  • \n\n
  • \nssl_cn (0x22) - \nSSL certificate Common Name\n
  • \n\n
  • \nssl_cipher (0x23) - \nname of the used cipher\n
  • \n\n
  • \nssl_sig_alg (0x24) - \nalgorithm used to sign the certificate\n
  • \n\n
  • \nssl_key_alg (0x25) - \npublic-key algorithm\n
  • \n\n

\n

\n\n

\nAlso, the following special SSL TLV type name is supported:\n

    \n\n
  • \nssl_verify - \nclient SSL certificate verification result,\nzero if the client presented a certificate\nand it was successfully verified, and non-zero otherwise\n
  • \n\n

\n

\n\n

\nThe PROXY protocol must be previously enabled by setting the\nproxy_protocol parameter\nin the listen directive.\n

\n
\n\n
$remote_addr
\n
\nclient address\n
\n\n
$remote_port
\n
\nclient port\n
\n\n
$server_addr
\n
\nan address of the server which accepted a connection\n

\nComputing a value of this variable usually requires one system call.\nTo avoid a system call, the listen directives\nmust specify addresses and use the bind parameter.\n

\n
\n\n
$server_port
\n
\nport of the server which accepted a connection\n
\n\n
$session_time
\n
\nsession duration in seconds with a milliseconds resolution\n(1.11.4);\n
\n\n
$status
\n
\nsession status (1.11.4), can be one of the following:\n
\n\n
200
\n
\nsession completed successfully\n
\n\n
400
\n
\nclient data could not be parsed, for example,\nthe PROXY protocol header\n
\n\n
403
\n
\naccess forbidden, for example, when access is limited for\ncertain client addresses\n
\n\n
500
\n
\ninternal server error\n
\n\n
502
\n
\nbad gateway, for example,\nif an upstream server could not be selected or reached.\n
\n\n
503
\n
\nservice unavailable, for example, when access is limited by the\nnumber of connections\n
\n\n
\n
\n\n
$time_iso8601
\n
\nlocal time in the ISO 8601 standard format\n
\n\n
$time_iso8601_ms
\n
\nlocal time in the ISO 8601 standard format\nwith a millisecond resolution (1.29.8)\n

\n

\nThis variable is available as part of our\ncommercial subscription.\n

\n

\n
\n\n
$time_local
\n
\nlocal time in the Common Log Format\n
\n\n

\n

\n\n
\n", "encoding": "utf-8"} +{"path": "en\\docs\\stream\\ngx_stream_geoip_module.html", "extension": ".html", "size_bytes": 9420, "content": "\nModule ngx_stream_geoip_module
\n\nPlanning your ingress-nginx migration? Start here:\nkubernetes.nginx.org.\n\n

Module ngx_stream_geoip_module

Example Configuration
Directives
     geoip_country
     geoip_city
     geoip_org
\n\n

\nThe ngx_stream_geoip_module module (1.11.3) creates variables\nwith values depending on the client IP address, using the precompiled\nMaxMind databases.\n

\nWhen using the databases with IPv6 support,\nIPv4 addresses are looked up as IPv4-mapped IPv6 addresses.\n

\nThis module is not built by default, it should be enabled with the\n--with-stream_geoip_module\nconfiguration parameter.\n

\nThis module requires the\nMaxMind GeoIP library.\n

\n

\n\n\n

Example Configuration

\n

\nstream {\n    geoip_country         GeoIP.dat;\n    geoip_city            GeoLiteCity.dat;\n\n    map $geoip_city_continent_code $nearest_server {\n        default        example.com;\n        EU          eu.example.com;\n        NA          na.example.com;\n        AS          as.example.com;\n    }\n   ...\n}\n

\n

\n\n\n

Directives

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n geoip_country file;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n stream
\n

\nSpecifies a database used to determine the country\ndepending on the client IP address.\nThe following variables are available when using this database:\n

\n\n
$geoip_country_code
\n
\ntwo-letter country code, for example,\n“RU”, “US”.\n
\n\n
$geoip_country_code3\n
\n
\nthree-letter country code, for example,\n“RUS”, “USA”.\n
\n\n
$geoip_country_name
\n
\ncountry name, for example,\n“Russian Federation”, “United States”.\n
\n\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n geoip_city file;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n stream
\n

\nSpecifies a database used to determine the country, region, and city\ndepending on the client IP address.\nThe following variables are available when using this database:\n

\n\n
$geoip_area_code
\n
telephone area code (US only).\n
\nThis variable may contain outdated information since\nthe corresponding database field is deprecated.\n
\n
\n\n
\n$geoip_city_continent_code
\n
two-letter continent code, for example,\n“EU”, “NA”.\n
\n\n
$geoip_city_country_code\n
\n
\ntwo-letter country code, for example,\n“RU”, “US”.\n
\n\n
$geoip_city_country_code3\n
\n
\nthree-letter country code, for example,\n“RUS”, “USA”.\n
\n\n
$geoip_city_country_name\n
\n
\ncountry name, for example,\n“Russian Federation”, “United States”.\n
\n\n
$geoip_dma_code
\n
\nDMA region code in US (also known as “metro code”), according to the\ngeotargeting\nin Google AdWords API.\n
\n\n
$geoip_latitude
\n
latitude.
\n\n
$geoip_longitude
\n
longitude.
\n\n
$geoip_region
\n
\ntwo-symbol country region code (region, territory, state, province, federal land\nand the like), for example,\n“48”, “DC”.\n
\n\n
$geoip_region_name
\n
\ncountry region name (region, territory, state, province, federal land\nand the like), for example,\n“Moscow City”, “District of Columbia”.\n
\n\n
$geoip_city
\n
\ncity name, for example,\n“Moscow”, “Washington”.\n
\n\n
$geoip_postal_code
\n
\npostal code.\n
\n\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n geoip_org file;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n stream
\n

\nSpecifies a database used to determine the organization\ndepending on the client IP address.\nThe following variable is available when using this database:\n

\n\n
$geoip_org
\n
\norganization name, for example, “The University of Melbourne”.\n
\n\n

\n

\n\n
\n", "encoding": "utf-8"} +{"path": "en\\docs\\stream\\ngx_stream_geo_module.html", "extension": ".html", "size_bytes": 6539, "content": "\nModule ngx_stream_geo_module
\n\nPlanning your ingress-nginx migration? Start here:\nkubernetes.nginx.org.\n\n

Module ngx_stream_geo_module

Example Configuration
Directives
     geo
\n\n

\nThe ngx_stream_geo_module module (1.11.3) creates variables\nwith values depending on the client IP address.\n

\n\n\n

Example Configuration

\n

\ngeo $geo {\n    default        0;\n\n    127.0.0.1      2;\n    192.168.1.0/24 1;\n    10.1.0.0/16    1;\n\n    ::1            2;\n    2001:0db8::/32 1;\n}\n

\n

\n\n\n

Directives

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n geo [$address] $variable { ... }
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n stream
\n

\nDescribes the dependency of values of the specified variable\non the client IP address.\nBy default, the address is taken from the $remote_addr variable,\nbut it can also be taken from another variable, for example:\n

\ngeo $arg_remote_addr $geo {\n    ...;\n}\n

\n

\n

\nSince variables are evaluated only when used, the mere existence\nof even a large number of declared “geo” variables\ndoes not cause any extra costs for connection processing.\n

\n

\nIf the value of a variable does not represent a valid IP address\nthen the “255.255.255.255” address is used.\n

\nAddresses are specified either as prefixes in CIDR notation\n(including individual addresses) or as ranges.\n

\nThe following special parameters are also supported:\n

\n\n
delete
\n
\ndeletes the specified network.\n
\n\n
default
\n
\na value set to the variable if the client address does not\nmatch any of the specified addresses.\nWhen addresses are specified in CIDR notation,\n“0.0.0.0/0” and “::/0”\ncan be used instead of default.\nWhen default is not specified, the default\nvalue will be an empty string.\n
\n\n
include
\n
\nincludes a file with addresses and values.\nThere can be several inclusions.\n
\n\n
ranges
\n
\nindicates that addresses are specified as ranges.\nThis parameter should be the first.\nTo speed up loading of a geo base, addresses should be put in ascending order.\n
\n\n
volatile
\n
\nindicates that the variable is not cacheable (1.29.3).\n
\n\n

\n

\nExample:\n

\ngeo $country {\n    default        ZZ;\n    include        conf/geo.conf;\n    delete         127.0.0.0/16;\n\n    127.0.0.0/24   US;\n    127.0.0.1/32   RU;\n    10.1.0.0/16    RU;\n    192.168.1.0/24 UK;\n}\n

\n

\nThe conf/geo.conf file could contain the following lines:\n

\n10.2.0.0/16    RU;\n192.168.2.0/24 RU;\n

\n

\nA value of the most specific match is used.\nFor example, for the 127.0.0.1 address the value “RU”\nwill be chosen, not “US”.\n

\nExample with ranges:\n

\ngeo $country {\n    ranges;\n    default                   ZZ;\n    127.0.0.0-127.0.0.0       US;\n    127.0.0.1-127.0.0.1       RU;\n    127.0.0.1-127.0.0.255     US;\n    10.1.0.0-10.1.255.255     RU;\n    192.168.1.0-192.168.1.255 UK;\n}\n

\n

\n\n
\n", "encoding": "utf-8"} +{"path": "en\\docs\\stream\\ngx_stream_js_module.html", "extension": ".html", "size_bytes": 48381, "content": "\nModule ngx_stream_js_module
\n\nPlanning your ingress-nginx migration? Start here:\nkubernetes.nginx.org.\n\n

Module ngx_stream_js_module

Example Configuration
Directives
     js_access
     js_context_reuse
     js_engine
     js_fetch_buffer_size
     js_fetch_ciphers
     js_fetch_max_response_buffer_size
     js_fetch_protocols
     js_fetch_timeout
     js_fetch_trusted_certificate
     js_fetch_verify
     js_fetch_verify_depth
     js_fetch_proxy
     js_fetch_keepalive
     js_fetch_keepalive_requests
     js_fetch_keepalive_time
     js_fetch_keepalive_timeout
     js_filter
     js_import
     js_include
     js_load_stream_native_module
     js_path
     js_periodic
     js_preload_object
     js_preread
     js_set
     js_shared_dict_zone
     js_var
Session Object Properties
\n\n

\nThe ngx_stream_js_module module is used to implement\nhandlers in njs —\na subset of the JavaScript language.\n

\nDownload and install instructions are available\nhere.\n

\n\n\n

Example Configuration

\nThe example works since\n0.4.0.\n

\nstream {\n    js_import stream.js;\n\n    js_set $bar stream.bar;\n    js_set $req_line stream.req_line;\n\n    server {\n        listen 12345;\n\n        js_preread stream.preread;\n        return     $req_line;\n    }\n\n    server {\n        listen 12346;\n\n        js_access  stream.access;\n        proxy_pass 127.0.0.1:8000;\n        js_filter  stream.header_inject;\n    }\n}\n\nhttp {\n    server {\n        listen 8000;\n        location / {\n            return 200 $http_foo\\n;\n        }\n    }\n}\n

\n

\nThe stream.js file:\n

\nvar line = '';\n\nfunction bar(s) {\n    var v = s.variables;\n    s.log(\"hello from bar() handler!\");\n    return \"bar-var\" + v.remote_port + \"; pid=\" + v.pid;\n}\n\nfunction preread(s) {\n    s.on('upload', function (data, flags) {\n        var n = data.indexOf('\\n');\n        if (n != -1) {\n            line = data.substr(0, n);\n            s.done();\n        }\n    });\n}\n\nfunction req_line(s) {\n    return line;\n}\n\n// Read HTTP request line.\n// Collect bytes in 'req' until\n// request line is read.\n// Injects HTTP header into a client's request\n\nvar my_header =  'Foo: foo';\nfunction header_inject(s) {\n    var req = '';\n    s.on('upload', function(data, flags) {\n        req += data;\n        var n = req.search('\\n');\n        if (n != -1) {\n            var rest = req.substr(n + 1);\n            req = req.substr(0, n + 1);\n            s.send(req + my_header + '\\r\\n' + rest, flags);\n            s.off('upload');\n        }\n    });\n}\n\nfunction access(s) {\n    if (s.remoteAddress.match('^192.*')) {\n        s.deny();\n        return;\n    }\n\n    s.allow();\n}\n\nexport default {bar, preread, req_line, header_inject, access};\n

\n

\n\n\n

Directives

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n js_access module.function;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n stream, server
\n

\nSets an njs function which will be called at the\naccess phase.\nSince 0.4.0,\na module function can be referenced.\n

\nThe function is called once at the moment when the stream session reaches\nthe access phase\nfor the first time.\nThe function is called with the following arguments:\n\n

\n
s
\n
\nthe Stream Session object\n
\n\n

\n

\nAt this phase, it is possible to perform initialization\nor register a callback with\nthe s.on()\nmethod\nfor each incoming data chunk until one of the following methods are called:\ns.allow(),\ns.decline(),\ns.done().\nAs soon as one of these methods is called, the stream session processing\nswitches to the next phase\nand all current\ns.on()\ncallbacks are dropped.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n js_context_reuse number;
\n
\n Default:\n \n
js_context_reuse 128;
\n
\n Context:\n \n stream, server
\n

This directive appeared in version 0.8.6.\n

\nSets a maximum number of JS context to be reused for\nQuickJS engine.\nEach context is used for a single stream session.\nThe finished context is put into a pool of reusable contexts.\nIf the pool is full, the context is destroyed.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n js_engine njs | qjs;
\n
\n Default:\n \n
js_engine njs;
\n
\n Context:\n \n stream, server
\n

This directive appeared in version 0.8.6.\n

\nSets a JavaScript engine\nto be used for njs scripts.\nThe njs parameter sets the njs engine, also used by default.\nThe qjs parameter sets the QuickJS engine.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n js_fetch_buffer_size size;
\n
\n Default:\n \n
js_fetch_buffer_size 16k;
\n
\n Context:\n \n stream, server
\n

This directive appeared in version 0.7.4.\n

\nSets the size of the buffer used for reading and writing\nwith Fetch API.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n js_fetch_ciphers ciphers;
\n
\n Default:\n \n
js_fetch_ciphers HIGH:!aNULL:!MD5;
\n
\n Context:\n \n stream, server
\n

This directive appeared in version 0.7.0.\n

\nSpecifies the enabled ciphers for HTTPS connections\nwith Fetch API.\nThe ciphers are specified in the format understood by the OpenSSL library.\n

\nThe full list can be viewed using the\n“openssl ciphers” command.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n js_fetch_max_response_buffer_size size;
\n
\n Default:\n \n
js_fetch_max_response_buffer_size 1m;
\n
\n Context:\n \n stream, server
\n

This directive appeared in version 0.7.4.\n

\nSets the maximum size of the response received\nwith Fetch API.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n js_fetch_protocols \n [TLSv1]\n [TLSv1.1]\n [TLSv1.2]\n [TLSv1.3];
\n
\n Default:\n \n
js_fetch_protocols TLSv1 TLSv1.1 TLSv1.2;
\n
\n Context:\n \n stream, server
\n

This directive appeared in version 0.7.0.\n

\nEnables the specified protocols for HTTPS connections\nwith Fetch API.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n js_fetch_timeout time;
\n
\n Default:\n \n
js_fetch_timeout 60s;
\n
\n Context:\n \n stream, server
\n

This directive appeared in version 0.7.4.\n

\nDefines a timeout for reading and writing\nfor Fetch API.\nThe timeout is set only between two successive read/write operations,\nnot for the whole response.\nIf no data is transmitted within this time, the connection is closed.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n js_fetch_trusted_certificate file;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n stream, server
\n

This directive appeared in version 0.7.0.\n

\nSpecifies a file with trusted CA certificates in the PEM format\nused to\nverify\nthe HTTPS certificate\nwith Fetch API.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n js_fetch_verify on | off;
\n
\n Default:\n \n
js_fetch_verify on;
\n
\n Context:\n \n stream, server
\n

This directive appeared in version 0.7.4.\n

\nEnables or disables verification of the HTTPS server certificate\nwith Fetch API.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n js_fetch_verify_depth number;
\n
\n Default:\n \n
js_fetch_verify_depth 100;
\n
\n Context:\n \n stream, server
\n

This directive appeared in version 0.7.0.\n

\nSets the verification depth in the HTTPS server certificates chain\nwith Fetch API.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n js_fetch_proxy url;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n stream, server
\n

This directive appeared in version 0.9.4.\n

\nConfigures a forward proxy URL\nwith Fetch API.\nThe url supports the HTTP scheme only\nand can contain optional user credentials\nin the format http://[user:password@]host:port\nfor Basic authentication.\nSupports both HTTP and HTTPS connections to destination servers.\nIf the url is empty, proxy routing is disabled.\nThe parameter value can contain variables.\n

\nExample:\n

\nserver {\n    listen 12345;\n    js_fetch_proxy http://user:pass@proxy.example.com:3128;\n    js_preread main.fetch_handler;\n}\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n js_fetch_keepalive connections;
\n
\n Default:\n \n
js_fetch_keepalive 0;
\n
\n Context:\n \n stream, server
\n

This directive appeared in version 0.9.2.\n

\nActivates the cache for connections to destination servers.\nWhen the value is greater than 0,\nenables keepalive connections for\nFetch API.\n

\nThe connections parameter sets the maximum number of idle\nkeepalive connections to destination servers that are preserved in the cache\nof each worker process.\nWhen this number is exceeded, the least recently used connections are closed.\n

\nExample:\n

\nserver {\n    listen 12345;\n    js_fetch_keepalive 32;\n    js_fetch_trusted_certificate /path/to/ISRG_Root_X1.pem;\n    js_preread main.fetch_handler;\n}\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n js_fetch_keepalive_requests number;
\n
\n Default:\n \n
js_fetch_keepalive_requests 1000;
\n
\n Context:\n \n stream, server
\n

This directive appeared in version 0.9.2.\n

\nSets the maximum number of requests that can be served through one keepalive\nconnection with Fetch API.\nAfter the maximum number of requests is made, the connection is closed.\n

\nClosing connections periodically is necessary to free per-connection memory\nallocations.\nTherefore, using too high maximum number of requests could result in\nexcessive memory usage and not recommended.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n js_fetch_keepalive_time time;
\n
\n Default:\n \n
js_fetch_keepalive_time 1h;
\n
\n Context:\n \n stream, server
\n

This directive appeared in version 0.9.2.\n

\nLimits the maximum time during which requests can be processed through one\nkeepalive connection with Fetch API.\nAfter this time is reached, the connection is closed following the subsequent\nrequest processing.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n js_fetch_keepalive_timeout time;
\n
\n Default:\n \n
js_fetch_keepalive_timeout 60s;
\n
\n Context:\n \n stream, server
\n

This directive appeared in version 0.9.2.\n

\nSets a timeout during which an idle keepalive connection to a destination server\nwill stay open with Fetch API.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n js_filter module.function;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n stream, server
\n

\nSets a data filter.\nSince 0.4.0,\na module function can be referenced.\nThe filter function is called once at the moment when the stream session reaches\nthe content phase.\n

\nThe filter function is called with the following arguments:\n

\n
s
\n
\nthe Stream Session object\n
\n\n

\n

\nAt this phase, it is possible to perform initialization\nor register a callback with\nthe s.on()\nmethod for each incoming data chunk.\nThe\ns.off()\nmethod may be used to unregister a callback and stop filtering.\n

\n

\nAs the js_filter handler\nreturns its result immediately, it supports\nonly synchronous operations.\nThus, asynchronous operations such as\nngx.fetch()\nor\nsetTimeout()\nare not supported.\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n js_import module.js |\nexport_name from module.js;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n stream, server
\n

This directive appeared in version 0.4.0.\n

\nImports a module that implements location and variable handlers in njs.\nThe export_name is used as a namespace\nto access module functions.\nIf the export_name is not specified,\nthe module name will be used as a namespace.\n

\njs_import stream.js;\n

\nHere, the module name stream is used as a namespace\nwhile accessing exports.\nIf the imported module exports foo(),\nstream.foo is used to refer to it.\n

\nSeveral js_import directives can be specified.\n

\n

\nThe directive can be specified on the\nserver level\nsince 0.7.7.\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n js_include file;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n stream
\n

\nSpecifies a file that implements server and variable handlers in njs:\n

\nnginx.conf:\njs_include stream.js;\njs_set     $js_addr address;\nserver {\n    listen 127.0.0.1:12345;\n    return $js_addr;\n}\n\nstream.js:\nfunction address(s) {\n    return s.remoteAddress;\n}\n

\n

\nThe directive was made obsolete in version\n0.4.0\nand was removed in version\n0.7.1.\nThe js_import directive should be used instead.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n js_load_stream_native_module path [as name];
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n main
\n

This directive appeared in version 0.9.5.\n

\nLoads a native module\n(shared library) for use in Stream JavaScript code.\nThe directive is\nQuickJS-only\nand is not available when using the njs built-in JavaScript engine.\n

\nThe path parameter\nspecifies the absolute path to the shared library file.\nThe optional as name parameter\nprovides an alias name for importing the module in JavaScript code.\nIf not specified, the module can be imported using its filename.\n

\nExample:\n

\njs_load_stream_native_module /path/to/mylib.so;\njs_load_stream_native_module /path/to/other.so as myalias;\n\nstream {\n    js_import main.js;\n    # ... rest of stream configuration\n}\n

\nIn JavaScript code:\n

\n// Import by filename\nimport * as mylib from 'mylib.so';\n\n// Import by alias\nimport * as myalias from 'myalias';\n\n// Use exported functions\nlet result = mylib.add(5, 10);\n

\n

\n

\nFor security reasons, this directive is only allowed\nin the main configuration context.\nNative modules run with full process privileges;\nuse absolute paths and ensure proper code review.\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n js_path \npath;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n stream, server
\n

This directive appeared in version 0.3.0.\n

\nSets an additional path for njs modules.\n

\n

\nThe directive can be specified on the\nserver level\nsince 0.7.7.\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n js_periodic module.function\n [interval=time]\n [jitter=number]\n [worker_affinity=mask];
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n server
\n

This directive appeared in version 0.8.1.\n

\nSpecifies a content handler to run at regular interval.\nThe handler receives a\nsession object\nas its first argument,\nit also has access to global objects such as\nngx.\n

\nThe optional interval parameter\nsets the interval between two consecutive runs,\nby default, 5 seconds.\n

\nThe optional jitter parameter sets the time within which\nthe location content handler will be randomly delayed,\nby default, there is no delay.\n

\nBy default, the js_handler is executed on worker process 0.\nThe optional worker_affinity parameter\nallows specifying particular worker processes\nwhere the location content handler should be executed.\nEach worker process set is represented by a bitmask of allowed worker processes.\nThe all mask allows the handler to be executed\nin all worker processes.\n

\nExample:\n

\nexample.conf:\n\nlocation @periodics {\n    # to be run at 1 minute intervals in worker process 0\n    js_periodic main.handler interval=60s;\n\n    # to be run at 1 minute intervals in all worker processes\n    js_periodic main.handler interval=60s worker_affinity=all;\n\n    # to be run at 1 minute intervals in worker processes 1 and 3\n    js_periodic main.handler interval=60s worker_affinity=0101;\n\n    resolver 10.0.0.1;\n    js_fetch_trusted_certificate /path/to/ISRG_Root_X1.pem;\n}\n\nexample.js:\n\nasync function handler(s) {\n    let reply = await ngx.fetch('https://nginx.org/en/docs/njs/');\n    let body = await reply.text();\n\n    ngx.log(ngx.INFO, body);\n}\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n js_preload_object name.json |\nname from file.json;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n stream, server
\n

This directive appeared in version 0.7.8.\n

\nPreloads an\nimmutable object\nat configure time.\nThe name is used as a name of the global variable\nthough which the object is available in njs code.\nIf the name is not specified,\nthe file name will be used instead.\n

\njs_preload_object map.json;\n

\nHere, the map is used as a name\nwhile accessing the preloaded object.\n

\nSeveral js_preload_object directives can be specified.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n js_preread module.function;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n stream, server
\n

\nSets an njs function which will be called at the\npreread phase.\nSince 0.4.0,\na module function can be referenced.\n

\nThe function is called once\nat the moment when the stream session reaches the\npreread phase\nfor the first time.\nThe function is called with the following arguments:\n\n

\n
s
\n
\nthe Stream Session object\n
\n\n

\n

\nAt this phase, it is possible to perform initialization\nor register a callback with\nthe s.on()\nmethod\nfor each incoming data chunk until one of the following methods are called:\ns.allow(),\ns.decline(),\ns.done().\nWhen one of these methods is called,\nthe stream session switches to the\nnext phase\nand all current\ns.on()\ncallbacks are dropped.\n

\n

\nAs the js_preread handler\nreturns its result immediately, it supports\nonly synchronous callbacks.\nThus, asynchronous callbacks such as\nngx.fetch()\nor\nsetTimeout()\nare not supported.\nNevertheless, asynchronous operations are supported in\ns.on()\ncallbacks in the\npreread phase.\nSee\nthis example for more information.\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n js_set \n $variable\n module.function\n [nocache];
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n stream, server
\n

\nSets an njs function\nfor the specified variable.\nSince 0.4.0,\na module function can be referenced.\n

\nThe function is called when\nthe variable is referenced for the first time for a given request.\nThe exact moment depends on a\nphase\nat which the variable is referenced.\nThis can be used to perform some logic\nnot related to variable evaluation.\nFor example, if the variable is referenced only in the\nlog_format directive,\nits handler will not be executed until the log phase.\nThis handler can be used to do some cleanup\nright before the request is freed.\n

\nSince 0.8.6, when\noptional argument nocache is provided the handler\nis called every time it is referenced.\nDue to current limitations\nof the rewrite module,\nwhen a nocache variable is referenced by the\nset directive\nits handler should always return a fixed-length value.\n

\n

\nAs the js_set handler\nreturns its result immediately, it supports\nonly synchronous callbacks.\nThus, asynchronous callbacks such as\nngx.fetch()\nor\nsetTimeout()\nare not supported.\n

\n

\n

\nThe directive can be specified on the\nserver level\nsince 0.7.7.\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n js_shared_dict_zone \n zone=name:size\n [timeout=time]\n [type=string|number]\n [evict]\n [state=file];
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n stream
\n

This directive appeared in version 0.8.0.\n

\nSets the name and size of the shared memory zone\nthat keeps the\nkey-value dictionary\nshared between worker processes.\n

\nBy default the shared dictionary uses a string as a key and a value.\nThe optional type parameter\nallows redefining the value type to number.\n

\nThe optional timeout parameter sets\nthe time in milliseconds\nafter which all shared dictionary entries are removed from the zone.\nIf some entries require a different removal time, it can be set\nwith the timeout argument of the\nadd,\nincr, and\nset\nmethods\n(0.8.5).\n

\nThe optional evict parameter removes the oldest\nkey-value pair when the zone storage is exhausted.\n

\nThe optional state parameter specifies a file\nthat keeps the shared dictionary state\nin JSON format and makes it persistent across nginx restarts\n(0.9.1).\n

\nExample:\n

\nexample.conf:\n    # Creates a 1Mb dictionary with string values,\n    # removes key-value pairs after 60 seconds of inactivity:\n    js_shared_dict_zone zone=foo:1M timeout=60s;\n\n    # Creates a 512Kb dictionary with string values,\n    # forcibly removes oldest key-value pairs when the zone is exhausted:\n    js_shared_dict_zone zone=bar:512K timeout=30s evict;\n\n    # Creates a 32Kb permanent dictionary with number values:\n    js_shared_dict_zone zone=num:32k type=number;\n\n    # Creates a 1Mb dictionary with string values and persistent state:\n    js_shared_dict_zone zone=persistent:1M state=/tmp/dict.json;\n\nexample.js:\n    function get(r) {\n        r.return(200, ngx.shared.foo.get(r.args.key));\n    }\n\n    function set(r) {\n        r.return(200, ngx.shared.foo.set(r.args.key, r.args.value));\n    }\n\n    function del(r) {\n        r.return(200, ngx.shared.bar.delete(r.args.key));\n    }\n\n    function increment(r) {\n        r.return(200, ngx.shared.num.incr(r.args.key, 2));\n    }\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n js_var $variable [value];
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n stream, server
\n

This directive appeared in version 0.5.3.\n

\nDeclares\na writable\nvariable.\nThe value can contain text, variables, and their combination.\n

\n

\nThe directive can be specified on the\nserver level\nsince 0.7.7.\n

\n

\n\n\n

Session Object Properties

\nEach stream njs handler receives one argument, a stream session\nobject.\n

\n\n
\n", "encoding": "utf-8"} +{"path": "en\\docs\\stream\\ngx_stream_keyval_module.html", "extension": ".html", "size_bytes": 8708, "content": "\nModule ngx_stream_keyval_module
\n\nPlanning your ingress-nginx migration? Start here:\nkubernetes.nginx.org.\n\n

Module ngx_stream_keyval_module

Example Configuration
Directives
     keyval
     keyval_zone
\n\n

\nThe ngx_stream_keyval_module module (1.13.7) creates variables\nwith values taken from key-value pairs managed by the\nAPI\nor a variable that can also be set with\nnjs.\n

\n

\nThis module is available as part of our\ncommercial subscription.\n

\n

\n\n\n

Example Configuration

\n

\nhttp {\n\n    server {\n        ...\n        location /api {\n            api write=on;\n        }\n    }\n}\n\nstream {\n\n    keyval_zone zone=one:32k state=/var/lib/nginx/state/one.keyval;\n    keyval      $ssl_server_name $name zone=one;\n\n    server {\n        listen              12345 ssl;\n        proxy_pass          $name;\n        ssl_certificate     /usr/local/nginx/conf/cert.pem;\n        ssl_certificate_key /usr/local/nginx/conf/cert.key;\n    }\n}\n

\n

\n\n\n

Directives

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n keyval \n key\n $variable\n zone=name;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n stream
\n

\nCreates a new $variable whose value\nis looked up by the key in the key-value database.\nMatching rules are defined by the\ntype parameter of the\nkeyval_zone directive.\nThe database is stored in a shared memory zone\nspecified by the zone parameter.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n keyval_zone \n zone=name:size\n [state=file]\n [timeout=time]\n [type=string|ip|prefix]\n [sync];
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n stream
\n

\nSets the name and size of the shared memory zone\nthat keeps the key-value database.\nKey-value pairs are managed by the\nAPI.\n

\nThe optional state parameter specifies a file\nthat keeps the current state of the key-value database in the JSON format\nand makes it persistent across nginx restarts.\nChanging the file content directly should be avoided.\n

\nExamples:\n

\nkeyval_zone zone=one:32k state=/var/lib/nginx/state/one.keyval; # path for Linux\nkeyval_zone zone=one:32k state=/var/db/nginx/state/one.keyval;  # path for FreeBSD\n

\n

\nThe optional timeout parameter (1.15.0) sets\nthe time after which key-value pairs are removed from the zone.\n

\nThe optional type parameter (1.17.1) activates\nan extra index optimized for matching the key of a certain type\nand defines matching rules when evaluating\na keyval $variable.\n

\nThe index is stored in the same shared memory zone\nand thus requires additional storage.\n

\n\n

\n\n
type=string
\n
\ndefault, no index is enabled;\nvariable lookup is performed using exact match\nof the record key and a search key\n
\n\n
type=ip
\n
\nthe search key is the textual representation of IPv4 or IPv6 address\nor CIDR range;\nto match a record key, the search key must belong to a subnet\nspecified by a record key or exactly match an IP address\n
\n\n
type=prefix
\n
\nvariable lookup is performed using prefix match\nof a record key and a search key (1.17.5);\nto match a record key, the record key must be a prefix of the search key\n
\n\n

\n

\nThe optional sync parameter (1.15.0) enables\nsynchronization\nof the shared memory zone.\nThe synchronization requires the\ntimeout parameter to be set.\n

\nIf the synchronization is enabled, removal of key-value pairs (no matter\none\nor\nall)\nwill be performed only on a target cluster node.\nThe same key-value pairs on other cluster nodes\nwill be removed upon timeout.\n

\n

\n\n
\n", "encoding": "utf-8"} +{"path": "en\\docs\\stream\\ngx_stream_limit_conn_module.html", "extension": ".html", "size_bytes": 9572, "content": "\nModule ngx_stream_limit_conn_module
\n\nPlanning your ingress-nginx migration? Start here:\nkubernetes.nginx.org.\n\n

Module ngx_stream_limit_conn_module

Example Configuration
Directives
     limit_conn
     limit_conn_dry_run
     limit_conn_log_level
     limit_conn_zone
Embedded Variables
\n\n

\nThe ngx_stream_limit_conn_module module (1.9.3) is used to\nlimit the number of connections per the defined key, in\nparticular, the number of connections from a single IP address.\n

\n\n\n

Example Configuration

\n

\nstream {\n    limit_conn_zone $binary_remote_addr zone=addr:10m;\n\n    ...\n\n    server {\n\n        ...\n\n        limit_conn           addr 1;\n        limit_conn_log_level error;\n    }\n}\n

\n

\n\n\n

Directives

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n limit_conn zone number;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n stream, server
\n

\nSets the shared memory zone\nand the maximum allowed number of connections for a given key value.\nWhen this limit is exceeded, the server will close the connection.\nFor example, the directives\n

\nlimit_conn_zone $binary_remote_addr zone=addr:10m;\n\nserver {\n    ...\n    limit_conn addr 1;\n}\n

\nallow only one connection per an IP address at a time.\n

\nWhen several limit_conn directives are specified,\nany configured limit will apply.\n

\nThese directives are inherited from the previous configuration level\nif and only if there are no limit_conn directives\ndefined on the current level.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n limit_conn_dry_run on | off;
\n
\n Default:\n \n
limit_conn_dry_run off;
\n
\n Context:\n \n stream, server
\n

This directive appeared in version 1.17.6.\n

\nEnables the dry run mode.\nIn this mode, the number of connections is not limited, however,\nin the shared memory zone, the number of excessive connections is accounted\nas usual.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n limit_conn_log_level \ninfo |\nnotice |\nwarn |\nerror;
\n
\n Default:\n \n
limit_conn_log_level error;
\n
\n Context:\n \n stream, server
\n

\nSets the desired logging level for cases when the server\nlimits the number of connections.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n limit_conn_zone \n key\n zone=name:size;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n stream
\n

\nSets parameters for a shared memory zone\nthat will keep states for various keys.\nIn particular, the state includes the current number of connections.\nThe key can contain text, variables,\nand their combinations (1.11.2).\nConnections with an empty key value are not accounted.\nUsage example:\n

\nlimit_conn_zone $binary_remote_addr zone=addr:10m;\n

\nHere, the key is a client IP address set by the\n$binary_remote_addr variable.\nThe size of $binary_remote_addr\nis 4 bytes for IPv4 addresses or 16 bytes for IPv6 addresses.\nThe stored state always occupies 32 or 64 bytes\non 32-bit platforms and 64 bytes on 64-bit platforms.\nOne megabyte zone can keep about 32 thousand 32-byte states\nor about 16 thousand 64-byte states.\nIf the zone storage is exhausted, the server will close the connection.\n

\n

\nAdditionally, as part of our\ncommercial subscription,\nthe\nstatus information\nfor each such shared memory zone can be\nobtained or\nreset\nwith the API since 1.17.7.\n

\n

\n\n\n

Embedded Variables

\n

\n\n
$limit_conn_status
\n
\nkeeps the result of limiting the number of connections (1.17.6):\nPASSED,\nREJECTED, or\nREJECTED_DRY_RUN\n
\n\n

\n

\n\n
\n", "encoding": "utf-8"} +{"path": "en\\docs\\stream\\ngx_stream_log_module.html", "extension": ".html", "size_bytes": 11445, "content": "\nModule ngx_stream_log_module
\n\nPlanning your ingress-nginx migration? Start here:\nkubernetes.nginx.org.\n\n

Module ngx_stream_log_module

Example Configuration
Directives
     access_log
     log_format
     open_log_file_cache
\n\n

\nThe ngx_stream_log_module module (1.11.4) writes session logs\nin the specified format.\n

\n\n\n

Example Configuration

\n

\nlog_format basic '$remote_addr [$time_local] '\n                 '$protocol $status $bytes_sent $bytes_received '\n                 '$session_time';\n\naccess_log /spool/logs/nginx-access.log basic buffer=32k;\n

\n

\n\n\n

Directives

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n access_log \n path\n format\n [buffer=size]\n [gzip[=level]]\n [flush=time]\n [if=condition];
access_log off;
\n
\n Default:\n \n
access_log off;
\n
\n Context:\n \n stream, server
\n

\nSets the path, format,\nand configuration for a buffered log write.\nSeveral logs can be specified on the same configuration level.\nLogging to syslog\ncan be configured by specifying\nthe “syslog:” prefix in the first parameter.\nThe special value off cancels all\naccess_log directives on the current level.\n

\nIf either the buffer or gzip\nparameter is used, writes to log will be buffered.\n

\nThe buffer size must not exceed the size of an atomic write to a disk file.\nFor FreeBSD this size is unlimited.\n

\n

\nWhen buffering is enabled, the data will be written to the file:\n

\n

\nIf the gzip parameter is used, then the buffered data will\nbe compressed before writing to the file.\nThe compression level can be set between 1 (fastest, less compression)\nand 9 (slowest, best compression).\nBy default, the buffer size is equal to 64K bytes, and the compression level\nis set to 1.\nSince the data is compressed in atomic blocks, the log file can be decompressed\nor read by “zcat” at any time.\n

\nExample:\n

\naccess_log /path/to/log.gz basic gzip flush=5m;\n

\n

\n

\nFor gzip compression to work, nginx must be built with the zlib library.\n

\n

\nThe file path can contain variables,\nbut such logs have some constraints:\n

\n

\nThe if parameter enables conditional logging.\nA session will not be logged if the condition evaluates to “0”\nor an empty string.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n log_format \n name\n [escape=default|json|none]\n string ...;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n stream
\n

\nSpecifies the log format, for example:\n

\nlog_format proxy '$remote_addr [$time_local] '\n                 '$protocol $status $bytes_sent $bytes_received '\n                 '$session_time \"$upstream_addr\" '\n                 '\"$upstream_bytes_sent\" \"$upstream_bytes_received\" \"$upstream_connect_time\"';\n

\n

\nThe escape parameter (1.11.8) allows setting\njson or default characters escaping\nin variables, by default, default escaping is used.\nThe none parameter (1.13.10) disables escaping.\n

\nFor default escaping,\ncharacters “\"”, “\\”,\nand other characters with values less than 32 or above 126\nare escaped as “\\xXX”.\nIf the variable value is not found,\na hyphen (“-”) will be logged.\n

\nFor json escaping,\nall characters not allowed\nin JSON strings\nwill be escaped:\ncharacters “\"” and\n“\\” are escaped as\n“\\\"” and “\\\\”,\ncharacters with values less than 32 are escaped as\n“\\n”,\n“\\r”,\n“\\t”,\n“\\b”,\n“\\f”, or\n“\\u00XX”.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n open_log_file_cache \nmax=N\n[inactive=time]\n[min_uses=N]\n[valid=time];
open_log_file_cache off;
\n
\n Default:\n \n
open_log_file_cache off;
\n
\n Context:\n \n stream, server
\n

\nDefines a cache that stores the file descriptors of frequently used logs\nwhose names contain variables.\nThe directive has the following parameters:\n

\n\n
max
\n
\nsets the maximum number of descriptors in a cache;\nif the cache becomes full the least recently used (LRU)\ndescriptors are closed\n
\n\n
inactive
\n
\nsets the time after which the cached descriptor is closed\nif there were no access during this time;\nby default, 10 seconds\n
\n\n
min_uses
\n
\nsets the minimum number of file uses during the time\ndefined by the inactive parameter\nto let the descriptor stay open in a cache;\nby default, 1\n
\n\n
valid
\n
\nsets the time after which it should be checked that the file\nstill exists with the same name; by default, 60 seconds\n
\n\n
off
\n
\ndisables caching\n
\n\n

\n

\nUsage example:\n

\nopen_log_file_cache max=1000 inactive=20s valid=1m min_uses=2;\n

\n

\n\n
\n", "encoding": "utf-8"} +{"path": "en\\docs\\stream\\ngx_stream_map_module.html", "extension": ".html", "size_bytes": 8722, "content": "\nModule ngx_stream_map_module
\n\nPlanning your ingress-nginx migration? Start here:\nkubernetes.nginx.org.\n\n

Module ngx_stream_map_module

Example Configuration
Directives
     map
     map_hash_bucket_size
     map_hash_max_size
\n\n

\nThe ngx_stream_map_module module (1.11.2) creates variables\nwhose values depend on values of other variables.\n

\n\n\n

Example Configuration

\n

\nmap $remote_addr $limit {\n    127.0.0.1    \"\";\n    default      $binary_remote_addr;\n}\n\nlimit_conn_zone $limit zone=addr:10m;\nlimit_conn addr 1;\n

\n

\n\n\n

Directives

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n map \n string\n $variable { ... }
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n stream
\n

\nCreates a new variable whose value\ndepends on values of one or more of the source variables\nspecified in the first parameter.\n

\n

\nSince variables are evaluated only when they are used, the mere declaration\neven of a large number of “map” variables\ndoes not add any extra costs to connection processing.\n

\n

\nParameters inside the map block specify a mapping\nbetween source and resulting values.\n

\nSource values are specified as strings or regular expressions.\n

\nStrings are matched ignoring the case.\n

\nA regular expression should either start from the “~”\nsymbol for a case-sensitive matching, or from the “~*”\nsymbols for case-insensitive matching.\nA regular expression can contain named and positional captures\nthat can later be used in other directives along with the\nresulting variable.\n

\nIf a source value matches one of the names of special parameters\ndescribed below, it should be prefixed with the “\\” symbol.\n

\nThe resulting value can contain text,\nvariable, and their combination.\n

\nThe following special parameters are also supported:\n

\n
default value
\n
\nsets the resulting value if the source value matches none\nof the specified variants.\nWhen default is not specified, the default\nresulting value will be an empty string.\n
\n\n
hostnames
\n
\nindicates that source values can be hostnames with a prefix or suffix mask:\n
\n*.example.com 1;\nexample.*     1;\n
\nThe following two records\n
\nexample.com   1;\n*.example.com 1;\n
\ncan be combined:\n
\n.example.com  1;\n
\nThis parameter should be specified before the list of values.\n
\n\n
include file
\n
\nincludes a file with values.\nThere can be several inclusions.\n
\n\n
volatile
\n
\nindicates that the variable is not cacheable (1.11.7).\n
\n\n

\n

\nThe search is performed in the following order of priority\nand terminates on the first matching variant:\n

    \n\n
  1. \nthe string value without a mask\n
  2. \n\n
  3. \nthe longest string value with a prefix mask,\ne.g. “*.example.com”\n
  4. \n\n
  5. \nthe longest string value with a suffix mask,\ne.g. “mail.*”\n
  6. \n\n
  7. \nthe first matching regular expression\n(in order of appearance in the configuration file)\n
  8. \n\n
  9. \nthe default value\n
  10. \n\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n map_hash_bucket_size size;
\n
\n Default:\n \n
map_hash_bucket_size 32|64|128;
\n
\n Context:\n \n stream
\n

\nSets the bucket size for the map variables hash tables.\nDefault value depends on the processor’s cache line size.\nThe details of setting up hash tables are provided in a separate\ndocument.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n map_hash_max_size size;
\n
\n Default:\n \n
map_hash_max_size 2048;
\n
\n Context:\n \n stream
\n

\nSets the maximum size of the map variables\nhash tables.\nThe details of setting up hash tables are provided in a separate\ndocument.\n

\n\n
\n", "encoding": "utf-8"} +{"path": "en\\docs\\stream\\ngx_stream_mqtt_filter_module.html", "extension": ".html", "size_bytes": 8039, "content": "\nModule ngx_stream_mqtt_filter_module
\n\nPlanning your ingress-nginx migration? Start here:\nkubernetes.nginx.org.\n\n

Module ngx_stream_mqtt_filter_module

Example Configuration
Directives
     mqtt
     mqtt_buffers
     mqtt_rewrite_buffer_size
     mqtt_set_connect
\n\n

\nThe ngx_stream_mqtt_filter_module module (1.23.4) provides\nsupport for Message Queuing Telemetry Transport protocol (MQTT) versions\n3.1.1\nand\n5.0.\n

\n

\nThis module is available as part of our\ncommercial subscription.\n

\n

\n\n\n

Example Configuration

\n

\nlisten            127.0.0.1:18883;\nproxy_pass        backend;\nproxy_buffer_size 16k;\n\nmqtt             on;\nmqtt_set_connect clientid \"$client\";\nmqtt_set_connect username \"$name\";\n

\n

\n\n\n

Directives

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n mqtt on | off;
\n
\n Default:\n \n
mqtt off;
\n
\n Context:\n \n stream, server
\n

\nEnables the MQTT protocol for the given virtual server.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n mqtt_buffers number size;
\n
\n Default:\n \n
mqtt_buffers 100 1k;
\n
\n Context:\n \n stream, server
\n

This directive appeared in version 1.25.1.\n

\nSets the number and size of the buffers\nused for handling MQTT messages,\nfor a single connection.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n mqtt_rewrite_buffer_size size;
\n
\n Default:\n \n
mqtt_rewrite_buffer_size 4k|8k;
\n
\n Context:\n \n server
\n

\n

\nThis directive is obsolete since version 1.25.1.\nThe mqtt_buffers\ndirective should be used instead.\n

\n

\nSets the size of the buffer\nused for writing a modified message.\nBy default, the buffer size is equal to one memory page.\nThis is either 4K or 8K, depending on a platform.\nIt can be made smaller, however.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n mqtt_set_connect field value;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n server
\n

\nSets the message field\nto the given value for CONNECT message.\nThe following fields are supported:\nclientid,\nusername, and\npassword.\nThe value can contain text, variables, and their combination.\n

\nSeveral mqtt_set_connect directives\ncan be specified on the same level:\n

\nmqtt_set_connect clientid \"$client\";\nmqtt_set_connect username \"$name\";\n

\n

\n\n
\n", "encoding": "utf-8"} +{"path": "en\\docs\\stream\\ngx_stream_mqtt_preread_module.html", "extension": ".html", "size_bytes": 4831, "content": "\nModule ngx_stream_mqtt_preread_module
\n\nPlanning your ingress-nginx migration? Start here:\nkubernetes.nginx.org.\n\n

Module ngx_stream_mqtt_preread_module

Example Configuration
Directives
     mqtt_preread
Embedded Variables
\n\n

\nThe ngx_stream_mqtt_preread_module module (1.23.4) allows\nextracting information from the CONNECT message\nof the Message Queuing Telemetry Transport protocol (MQTT) versions\n3.1.1\nand\n5.0,\nfor example, a username or a client ID.\n

\n

\nThis module is available as part of our\ncommercial subscription.\n

\n

\n\n\n

Example Configuration

\n

\nmqtt_preread on;\nreturn       $mqtt_preread_clientid;\n

\n

\n\n\n

Directives

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n mqtt_preread on | off;
\n
\n Default:\n \n
mqtt_preread off;
\n
\n Context:\n \n stream, server
\n

\nEnables extracting information from the MQTT CONNECT message at\nthe preread phase.\n

\n\n\n

Embedded Variables

\n

\n\n
$mqtt_preread_clientid
\n
\nthe clientid value from the CONNECT message\n
\n\n
$mqtt_preread_username
\n
\nthe username value from the CONNECT message\n
\n\n

\n

\n\n
\n", "encoding": "utf-8"} +{"path": "en\\docs\\stream\\ngx_stream_num_map_module.html", "extension": ".html", "size_bytes": 5011, "content": "\nModule ngx_stream_num_map_module
\n\nPlanning your ingress-nginx migration? Start here:\nkubernetes.nginx.org.\n\n

Module ngx_stream_num_map_module

Example Configuration
Directives
     num_map
\n\n

\nThe ngx_stream_num_map_module module (1.29.3)\ncreates variables whose values depend on numeric values\nor numeric value ranges.\n

\n

\nThis module is available as part of our\ncommercial subscription.\n

\n

\n\n\n

Example Configuration

\n

\nnum_map $remote_port $port_allow {\n    default    0;\n\n    80         1;\n    443        1;\n    <=1023     0;\n    8080-8090  1;\n}\n

\n

\n\n\n

Directives

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n num_map \n [$number]\n $variable { ... }
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n stream
\n

\nDescribes how the values of the specified variable depend on numeric values\nor numeric value ranges.\n

\n

\nSince variables are evaluated only when used, the mere existence\nof even a large number of declared “num_map” variables\ndoes not cause any extra costs for connection processing.\n

\n

\nParameters inside the num_map block specify a mapping\nbetween source and resulting values.\n

\nSource values are specified as numbers or as numeric ranges.\n

\nThe following special parameters are also supported:\n

\n\n
default
\n
\nsets the resulting value if the source value matches none\nof the specified variants.\nWhen default is not specified, the default\nresulting value will be an empty string.\n
\n\n
include
\n
\nincludes a file with values.\nThere can be several inclusions.\n
\n\n
volatile
\n
\nindicates that the variable is not cacheable.\n
\n\n

\n

\n\n
\n", "encoding": "utf-8"} +{"path": "en\\docs\\stream\\ngx_stream_pass_module.html", "extension": ".html", "size_bytes": 4575, "content": "\nModule ngx_stream_pass_module
\n\nPlanning your ingress-nginx migration? Start here:\nkubernetes.nginx.org.\n\n

Module ngx_stream_pass_module

Example Configuration
Directives
     pass
\n\n

\nThe ngx_stream_pass_module module (1.25.5) allows\npassing the accepted connection directly to any configured listening socket\nin http, stream, mail,\nand other similar modules.\n

\n\n\n

Example Configuration

\n

\nhttp {\n    server {\n        listen 8000;\n\n        location / {\n            root html;\n        }\n    }\n}\n\nstream {\n    server {\n        listen 12345 ssl;\n\n        ssl_certificate     domain.crt;\n        ssl_certificate_key domain.key;\n\n        pass 127.0.0.1:8000;\n    }\n}\n

\nIn the example,\nafter terminating SSL/TLS in the stream module\nthe connection is passed to the http module.\n

\n\n\n

Directives

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n pass address;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n server
\n

\nSets server address to pass client connection to.\nThe address can be specified as an IP address\nand a port:\n

\npass 127.0.0.1:12345;\n

\nor as a UNIX-domain socket path:\n

\npass unix:/tmp/stream.socket;\n

\n

\nThe address can also be specified using variables:\n

\npass $upstream;\n

\n

\n\n
\n", "encoding": "utf-8"} +{"path": "en\\docs\\stream\\ngx_stream_proxy_module.html", "extension": ".html", "size_bytes": 47833, "content": "\nModule ngx_stream_proxy_module
\n\nPlanning your ingress-nginx migration? Start here:\nkubernetes.nginx.org.\n\n

Module ngx_stream_proxy_module

Example Configuration
Directives
     proxy_bind
     proxy_bind_dynamic
     proxy_buffer_size
     proxy_connect_timeout
     proxy_download_rate
     proxy_half_close
     proxy_next_upstream
     proxy_next_upstream_timeout
     proxy_next_upstream_tries
     proxy_pass
     proxy_protocol
     proxy_requests
     proxy_responses
     proxy_session_drop
     proxy_socket_keepalive
     proxy_ssl
     proxy_ssl_alpn
     proxy_ssl_certificate
     proxy_ssl_certificate_cache
     proxy_ssl_certificate_key
     proxy_ssl_ciphers
     proxy_ssl_conf_command
     proxy_ssl_crl
     proxy_ssl_key_log
     proxy_ssl_name
     proxy_ssl_password_file
     proxy_ssl_protocols
     proxy_ssl_server_name
     proxy_ssl_session_reuse
     proxy_ssl_trusted_certificate
     proxy_ssl_verify
     proxy_ssl_verify_depth
     proxy_timeout
     proxy_upload_rate
\n\n

\nThe ngx_stream_proxy_module module (1.9.0) allows proxying\ndata streams over TCP, UDP (1.9.13), and UNIX-domain sockets.\n

\n\n\n

Example Configuration

\n

\nserver {\n    listen 127.0.0.1:12345;\n    proxy_pass 127.0.0.1:8080;\n}\n\nserver {\n    listen 12345;\n    proxy_connect_timeout 1s;\n    proxy_timeout 1m;\n    proxy_pass example.com:12345;\n}\n\nserver {\n    listen 53 udp reuseport;\n    proxy_timeout 20s;\n    proxy_pass dns.example.com:53;\n}\n\nserver {\n    listen [::1]:12345;\n    proxy_pass unix:/tmp/stream.socket;\n}\n

\n

\n\n\n

Directives

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n proxy_bind \n address\n [transparent] |\n off;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n stream, server
\n

This directive appeared in version 1.9.2.\n

\nMakes outgoing connections to a proxied server originate\nfrom the specified local IP address.\nParameter value can contain variables (1.11.2).\nThe special value off cancels the effect\nof the proxy_bind directive\ninherited from the previous configuration level, which allows the\nsystem to auto-assign the local IP address.\n

\nThe transparent parameter (1.11.0) allows\noutgoing connections to a proxied server originate\nfrom a non-local IP address,\nfor example, from a real IP address of a client:\n

\nproxy_bind $remote_addr transparent;\n

\nIn order for this parameter to work,\nit is usually necessary to run nginx worker processes with the\nsuperuser privileges.\nOn Linux it is not required (1.13.8) as if\nthe transparent parameter is specified, worker processes\ninherit the CAP_NET_RAW capability from the master process.\nIt is also necessary to configure kernel routing table\nto intercept network traffic from the proxied server.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n proxy_bind_dynamic on | off;
\n
\n Default:\n \n
proxy_bind_dynamic off;
\n
\n Context:\n \n stream, server
\n

This directive appeared in version 1.29.3.\n

\nWhen enabled, makes the bind operation\nat each connection attempt.\n

\n

\nThis directive is available as part of our\ncommercial subscription.\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n proxy_buffer_size size;
\n
\n Default:\n \n
proxy_buffer_size 16k;
\n
\n Context:\n \n stream, server
\n

This directive appeared in version 1.9.4.\n

\nSets the size of the buffer used for reading data\nfrom the proxied server.\nAlso sets the size of the buffer used for reading data\nfrom the client.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n proxy_connect_timeout time;
\n
\n Default:\n \n
proxy_connect_timeout 60s;
\n
\n Context:\n \n stream, server
\n

\nDefines a timeout for establishing a connection with a proxied server.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n proxy_download_rate rate;
\n
\n Default:\n \n
proxy_download_rate 0;
\n
\n Context:\n \n stream, server
\n

This directive appeared in version 1.9.3.\n

\nLimits the speed of reading the data from the proxied server.\nThe rate is specified in bytes per second.\nThe zero value disables rate limiting.\nThe limit is set per a connection, so if nginx simultaneously opens\ntwo connections to the proxied server,\nthe overall rate will be twice as much as the specified limit.\n

\nParameter value can contain variables (1.17.0).\nIt may be useful in cases where rate should be limited\ndepending on a certain condition:\n

\nmap $slow $rate {\n    1     4k;\n    2     8k;\n}\n\nproxy_download_rate $rate;\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n proxy_half_close on | off;
\n
\n Default:\n \n
proxy_half_close off;
\n
\n Context:\n \n stream, server
\n

This directive appeared in version 1.21.4.\n

\nEnables or disables closing\neach direction of a TCP connection independently (“TCP half-close”).\nIf enabled, proxying over TCP will be kept\nuntil both sides close the connection.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n proxy_next_upstream on | off;
\n
\n Default:\n \n
proxy_next_upstream on;
\n
\n Context:\n \n stream, server
\n

\nWhen a connection to the proxied server cannot be established, determines\nwhether a client connection will be passed to the next server.\n

\nPassing a connection to the next server can be limited by\nthe number of tries\nand by time.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n proxy_next_upstream_timeout time;
\n
\n Default:\n \n
proxy_next_upstream_timeout 0;
\n
\n Context:\n \n stream, server
\n

\nLimits the time allowed to pass a connection to the\nnext server.\nThe 0 value turns off this limitation.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n proxy_next_upstream_tries number;
\n
\n Default:\n \n
proxy_next_upstream_tries 0;
\n
\n Context:\n \n stream, server
\n

\nLimits the number of possible tries for passing a connection to the\nnext server.\nThe 0 value turns off this limitation.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n proxy_pass address;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n server
\n

\nSets the address of a proxied server.\nThe address can be specified as a domain name or IP address,\nand a port:\n

\nproxy_pass localhost:12345;\n

\nor as a UNIX-domain socket path:\n

\nproxy_pass unix:/tmp/stream.socket;\n

\n

\nIf a domain name resolves to several addresses, all of them will be\nused in a round-robin fashion.\nIn addition, an address can be specified as a\nserver group.\n

\nThe address can also be specified using variables (1.11.3):\n

\nproxy_pass $upstream;\n

\nIn this case, the server name is searched among the described\nserver groups,\nand, if not found, is determined using a\nresolver.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n proxy_protocol on | off;
\n
\n Default:\n \n
proxy_protocol off;
\n
\n Context:\n \n stream, server
\n

This directive appeared in version 1.9.2.\n

\nEnables the\nPROXY\nprotocol for connections to a proxied server.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n proxy_requests number;
\n
\n Default:\n \n
proxy_requests 0;
\n
\n Context:\n \n stream, server
\n

This directive appeared in version 1.15.7.\n

\nSets the number of client datagrams at which\nbinding between a client and existing UDP stream session is dropped.\nAfter receiving the specified number of datagrams, next datagram\nfrom the same client starts a new session.\nThe session terminates when all client datagrams are transmitted\nto a proxied server and the expected number of\nresponses is received,\nor when it reaches a timeout.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n proxy_responses number;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n stream, server
\n

This directive appeared in version 1.9.13.\n

\nSets the number of datagrams expected from the proxied server\nin response to a client datagram\nif the UDP\nprotocol is used.\nThe number serves as a hint for session termination.\nBy default, the number of datagrams is not limited.\n

\nIf zero value is specified, no response is expected.\nHowever, if a response is received and the\nsession is still not finished, the response will be handled.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n proxy_session_drop on | off;
\n
\n Default:\n \n
proxy_session_drop off;
\n
\n Context:\n \n stream, server
\n

This directive appeared in version 1.15.8.\n

\nEnables terminating all sessions to a proxied server\nafter it was removed from the group or marked as permanently unavailable.\nThis can occur because of\nre-resolve\nor with the API\nDELETE\ncommand.\nA server can be marked as permanently unavailable if it is considered\nunhealthy\nor with the API\nPATCH\ncommand.\nEach session is terminated when the next\nread or write event is processed for the client or proxied server.\n

\n

\nThis directive is available as part of our\ncommercial subscription.\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n proxy_socket_keepalive on | off;
\n
\n Default:\n \n
proxy_socket_keepalive off;
\n
\n Context:\n \n stream, server
\n

This directive appeared in version 1.15.6.\n

\nConfigures the “TCP keepalive” behavior\nfor outgoing connections to a proxied server.\nBy default, the operating system’s settings are in effect for the socket.\nIf the directive is set to the value “on”, the\nSO_KEEPALIVE socket option is turned on for the socket.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n proxy_ssl on | off;
\n
\n Default:\n \n
proxy_ssl off;
\n
\n Context:\n \n stream, server
\n

\nEnables the SSL/TLS protocol for connections to a proxied server.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n proxy_ssl_alpn protocol ...;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n stream, server
\n

This directive appeared in version 1.31.0.\n

\nSpecifies the list of protocols to advertise via the\nALPN\nextension when establishing a connection with the proxied server.\nFor example:\n

\nproxy_ssl_alpn h2 http/1.1;\n

\n

\nParameter value can contain variables:\n

\nproxy_ssl_alpn $ssl_alpn_protocol;\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n proxy_ssl_certificate file;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n stream, server
\n

\nSpecifies a file with the certificate in the PEM format\nused for authentication to a proxied server.\n

\nSince version 1.21.0, variables can be used in the file name.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n proxy_ssl_certificate_cache off;
proxy_ssl_certificate_cache \n max=N\n [inactive=time]\n [valid=time];
\n
\n Default:\n \n
proxy_ssl_certificate_cache off;
\n
\n Context:\n \n stream, server
\n

This directive appeared in version 1.27.4.\n

\nDefines a cache that stores\nSSL certificates and\nsecret keys\nspecified with variables.\n

\nThe directive has the following parameters:\n

\n\n
\nmax\n
\n
\nsets the maximum number of elements in the cache;\non cache overflow the least recently used (LRU) elements are removed;\n
\n\n
\ninactive\n
\n
\ndefines a time after which an element is removed from the cache\nif it has not been accessed during this time;\nby default, it is 10 seconds;\n
\n\n
\nvalid\n
\n
\ndefines a time during which\nan element in the cache is considered valid\nand can be reused;\nby default, it is 60 seconds.\nCertificates that exceed this time will be reloaded or revalidated;\n
\n\n
\noff\n
\n
\ndisables the cache.\n
\n\n

\n

\nExample:\n

\nproxy_ssl_certificate       $proxy_ssl_server_name.crt;\nproxy_ssl_certificate_key   $proxy_ssl_server_name.key;\nproxy_ssl_certificate_cache max=1000 inactive=20s valid=1m;\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n proxy_ssl_certificate_key file;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n stream, server
\n

\nThe value\nstore:scheme:id\ncan be specified instead of the file (1.29.0),\nwhich is used to load a secret key with a specified id\nand OpenSSL provider registered URI scheme, such as\npkcs11.\n

\nSpecifies a file with the secret key in the PEM format\nused for authentication to a proxied server.\n

\nSince version 1.21.0, variables can be used in the file name.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n proxy_ssl_ciphers ciphers;
\n
\n Default:\n \n
proxy_ssl_ciphers DEFAULT;
\n
\n Context:\n \n stream, server
\n

\nSpecifies the enabled ciphers for connections to a proxied server.\nThe ciphers are specified in the format understood by the OpenSSL library.\n

\nThe full list can be viewed using the\n“openssl ciphers” command.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n proxy_ssl_conf_command name value;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n stream, server
\n

This directive appeared in version 1.19.4.\n

\nSets arbitrary OpenSSL configuration\ncommands\nwhen establishing a connection with the proxied server.\n

\nThe directive is supported when using OpenSSL 1.0.2 or higher.\n

\n

\nSeveral proxy_ssl_conf_command directives\ncan be specified on the same level.\nThese directives are inherited from the previous configuration level\nif and only if there are\nno proxy_ssl_conf_command directives\ndefined on the current level.\n

\n

\nNote that configuring OpenSSL directly\nmight result in unexpected behavior.\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n proxy_ssl_crl file;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n stream, server
\n

\nSpecifies a file with revoked certificates (CRL)\nin the PEM format used to verify\nthe certificate of the proxied server.\nWhen using intermediate certificates, their CRLs should be\nspecified in the same file.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n proxy_ssl_key_log path;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n stream, server
\n

This directive appeared in version 1.27.2.\n

\nEnables logging of proxied server connection SSL keys\nand specifies the path to the key log file.\nKeys are logged in the\nSSLKEYLOGFILE\nformat compatible with Wireshark.\n

\n

\nThis directive is available as part of our\ncommercial subscription.\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n proxy_ssl_name name;
\n
\n Default:\n \n
proxy_ssl_name host from proxy_pass;
\n
\n Context:\n \n stream, server
\n

\nAllows overriding the server name used to\nverify\nthe certificate of the proxied server and to be\npassed through SNI\nwhen establishing a connection with the proxied server.\nThe server name can also be specified using variables (1.11.3).\n

\nBy default, the host part of the proxy_pass address is used.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n proxy_ssl_password_file file;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n stream, server
\n

\nSpecifies a file with passphrases for\nsecret keys\nwhere each passphrase is specified on a separate line.\nPassphrases are tried in turn when loading the key.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n proxy_ssl_protocols \n [SSLv2]\n [SSLv3]\n [TLSv1]\n [TLSv1.1]\n [TLSv1.2]\n [TLSv1.3];
\n
\n Default:\n \n
proxy_ssl_protocols TLSv1.2 TLSv1.3;
\n
\n Context:\n \n stream, server
\n

\nEnables the specified protocols for connections to a proxied server.\n

\n

\nThe TLSv1.3 parameter is used by default\nsince 1.23.4.\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n proxy_ssl_server_name on | off;
\n
\n Default:\n \n
proxy_ssl_server_name off;
\n
\n Context:\n \n stream, server
\n

\nEnables or disables passing of the server name through\nTLS\nServer Name Indication extension (SNI, RFC 6066)\nwhen establishing a connection with the proxied server.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n proxy_ssl_session_reuse on | off;
\n
\n Default:\n \n
proxy_ssl_session_reuse on;
\n
\n Context:\n \n stream, server
\n

\nDetermines whether SSL sessions can be reused when working with\nthe proxied server.\nIf the errors\n“digest check failed”\nappear in the logs, try disabling session reuse.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n proxy_ssl_trusted_certificate file;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n stream, server
\n

\nSpecifies a file with trusted CA certificates in the PEM format\nused to verify\nthe certificate of the proxied server.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n proxy_ssl_verify on | off;
\n
\n Default:\n \n
proxy_ssl_verify off;
\n
\n Context:\n \n stream, server
\n

\nEnables or disables verification of the proxied server certificate.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n proxy_ssl_verify_depth number;
\n
\n Default:\n \n
proxy_ssl_verify_depth 1;
\n
\n Context:\n \n stream, server
\n

\nSets the verification depth in the proxied server certificates chain.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n proxy_timeout timeout;
\n
\n Default:\n \n
proxy_timeout 10m;
\n
\n Context:\n \n stream, server
\n

\nSets the timeout between two successive\nread or write operations on client or proxied server connections.\nIf no data is transmitted within this time, the connection is closed.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n proxy_upload_rate rate;
\n
\n Default:\n \n
proxy_upload_rate 0;
\n
\n Context:\n \n stream, server
\n

This directive appeared in version 1.9.3.\n

\nLimits the speed of reading the data from the client.\nThe rate is specified in bytes per second.\nThe zero value disables rate limiting.\nThe limit is set per a connection, so if the client simultaneously opens\ntwo connections,\nthe overall rate will be twice as much as the specified limit.\n

\nParameter value can contain variables (1.17.0).\nIt may be useful in cases where rate should be limited\ndepending on a certain condition:\n

\nmap $slow $rate {\n    1     4k;\n    2     8k;\n}\n\nproxy_upload_rate $rate;\n

\n

\n\n
\n", "encoding": "utf-8"} +{"path": "en\\docs\\stream\\ngx_stream_proxy_protocol_vendor_module.html", "extension": ".html", "size_bytes": 4680, "content": "\nModule ngx_stream_proxy_protocol_vendor_module
\n\nPlanning your ingress-nginx migration? Start here:\nkubernetes.nginx.org.\n\n

Module ngx_stream_proxy_protocol_vendor_module

Example Configuration
Embedded Variables
\n\n

\nThe ngx_stream_proxy_protocol_vendor_module module (1.23.3)\nallows obtaining additional information about a connection in\ncloud platforms from application-specific TLVs of the\nPROXY\nprotocol\nheader.\n

\nSupported cloud platforms:\n

\n

\nThe PROXY protocol must be previously enabled by setting the\nproxy_protocol parameter\nin the listen directive.\n

\n

\nThis module is available as part of our\ncommercial subscription.\n

\n

\n\n\n

Example Configuration

\n

\nserver {\n    listen 12345 proxy_protocol;\n    return $proxy_protocol_tlv_gcp_conn_id;\n}\n

\n

\n\n\n

Embedded Variables

\n

\n\n
$proxy_protocol_tlv_aws_vpce_id
\n
\nTLV value from the PROXY Protocol header representing the\nID\nof AWS VPC endpoint\n
\n\n
$proxy_protocol_tlv_azure_pel_id
\n
\nTLV value from the PROXY Protocol header representing the\nLinkID\nof Azure private endpoint\n
\n\n
$proxy_protocol_tlv_gcp_conn_id
\n
\nTLV value from the PROXY Protocol header representing\nGoogle Cloud PSC\nconnection ID\n
\n\n

\n

\n\n
\n", "encoding": "utf-8"} +{"path": "en\\docs\\stream\\ngx_stream_realip_module.html", "extension": ".html", "size_bytes": 4824, "content": "\nModule ngx_stream_realip_module
\n\nPlanning your ingress-nginx migration? Start here:\nkubernetes.nginx.org.\n\n

Module ngx_stream_realip_module

Example Configuration
Directives
     set_real_ip_from
Embedded Variables
\n\n

\nThe ngx_stream_realip_module module is used\nto change the client address and port\nto the ones sent in the PROXY protocol header (1.11.4).\nThe PROXY protocol must be previously enabled by setting the\nproxy_protocol parameter\nin the listen directive.\n

\nThis module is not built by default, it should be enabled with the\n--with-stream_realip_module\nconfiguration parameter.\n

\n\n\n

Example Configuration

\n

\nlisten 12345 proxy_protocol;\n\nset_real_ip_from  192.168.1.0/24;\nset_real_ip_from  192.168.2.1;\nset_real_ip_from  2001:0db8::/32;\n

\n

\n\n\n

Directives

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n set_real_ip_from \n address |\n CIDR |\n unix:;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n stream, server
\n

\nDefines trusted addresses that are known to send correct\nreplacement addresses.\nIf the special value unix: is specified,\nall UNIX-domain sockets will be trusted.\n

\n\n\n

Embedded Variables

\n

\n\n
$realip_remote_addr
\n
\nkeeps the original client address\n
\n\n
$realip_remote_port
\n
\nkeeps the original client port\n
\n\n

\n

\n\n
\n", "encoding": "utf-8"} +{"path": "en\\docs\\stream\\ngx_stream_return_module.html", "extension": ".html", "size_bytes": 3818, "content": "\nModule ngx_stream_return_module
\n\nPlanning your ingress-nginx migration? Start here:\nkubernetes.nginx.org.\n\n

Module ngx_stream_return_module

Example Configuration
Directives
     return
\n\n

\nThe ngx_stream_return_module module (1.11.2) allows\nsending a specified value to the client and then closing the connection.\n

\n\n\n

Example Configuration

\n

\nserver {\n    listen 12345;\n    return $time_iso8601;\n}\n

\n

\n\n\n

Directives

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n return value;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n server
\n

\nSpecifies a value to send to the client.\nThe value can contain text, variables, and their combination.\n

\n\n
\n", "encoding": "utf-8"} +{"path": "en\\docs\\stream\\ngx_stream_set_module.html", "extension": ".html", "size_bytes": 3808, "content": "\nModule ngx_stream_set_module
\n\nPlanning your ingress-nginx migration? Start here:\nkubernetes.nginx.org.\n\n

Module ngx_stream_set_module

Example Configuration
Directives
     set
\n\n

\nThe ngx_stream_set_module module (1.19.3) allows\nsetting a value for a variable.\n

\n\n\n

Example Configuration

\n

\nserver {\n    listen 12345;\n    set    $true 1;\n}\n

\n

\n\n\n

Directives

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n set $variable value;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n server
\n

\nSets a value for the specified variable.\nThe value can contain text, variables, and their combination.\n

\n\n
\n", "encoding": "utf-8"} +{"path": "en\\docs\\stream\\ngx_stream_split_clients_module.html", "extension": ".html", "size_bytes": 4725, "content": "\nModule ngx_stream_split_clients_module
\n\nPlanning your ingress-nginx migration? Start here:\nkubernetes.nginx.org.\n\n

Module ngx_stream_split_clients_module

Example Configuration
Directives
     split_clients
\n\n

\nThe ngx_stream_split_clients_module module (1.11.3) creates\nvariables suitable for A/B testing, also known as split testing.\n

\n\n\n

Example Configuration

\n

\nstream {\n    ...\n    split_clients \"${remote_addr}AAA\" $upstream {\n                  0.5%                feature_test1;\n                  2.0%                feature_test2;\n                  *                   production;\n    }\n\n    server {\n        ...\n        proxy_pass $upstream;\n    }\n}\n

\n

\n\n\n

Directives

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n split_clients \n string\n $variable { ... }
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n stream
\n

\nCreates a variable for A/B testing, for example:\n

\nsplit_clients \"${remote_addr}AAA\" $variant {\n               0.5%               .one;\n               2.0%               .two;\n               *                  \"\";\n}\n

\nThe value of the original string is hashed using MurmurHash2.\nIn the example given, hash values from 0 to 21474835 (0.5%)\ncorrespond to the\nvalue \".one\" of the $variant variable,\nhash values from 21474836 to 107374180 (2%) correspond to\nthe value \".two\",\nand hash values from 107374181 to 4294967295 correspond to\nthe value \"\" (an empty string).\n

\n\n
\n", "encoding": "utf-8"} +{"path": "en\\docs\\stream\\ngx_stream_ssl_module.html", "extension": ".html", "size_bytes": 60056, "content": "\nModule ngx_stream_ssl_module
\n\nPlanning your ingress-nginx migration? Start here:\nkubernetes.nginx.org.\n\n

Module ngx_stream_ssl_module

Example Configuration
Directives
     ssl_alpn
     ssl_certificate
     ssl_certificate_cache
     ssl_certificate_compression
     ssl_certificate_key
     ssl_ciphers
     ssl_client_certificate
     ssl_conf_command
     ssl_crl
     ssl_dhparam
     ssl_ecdh_curve
     ssl_ech_file
     ssl_handshake_timeout
     ssl_key_log
     ssl_ocsp
     ssl_ocsp_cache
     ssl_ocsp_responder
     ssl_password_file
     ssl_prefer_server_ciphers
     ssl_protocols
     ssl_reject_handshake
     ssl_session_cache
     ssl_session_ticket_key
     ssl_session_tickets
     ssl_session_timeout
     ssl_stapling
     ssl_stapling_file
     ssl_stapling_responder
     ssl_stapling_verify
     ssl_trusted_certificate
     ssl_verify_client
     ssl_verify_depth
Embedded Variables
\n\n

\nThe ngx_stream_ssl_module module (1.9.0)\nprovides the necessary support for a stream proxy server to work with\nthe SSL/TLS protocol.\n

\nThis module is not built by default, it should be enabled with the\n--with-stream_ssl_module\nconfiguration parameter.\n

\nThis module requires the\nOpenSSL library.\n

\n

\n\n\n

Example Configuration

\nTo reduce the processor load, it is recommended to\n

\n\n

\nworker_processes auto;\n\nstream {\n\n    ...\n\n    server {\n        listen              12345 ssl;\n\n        ssl_protocols       TLSv1.2 TLSv1.3;\n        ssl_ciphers         AES128-SHA:AES256-SHA:RC4-SHA:DES-CBC3-SHA:RC4-MD5;\n        ssl_certificate     /usr/local/nginx/conf/cert.pem;\n        ssl_certificate_key /usr/local/nginx/conf/cert.key;\n        ssl_session_cache   shared:SSL:10m;\n        ssl_session_timeout 10m;\n\n        ...\n    }\n

\n

\n\n\n

Directives

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n ssl_alpn protocol ...;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n stream, server
\n

This directive appeared in version 1.21.4.\n

\nSpecifies the list of supported\nALPN protocols.\nOne of the protocols must be\nnegotiated if the client uses ALPN:\n

\nmap $ssl_alpn_protocol $proxy {\n    h2                127.0.0.1:8001;\n    http/1.1          127.0.0.1:8002;\n}\n\nserver {\n    listen      12346;\n    proxy_pass  $proxy;\n    ssl_alpn    h2 http/1.1;\n}\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n ssl_certificate file;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n stream, server
\n

\nSpecifies a file with the certificate in the PEM format\nfor the given virtual server.\nIf intermediate certificates should be specified in addition to a primary\ncertificate, they should be specified in the same file in the following\norder: the primary certificate comes first, then the intermediate certificates.\nA secret key in the PEM format may be placed in the same file.\n

\nSince version 1.11.0,\nthis directive can be specified multiple times\nto load certificates of different types, for example, RSA and ECDSA:\n

\nserver {\n    listen              12345 ssl;\n\n    ssl_certificate     example.com.rsa.crt;\n    ssl_certificate_key example.com.rsa.key;\n\n    ssl_certificate     example.com.ecdsa.crt;\n    ssl_certificate_key example.com.ecdsa.key;\n\n    ...\n}\n

\n

\nOnly OpenSSL 1.0.2 or higher supports separate\ncertificate\nchains\nfor different certificates.\nWith older versions, only one certificate chain can be used.\n

\n

\nSince version 1.15.9, variables can be used in the file name\nwhen using OpenSSL 1.0.2 or higher:\n

\nssl_certificate     $ssl_server_name.crt;\nssl_certificate_key $ssl_server_name.key;\n

\nNote that using variables implies that\na certificate will be loaded for each SSL handshake,\nand this may have a negative impact on performance.\n

\nThe value\ndata:$variable\ncan be specified instead of the file (1.15.10),\nwhich loads a certificate from a variable\nwithout using intermediate files.\nNote that inappropriate use of this syntax may have its security implications,\nsuch as writing secret key data to\nerror log.\n

\nIt should be kept in mind that due to the SSL/TLS protocol limitations,\nfor maximum interoperability with clients that do not use\nSNI,\nvirtual servers with different certificates should listen on\ndifferent\nIP addresses.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n ssl_certificate_cache off;
ssl_certificate_cache \n max=N\n [inactive=time]\n [valid=time];
\n
\n Default:\n \n
ssl_certificate_cache off;
\n
\n Context:\n \n stream, server
\n

This directive appeared in version 1.27.4.\n

\nDefines a cache that stores\nSSL certificates and\nsecret keys\nspecified with variables.\n

\nThe directive has the following parameters:\n

\n\n
\nmax\n
\n
\nsets the maximum number of elements in the cache;\non cache overflow the least recently used (LRU) elements are removed;\n
\n\n
\ninactive\n
\n
\ndefines a time after which an element is removed from the cache\nif it has not been accessed during this time;\nby default, it is 10 seconds;\n
\n\n
\nvalid\n
\n
\ndefines a time during which\nan element in the cache is considered valid\nand can be reused;\nby default, it is 60 seconds.\nCertificates that exceed this time will be reloaded or revalidated;\n
\n\n
\noff\n
\n
\ndisables the cache.\n
\n\n

\n

\nExample:\n

\nssl_certificate       $ssl_server_name.crt;\nssl_certificate_key   $ssl_server_name.key;\nssl_certificate_cache max=1000 inactive=20s valid=1m;\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n ssl_certificate_compression on | off;
\n
\n Default:\n \n
ssl_certificate_compression off;
\n
\n Context:\n \n stream, server
\n

This directive appeared in version 1.29.1.\n

\nEnables TLS 1.3\ncompression\nof server certificates.\n

\nThe directive is supported when using OpenSSL 3.2 or higher;\nthe list of supported compression algorithms is provided by the library.\n

\n

\nThe directive is supported when using BoringSSL;\nthe list of supported compression algorithms includes\nzlib (1.29.3).\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n ssl_certificate_key file;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n stream, server
\n

\nSpecifies a file with the secret key in the PEM format\nfor the given virtual server.\n

\nThe value\nengine:name:id\ncan be specified instead of the file,\nwhich loads a secret key with a specified id\nfrom the OpenSSL engine name.\n

\nThe value\nstore:scheme:id\ncan be specified instead of the file (1.29.0),\nwhich is used to load a secret key with a specified id\nand OpenSSL provider registered URI scheme, such as\npkcs11.\n

\nThe value\ndata:$variable\ncan be specified instead of the file (1.15.10),\nwhich loads a secret key from a variable without using intermediate files.\nNote that inappropriate use of this syntax may have its security implications,\nsuch as writing secret key data to\nerror log.\n

\nSince version 1.15.9, variables can be used in the file name\nwhen using OpenSSL 1.0.2 or higher.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n ssl_ciphers ciphers;
\n
\n Default:\n \n
ssl_ciphers HIGH:!aNULL:!MD5;
\n
\n Context:\n \n stream, server
\n

\nSpecifies the enabled ciphers.\nThe ciphers are specified in the format understood by the\nOpenSSL library, for example:\n

\nssl_ciphers ALL:!aNULL:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP;\n

\n

\nThe full list can be viewed using the\n“openssl ciphers” command.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n ssl_client_certificate file;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n stream, server
\n

This directive appeared in version 1.11.8.\n

\nSpecifies a file with trusted CA certificates in the PEM format\nused to verify client certificates and\nOCSP responses if ssl_stapling is enabled.\n

\nThe list of certificates will be sent to clients.\nIf this is not desired, the ssl_trusted_certificate\ndirective can be used.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n ssl_conf_command name value;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n stream, server
\n

This directive appeared in version 1.19.4.\n

\nSets arbitrary OpenSSL configuration\ncommands.\n

\nThe directive is supported when using OpenSSL 1.0.2 or higher.\n

\n

\nSeveral ssl_conf_command directives\ncan be specified on the same level:\n

\nssl_conf_command Options PrioritizeChaCha;\nssl_conf_command Ciphersuites TLS_CHACHA20_POLY1305_SHA256;\n

\nThese directives are inherited from the previous configuration level\nif and only if there are no ssl_conf_command directives\ndefined on the current level.\n

\n

\nNote that configuring OpenSSL directly\nmight result in unexpected behavior.\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n ssl_crl file;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n stream, server
\n

This directive appeared in version 1.11.8.\n

\nSpecifies a file with revoked certificates (CRL)\nin the PEM format used to verify\nclient certificates.\nWhen using intermediate certificates, their CRLs should be\nspecified in the same file.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n ssl_dhparam file;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n stream, server
\n

\nSpecifies a file with DH parameters for DHE ciphers.\n

\nBy default no parameters are set,\nand therefore DHE ciphers will not be used.\n

\nPrior to version 1.11.0, builtin parameters were used by default.\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n ssl_ecdh_curve curve;
\n
\n Default:\n \n
ssl_ecdh_curve auto;
\n
\n Context:\n \n stream, server
\n

\nSpecifies a curve for ECDHE ciphers.\n

\nWhen using OpenSSL 1.0.2 or higher,\nit is possible to specify multiple curves (1.11.0), for example:\n

\nssl_ecdh_curve prime256v1:secp384r1;\n

\n

\nThe special value auto (1.11.0) instructs nginx to use\na list built into the OpenSSL library when using OpenSSL 1.0.2 or higher,\nor prime256v1 with older versions.\n

\n

\nPrior to version 1.11.0,\nthe prime256v1 curve was used by default.\n

\n

\n

\nWhen using OpenSSL 1.0.2 or higher,\nthis directive sets the list of curves supported by the server.\nThus, in order for ECDSA certificates to work,\nit is important to include the curves used in the certificates.\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n ssl_ech_file file;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n stream, server
\n

This directive appeared in version 1.29.4.\n

\nSpecifies a file with encrypted ClientHello configuration\n(ECHConfig) in the\nPEM\nformat used to enable TLS 1.3\nECH\nin shared mode.\n

\n

\nThe directive is currently supported only when using OpenSSL\nECH\nfeature branch.\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n ssl_handshake_timeout time;
\n
\n Default:\n \n
ssl_handshake_timeout 60s;
\n
\n Context:\n \n stream, server
\n

\nSpecifies a timeout for the SSL handshake to complete.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n ssl_key_log path;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n stream, server
\n

This directive appeared in version 1.27.2.\n

\nEnables logging of client connection SSL keys\nand specifies the path to the key log file.\nKeys are logged in the\nSSLKEYLOGFILE\nformat compatible with Wireshark.\n

\n

\nThis directive is available as part of our\ncommercial subscription.\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n ssl_ocsp on |\n off |\n leaf;
\n
\n Default:\n \n
ssl_ocsp off;
\n
\n Context:\n \n stream, server
\n

This directive appeared in version 1.27.2.\n

\nEnables OCSP validation of the client certificate chain.\nThe leaf parameter\nenables validation of the client certificate only.\n

\nFor the OCSP validation to work,\nthe ssl_verify_client directive should be set to\non or optional.\n

\nTo resolve the OCSP responder hostname,\nthe resolver directive\nshould also be specified.\n

\nExample:\n

\nssl_verify_client on;\nssl_ocsp          on;\nresolver          192.0.2.1;\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n ssl_ocsp_cache \n off |\n [shared:name:size];
\n
\n Default:\n \n
ssl_ocsp_cache off;
\n
\n Context:\n \n stream, server
\n

This directive appeared in version 1.27.2.\n

\nSets name and size of the cache\nthat stores client certificates status for OCSP validation.\nThe cache is shared between all worker processes.\nA cache with the same name can be used in several\nvirtual servers.\n

\nThe off parameter prohibits the use of the cache.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n ssl_ocsp_responder url;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n stream, server
\n

This directive appeared in version 1.27.2.\n

\nOverrides the URL of the OCSP responder specified in the\n“Authority\nInformation Access” certificate extension\nfor validation of client certificates.\n

\nOnly “http://” OCSP responders are supported:\n

\nssl_ocsp_responder http://ocsp.example.com/;\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n ssl_password_file file;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n stream, server
\n

\nSpecifies a file with passphrases for\nsecret keys\nwhere each passphrase is specified on a separate line.\nPassphrases are tried in turn when loading the key.\n

\nExample:\n

\nstream {\n    ssl_password_file /etc/keys/global.pass;\n    ...\n\n    server {\n        listen 127.0.0.1:12345;\n        ssl_certificate_key /etc/keys/first.key;\n    }\n\n    server {\n        listen 127.0.0.1:12346;\n\n        # named pipe can also be used instead of a file\n        ssl_password_file /etc/keys/fifo;\n        ssl_certificate_key /etc/keys/second.key;\n    }\n}\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n ssl_prefer_server_ciphers on | off;
\n
\n Default:\n \n
ssl_prefer_server_ciphers off;
\n
\n Context:\n \n stream, server
\n

\nSpecifies that server ciphers should be preferred over client ciphers\nwhen the SSLv3 and TLS protocols are used.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n ssl_protocols \n [SSLv2]\n [SSLv3]\n [TLSv1]\n [TLSv1.1]\n [TLSv1.2]\n [TLSv1.3];
\n
\n Default:\n \n
ssl_protocols TLSv1.2 TLSv1.3;
\n
\n Context:\n \n stream, server
\n

\nEnables the specified protocols.\n

\nIf the directive is specified\non the server level,\nthe value from the default server can be used.\nDetails are provided in the\n“Virtual\nserver selection” section.\n

\n

\nThe TLSv1.1 and TLSv1.2 parameters\nwork only when OpenSSL 1.0.1 or higher is used.\n

\n

\nThe TLSv1.3 parameter (1.13.0) works only when\nOpenSSL 1.1.1 or higher is used.\n

\n

\nThe TLSv1.3 parameter is used by default\nsince 1.23.4.\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n ssl_reject_handshake on | off;
\n
\n Default:\n \n
ssl_reject_handshake off;
\n
\n Context:\n \n stream, server
\n

This directive appeared in version 1.25.5.\n

\nIf enabled, SSL handshakes in\nthe server block will be rejected.\n

\nFor example, in the following configuration, SSL handshakes with\nserver names other than example.com are rejected:\n

\nserver {\n    listen               443 ssl default_server;\n    ssl_reject_handshake on;\n}\n\nserver {\n    listen              443 ssl;\n    server_name         example.com;\n    ssl_certificate     example.com.crt;\n    ssl_certificate_key example.com.key;\n}\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n ssl_session_cache \n off |\n none |\n [builtin[:size]]\n [shared:name:size];
\n
\n Default:\n \n
ssl_session_cache none;
\n
\n Context:\n \n stream, server
\n

\nSets the types and sizes of caches that store session parameters.\nA cache can be of any of the following types:\n

\n\n
off
\n
\nthe use of a session cache is strictly prohibited:\nnginx explicitly tells a client that sessions may not be reused.\n
\n\n
none
\n
\nthe use of a session cache is gently disallowed:\nnginx tells a client that sessions may be reused, but does not\nactually store session parameters in the cache.\n
\n\n
builtin
\n
\na cache built in OpenSSL; used by one worker process only.\nThe cache size is specified in sessions.\nIf size is not given, it is equal to 20480 sessions.\nUse of the built-in cache can cause memory fragmentation.\n
\n\n
shared
\n
\na cache shared between all worker processes.\nThe cache size is specified in bytes; one megabyte can store\nabout 4000 sessions.\nEach shared cache should have an arbitrary name.\nA cache with the same name can be used in several\nvirtual servers.\nIt is also used to automatically generate, store, and\nperiodically rotate TLS session ticket keys (1.23.2)\nunless configured explicitly\nusing the ssl_session_ticket_key directive.\n
\n\n

\n

\nBoth cache types can be used simultaneously, for example:\n

\nssl_session_cache builtin:1000 shared:SSL:10m;\n

\nbut using only shared cache without the built-in cache should\nbe more efficient.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n ssl_session_ticket_key file;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n stream, server
\n

\nSets a file with the secret key used to encrypt\nand decrypt TLS session tickets.\nThe directive is necessary if the same key has to be shared between\nmultiple servers.\nBy default, a randomly generated key is used.\n

\nIf several keys are specified, only the first key is\nused to encrypt TLS session tickets.\nThis allows configuring key rotation, for example:\n

\nssl_session_ticket_key current.key;\nssl_session_ticket_key previous.key;\n

\n

\nThe file must contain 80 or 48 bytes\nof random data and can be created using the following command:\n

\nopenssl rand 80 > ticket.key\n

\nDepending on the file size either AES256 (for 80-byte keys, 1.11.8)\nor AES128 (for 48-byte keys) is used for encryption.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n ssl_session_tickets on | off;
\n
\n Default:\n \n
ssl_session_tickets on;
\n
\n Context:\n \n stream, server
\n

\nEnables or disables session resumption through\nTLS session tickets.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n ssl_session_timeout time;
\n
\n Default:\n \n
ssl_session_timeout 5m;
\n
\n Context:\n \n stream, server
\n

\nSpecifies a time during which a client may reuse the\nsession parameters.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n ssl_stapling on | off;
\n
\n Default:\n \n
ssl_stapling off;
\n
\n Context:\n \n stream, server
\n

This directive appeared in version 1.27.2.\n

\nEnables or disables\nstapling\nof OCSP responses by the server.\nExample:\n

\nssl_stapling on;\nresolver 192.0.2.1;\n

\n

\nFor the OCSP stapling to work, the certificate of the server certificate\nissuer should be known.\nIf the ssl_certificate file does\nnot contain intermediate certificates,\nthe certificate of the server certificate issuer should be\npresent in the\nssl_trusted_certificate file.\n

\nFor a resolution of the OCSP responder hostname,\nthe resolver directive\nshould also be specified.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n ssl_stapling_file file;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n stream, server
\n

This directive appeared in version 1.27.2.\n

\nWhen set, the stapled OCSP response will be taken from the\nspecified file instead of querying\nthe OCSP responder specified in the server certificate.\n

\nThe file should be in the DER format as produced by the\n“openssl ocsp” command.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n ssl_stapling_responder url;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n stream, server
\n

This directive appeared in version 1.27.2.\n

\nOverrides the URL of the OCSP responder specified in the\n“Authority\nInformation Access” certificate extension.\n

\nOnly “http://” OCSP responders are supported:\n

\nssl_stapling_responder http://ocsp.example.com/;\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n ssl_stapling_verify on | off;
\n
\n Default:\n \n
ssl_stapling_verify off;
\n
\n Context:\n \n stream, server
\n

This directive appeared in version 1.27.2.\n

\nEnables or disables verification of OCSP responses by the server.\n

\nFor verification to work, the certificate of the server certificate\nissuer, the root certificate, and all intermediate certificates\nshould be configured as trusted using the\nssl_trusted_certificate directive.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n ssl_trusted_certificate file;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n stream, server
\n

This directive appeared in version 1.11.8.\n

\nSpecifies a file with trusted CA certificates in the PEM format\nused to verify client certificates and\nOCSP responses if ssl_stapling is enabled.\n

\nIn contrast to the certificate set by ssl_client_certificate,\nthe list of these certificates will not be sent to clients.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n ssl_verify_client \n on | off |\n optional | optional_no_ca;
\n
\n Default:\n \n
ssl_verify_client off;
\n
\n Context:\n \n stream, server
\n

This directive appeared in version 1.11.8.\n

\nEnables verification of client certificates.\nThe verification result is stored in the\n$ssl_client_verify variable.\nIf an error has occurred during the client certificate verification\nor a client has not presented the required certificate,\nthe connection is closed.\n

\nThe optional parameter requests the client\ncertificate and verifies it if the certificate is present.\n

\nThe optional_no_ca parameter\nrequests the client\ncertificate but does not require it to be signed by a trusted CA certificate.\nThis is intended for the use in cases when a service that is external to nginx\nperforms the actual certificate verification.\nThe contents of the certificate is accessible through the\n$ssl_client_cert variable.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n ssl_verify_depth number;
\n
\n Default:\n \n
ssl_verify_depth 1;
\n
\n Context:\n \n stream, server
\n

This directive appeared in version 1.11.8.\n

\nSets the verification depth in the client certificates chain.\n

\n\n\n

Embedded Variables

\nThe ngx_stream_ssl_module module supports variables\nsince 1.11.2.\n

\n\n
$ssl_alpn_protocol
\n
\nreturns the protocol selected by ALPN during the SSL handshake,\nor an empty string otherwise (1.21.4);\n
\n\n
$ssl_cipher
\n
\nreturns the name of the cipher used\nfor an established SSL connection;\n
\n\n
$ssl_ciphers
\n
\nreturns the list of ciphers supported by the client (1.11.7).\nKnown ciphers are listed by names, unknown are shown in hexadecimal,\nfor example:\n
\nAES128-SHA:AES256-SHA:0x00ff\n
\n
\nThe variable is fully supported only when using OpenSSL version 1.0.2 or higher.\nWith older versions, the variable is available\nonly for new sessions and lists only known ciphers.\n
\n
\n\n
$ssl_client_cert
\n
\nreturns the client certificate in the PEM format\nfor an established SSL connection, with each line except the first\nprepended with the tab character (1.11.8);\n
\n\n
$ssl_client_fingerprint
\n
\nreturns the SHA1 fingerprint of the client certificate\nfor an established SSL connection (1.11.8);\n
\n\n
$ssl_client_i_dn
\n
\nreturns the “issuer DN” string of the client certificate\nfor an established SSL connection according to\nRFC 2253 (1.11.8);\n
\n\n
$ssl_client_raw_cert\n
\n
\nreturns the client certificate in the PEM format\nfor an established SSL connection (1.11.8);\n
\n\n
$ssl_client_s_dn
\n
\nreturns the “subject DN” string of the client certificate\nfor an established SSL connection according to\nRFC 2253 (1.11.8);\n
\n\n
$ssl_client_serial
\n
\nreturns the serial number of the client certificate\nfor an established SSL connection (1.11.8);\n
\n\n
$ssl_client_sigalg
\n
\nreturns the\nsignature algorithm\nfor the client certificate for an established SSL connection (1.29.3).\n
\nThe variable is supported only when using OpenSSL version 3.5 or higher.\nWith older versions, the variable value will be an empty string.\n
\n
\nThe variable is available only for new sessions.\n
\n
\n\n
$ssl_client_v_end
\n
\nreturns the end date of the client certificate (1.11.8);\n
\n\n
$ssl_client_v_remain
\n
\nreturns the number of days\nuntil the client certificate expires (1.11.8);\n
\n\n
$ssl_client_v_start
\n
\nreturns the start date of the client certificate (1.11.8);\n
\n\n
$ssl_client_verify
\n
\nreturns the result of client certificate verification (1.11.8):\n“SUCCESS”, “FAILED:reason”,\nand “NONE” if a certificate was not present;\n
\n\n
$ssl_curve
\n
\nreturns the negotiated curve used for\nSSL handshake key exchange process (1.21.5).\nKnown curves are listed by names, unknown are shown in hexadecimal,\nfor example:\n
\nprime256v1\n
\n
\nThe variable is supported only when using OpenSSL version 3.0 or higher.\nWith older versions, the variable value will be an empty string.\n
\n
\n\n
$ssl_curves
\n
\nreturns the list of curves supported by the client (1.11.7).\nKnown curves are listed by names, unknown are shown in hexadecimal,\nfor example:\n
\n0x001d:prime256v1:secp521r1:secp384r1\n
\n
\nThe variable is supported only when using OpenSSL version 1.0.2 or higher.\nWith older versions, the variable value will be an empty string.\n
\n
\nThe variable is available only for new sessions.\n
\n
\n\n
$ssl_ech_outer_server_name
\n
\nreturns the public server name requested through\nSNI\nif TLS 1.3 ECH was accepted,\notherwise “” (1.29.4);\n
\n\n
$ssl_ech_status
\n
\nreturns the result of TLS 1.3 ECH processing:\n“FAILED”,\n“BACKEND”,\n“GREASE”,\n“SUCCESS”, or\n“NOT_TRIED” (1.29.4);\n
\nThe variable is currently supported only when using OpenSSL\nECH feature branch\nand is therefore subject to change.\nThe variable value will otherwise be an empty string.\n
\n
\n\n
$ssl_protocol
\n
\nreturns the protocol of an established SSL connection;\n
\n\n
$ssl_server_name
\n
\nreturns the server name requested through\nSNI;\n
\n\n
$ssl_session_id
\n
\nreturns the session identifier of an established SSL connection;\n
\n\n
$ssl_session_reused
\n
\nreturns “r” if an SSL session was reused,\nor “.” otherwise.\n
\n\n
$ssl_sigalg
\n
\nreturns the\nsignature algorithm\nfor the server certificate for an established SSL connection (1.29.3).\n
\nThe variable is supported only when using OpenSSL version 3.5 or higher.\nWith older versions, the variable value will be an empty string.\n
\n
\nThe variable is available only for new sessions.\n
\n
\n\n

\n

\n\n
\n", "encoding": "utf-8"} +{"path": "en\\docs\\stream\\ngx_stream_ssl_preread_module.html", "extension": ".html", "size_bytes": 6115, "content": "\nModule ngx_stream_ssl_preread_module
\n\nPlanning your ingress-nginx migration? Start here:\nkubernetes.nginx.org.\n\n

Module ngx_stream_ssl_preread_module

Example Configuration
Directives
     ssl_preread
Embedded Variables
\n\n

\nThe ngx_stream_ssl_preread_module module (1.11.5) allows\nextracting information from the\nClientHello\nmessage without terminating SSL/TLS,\nfor example, the server name requested through\nSNI\nor protocols advertised in\nALPN.\nThis module is not built by default, it should be enabled with the\n--with-stream_ssl_preread_module\nconfiguration parameter.\n

\n\n\n

Example Configuration

\nSelecting an upstream based on server name:\n

\nmap $ssl_preread_server_name $name {\n    backend.example.com      backend;\n    default                  backend2;\n}\n\nupstream backend {\n    server 192.168.0.1:12345;\n    server 192.168.0.2:12345;\n}\n\nupstream backend2 {\n    server 192.168.0.3:12345;\n    server 192.168.0.4:12345;\n}\n\nserver {\n    listen      12346;\n    proxy_pass  $name;\n    ssl_preread on;\n}\n

\n

\nSelecting an upstream based on protocol:\n

\nmap $ssl_preread_alpn_protocols $proxy {\n    ~\\bh2\\b           127.0.0.1:8001;\n    ~\\bhttp/1.1\\b     127.0.0.1:8002;\n    ~\\bxmpp-client\\b  127.0.0.1:8003;\n}\n\nserver {\n    listen      9000;\n    proxy_pass  $proxy;\n    ssl_preread on;\n}\n

\n

\nSelecting an upstream based on SSL protocol version:\n

\nmap $ssl_preread_protocol $upstream {\n    \"\"        ssh.example.com:22;\n    \"TLSv1.2\" new.example.com:443;\n    default   tls.example.com:443;\n}\n\n# ssh and https on the same port\nserver {\n    listen      192.168.0.1:443;\n    proxy_pass  $upstream;\n    ssl_preread on;\n}\n

\n

\n\n\n

Directives

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n ssl_preread on | off;
\n
\n Default:\n \n
ssl_preread off;
\n
\n Context:\n \n stream, server
\n

\nEnables extracting information from the ClientHello message at\nthe preread phase.\n

\n\n\n

Embedded Variables

\n

\n\n
$ssl_preread_protocol
\n
\nthe highest SSL protocol version supported by the client (1.15.2)\n
\n\n
$ssl_preread_server_name
\n
\nserver name requested through SNI\n
\n\n
$ssl_preread_alpn_protocols
\n
\nlist of protocols advertised by the client through ALPN (1.13.10).\nThe values are separated by commas.\n
\n\n

\n

\n\n
\n", "encoding": "utf-8"} +{"path": "en\\docs\\stream\\ngx_stream_upstream_hc_module.html", "extension": ".html", "size_bytes": 12701, "content": "\nModule ngx_stream_upstream_hc_module
\n\nPlanning your ingress-nginx migration? Start here:\nkubernetes.nginx.org.\n\n

Module ngx_stream_upstream_hc_module

Example Configuration
Directives
     health_check
     health_check_timeout
     match
\n\n

\nThe ngx_stream_upstream_hc_module module (1.9.0)\nallows enabling periodic health checks of the servers in a\ngroup.\nThe server group must reside in the\nshared memory.\n

\nIf a health check fails, the server will be considered unhealthy.\nIf several health checks are defined for the same group of servers,\na single failure of any check will make the corresponding server be\nconsidered unhealthy.\nClient connections are not passed to unhealthy servers\nand servers in the “checking” state.\n

\n

\nThis module is available as part of our\ncommercial subscription.\n

\n

\n\n\n

Example Configuration

\n

\nupstream tcp {\n    zone upstream_tcp 64k;\n\n    server backend1.example.com:12345 weight=5;\n    server backend2.example.com:12345 fail_timeout=5s slow_start=30s;\n    server 192.0.2.1:12345            max_fails=3;\n\n    server backup1.example.com:12345  backup;\n    server backup2.example.com:12345  backup;\n}\n\nserver {\n    listen     12346;\n    proxy_pass tcp;\n    health_check;\n}\n

\nWith this configuration, nginx\nwill check the ability to establish a TCP connection to each server\nin the tcp group every five seconds.\nWhen a connection to the server cannot be established,\nthe health check will fail, and the server will\nbe considered unhealthy.\n

\nHealth checks can be configured for the UDP protocol:\n

\nupstream dns_upstream {\n\n    zone   dns_zone 64k;\n\n    server dns1.example.com:53;\n    server dns2.example.com:53;\n    server dns3.example.com:53;\n}\n\nserver {\n    listen       53 udp;\n    proxy_pass   dns_upstream;\n    health_check udp;\n}\n

\nIn this case, the absence of\nICMP “Destination Unreachable” message is expected\nin reply to the sent string “nginx health check”.\n

\nHealth checks can also be configured to test data obtained from the server.\nTests are configured separately using the match directive\nand referenced in the match parameter\nof the health_check directive.\n

\n\n\n

Directives

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n health_check [parameters];
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n server
\n

\nEnables periodic health checks of the servers in a\ngroup.\n

\nThe following optional parameters are supported:\n

\n\n
\ninterval=time\n
\n
\nsets the interval between two consecutive health checks,\nby default, 5 seconds.\n
\n\n
\njitter=time\n
\n
\nsets the time within which\neach health check will be randomly delayed,\nby default, there is no delay.\n
\n\n
\nfails=number\n
\n
\nsets the number of consecutive failed health checks of a particular server\nafter which this server will be considered unhealthy,\nby default, 1.\n
\n\n
\npasses=number\n
\n
\nsets the number of consecutive passed health checks of a particular server\nafter which the server will be considered healthy,\nby default, 1.\n
\n\n
\nmandatory [persistent]\n
\n
\n

\nsets the initial “checking” state for a server\nuntil the first health check is completed (1.11.7).\nClient connections are not passed to servers in the “checking” state.\nIf the parameter is not specified,\nthe server will be initially considered healthy.\n

\n\n

\nThe persistent parameter (1.21.1)\nsets the initial “up” state for a server after reload\nif the server was considered healthy before reload.\n

\n\n
\n\n
\nmatch=name\n
\n
\nspecifies the match block configuring the tests that a\nsuccessful connection should pass in order for a health check to pass.\nBy default, for TCP, only the ability\nto establish a TCP connection with the server is checked.\nFor UDP, the absence of\nICMP “Destination Unreachable” message is expected\nin reply to the sent string “nginx health check”.\n
\nPrior to version 1.11.7, by default, UDP health check\nrequired a match block with the\nsend and expect\nparameters.\n
\n
\n\n
\nport=number\n
\n
\ndefines the port used when connecting to a server\nto perform a health check (1.9.7).\nBy default, equals the\nserver port.\n
\n\n
\nudp\n
\n
\nspecifies that the UDP protocol should be used for\nhealth checks instead of the default TCP protocol (1.9.13).\n
\n\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n health_check_timeout timeout;
\n
\n Default:\n \n
health_check_timeout 5s;
\n
\n Context:\n \n stream, server
\n

\nOverrides the\nproxy_timeout\nvalue for health checks.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n match name { ... }
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n stream
\n

\nDefines the named test set used to verify server responses to health checks.\n

\nThe following parameters can be configured:\n

\n\n
\nsend string;\n
\n
\nsends a string to the server;\n
\n\n
\nexpect string |\n~ regex;\n
\n
\na literal string (1.9.12) or a regular expression\nthat the data obtained from the server should match.\nThe regular expression is specified with the preceding\n“~*” modifier (for case-insensitive matching), or the\n“~” modifier (for case-sensitive matching).\n
\n\n

\nBoth send and expect parameters\ncan contain hexadecimal literals with the prefix “\\x”\nfollowed by two hex digits, for example, “\\x80” (1.9.12).\n

\nHealth check is passed if:\n

\n

\nExample:\n

\nupstream backend {\n    zone     upstream_backend 10m;\n    server   127.0.0.1:12345;\n}\n\nmatch http {\n    send     \"GET / HTTP/1.0\\r\\nHost: localhost\\r\\n\\r\\n\";\n    expect ~ \"200 OK\";\n}\n\nserver {\n    listen       12346;\n    proxy_pass   backend;\n    health_check match=http;\n}\n

\n

\n

\nOnly the first\nproxy_buffer_size\nbytes of data obtained from the server are examined.\n

\n

\n\n
\n", "encoding": "utf-8"} +{"path": "en\\docs\\stream\\ngx_stream_upstream_module.html", "extension": ".html", "size_bytes": 31536, "content": "\nModule ngx_stream_upstream_module
\n\nPlanning your ingress-nginx migration? Start here:\nkubernetes.nginx.org.\n\n

Module ngx_stream_upstream_module

Example Configuration
Directives
     upstream
     server
     zone
     state
     hash
     least_conn
     least_time
     random
     resolver
     resolver_timeout
Embedded Variables
\n\n

\nThe ngx_stream_upstream_module module (1.9.0)\nis used to define groups of servers that can be referenced\nby the proxy_pass\ndirective.\n

\n\n\n

Example Configuration

\n

\nupstream backend {\n    hash $remote_addr consistent;\n\n    server backend1.example.com:12345  weight=5;\n    server backend2.example.com:12345;\n    server unix:/tmp/backend3;\n\n    server backup1.example.com:12345   backup;\n    server backup2.example.com:12345   backup;\n}\n\nserver {\n    listen 12346;\n    proxy_pass backend;\n}\n

\n

\nDynamically configurable group with\nperiodic health checks is\navailable as part of our\ncommercial subscription:\n

\nresolver 10.0.0.1;\n\nupstream dynamic {\n    zone upstream_dynamic 64k;\n\n    server backend1.example.com:12345 weight=5;\n    server backend2.example.com:12345 fail_timeout=5s slow_start=30s;\n    server 192.0.2.1:12345            max_fails=3;\n    server backend3.example.com:12345 resolve;\n    server backend4.example.com       service=http resolve;\n\n    server backup1.example.com:12345  backup;\n    server backup2.example.com:12345  backup;\n}\n\nserver {\n    listen 12346;\n    proxy_pass dynamic;\n    health_check;\n}\n

\n

\n\n\n

Directives

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n upstream name { ... }
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n stream
\n

\nDefines a group of servers.\nServers can listen on different ports.\nIn addition, servers listening on TCP and UNIX-domain sockets\ncan be mixed.\n

\nExample:\n

\nupstream backend {\n    server backend1.example.com:12345 weight=5;\n    server 127.0.0.1:12345            max_fails=3 fail_timeout=30s;\n    server unix:/tmp/backend2;\n    server backend3.example.com:12345 resolve;\n\n    server backup1.example.com:12345  backup;\n}\n

\n

\nBy default, connections are distributed between the servers using a\nweighted round-robin balancing method.\nIn the above example, each 7 connections will be distributed as follows:\n5 connections go to backend1.example.com:12345\nand one connection to each of the second and third servers.\nIf an error occurs during communication with a server, the connection will\nbe passed to the next server, and so on until all of the functioning\nservers will be tried.\nIf communication with all servers fails, the connection will be closed.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n server address [parameters];
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n upstream
\n

\nDefines the address and other parameters\nof a server.\nThe address can be specified as a domain name or IP address\nwith an obligatory port, or as a UNIX-domain socket path\nspecified after the “unix:” prefix.\nA domain name that resolves to several IP addresses defines\nmultiple servers at once.\n

\nThe following parameters can be defined:\n

\n\n
\nweight=number\n
\n
\nsets the weight of the server, by default, 1.\n
\n\n
\nmax_conns=number\n
\n
\nlimits the maximum number of simultaneous\nconnections to the proxied server (1.11.5).\nDefault value is zero, meaning there is no limit.\nIf the server group does not reside in the shared memory,\nthe limitation works per each worker process.\n
\nPrior to version 1.11.5, this parameter was available as part of our\ncommercial subscription.\n
\n
\n\n
\nmax_fails=number\n
\n
\nsets the number of unsuccessful attempts to communicate with the server\nthat should happen in the duration set by the fail_timeout\nparameter to consider the server unavailable for a duration also set by the\nfail_timeout parameter.\nBy default, the number of unsuccessful attempts is set to 1.\nThe zero value disables the accounting of attempts.\nHere, an unsuccessful attempt is an error or timeout\nwhile establishing a connection with the server.\n
\n\n
\nfail_timeout=time\n
\n
\nsets\n
    \n\n
  • \nthe time during which the specified number of unsuccessful attempts to\ncommunicate with the server should happen to consider the server unavailable;\n
  • \n\n
  • \nand the period of time the server will be considered unavailable.\n
  • \n\n
\nBy default, the parameter is set to 10 seconds.\n
\n\n
\nbackup\n
\n
\nmarks the server as a backup server.\nConnections to the backup server will be passed\nwhen the primary servers are unavailable.\n
\nThe parameter cannot be used along with the\nhash and random load balancing methods.\n
\n
\n\n
\ndown\n
\n
\nmarks the server as permanently unavailable.\n
\n\n
\nresolve\n
\n
\nmonitors changes of the IP addresses\nthat correspond to a domain name of the server,\nand automatically modifies the upstream configuration\nwithout the need of restarting nginx.\nThe server group must reside in the shared memory.\n

\nIn order for this parameter to work,\nthe resolver directive\nmust be specified in the\nstream block\nor in the corresponding upstream block.\n

\n\n

\n

\nPrior to version 1.27.3, this parameter was available only as part of our\ncommercial subscription.\n

\n

\n
\n\n
\nservice=name\n
\n
\nenables resolving of DNS\nSRV\nrecords and sets the service name (1.9.13).\nIn order for this parameter to work, it is necessary to specify\nthe resolve parameter for the server\nand specify a hostname without a port number.\n

\nIf the service name does not contain a dot (“.”), then\nthe RFC-compliant name\nis constructed\nand the TCP protocol is added to the service prefix.\nFor example, to look up the\n_http._tcp.backend.example.com SRV record,\nit is necessary to specify the directive:\n

\nserver backend.example.com service=http resolve;\n

\nIf the service name contains one or more dots, then the name is constructed\nby joining the service prefix and the server name.\nFor example, to look up the _http._tcp.backend.example.com\nand server1.backend.example.com SRV records,\nit is necessary to specify the directives:\n

\nserver backend.example.com service=_http._tcp resolve;\nserver example.com service=server1.backend resolve;\n

\n

\n\n

\nHighest-priority SRV records\n(records with the same lowest-number priority value)\nare resolved as primary servers,\nthe rest of SRV records are resolved as backup servers.\nIf the backup parameter is specified for the server,\nhigh-priority SRV records are resolved as backup servers,\nthe rest of SRV records are ignored.\n

\n\n

\n

\nPrior to version 1.27.3, this parameter was available only as part of our\ncommercial subscription.\n

\n

\n
\n\n

\n

\nAdditionally,\nthe following parameters are available as part of our\ncommercial subscription:\n

\n\n
\nslow_start=time\n
\n
\nsets the time during which the server will recover its weight\nfrom zero to a nominal value, when unhealthy server becomes\nhealthy,\nor when the server becomes available after a period of time\nit was considered unavailable.\nDefault value is zero, i.e. slow start is disabled.\n
\nThe parameter cannot be used along with the\nhash and random load balancing methods.\n
\n
\n\n

\n

\n

\nIf there is only a single server in a group, max_fails,\nfail_timeout and slow_start parameters\nare ignored, and such a server will never be considered unavailable.\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n zone name [size];
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n upstream
\n

\nDefines the name and size of the shared\nmemory zone that keeps the group’s configuration and run-time state that are\nshared between worker processes.\nSeveral groups may share the same zone.\nIn this case, it is enough to specify the size only once.\n

\nAdditionally,\nas part of our commercial subscription,\nsuch groups allow changing the group membership\nor modifying the settings of a particular server\nwithout the need of restarting nginx.\nThe configuration is accessible via the\nAPI module (1.13.3).\n

\nPrior to version 1.13.3,\nthe configuration was accessible only via a special location\nhandled by\nupstream_conf.\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n state file;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n upstream
\n

This directive appeared in version 1.9.7.\n

\nSpecifies a file that keeps the state\nof the dynamically configurable group.\n

\nExamples:\n

\nstate /var/lib/nginx/state/servers.conf; # path for Linux\nstate /var/db/nginx/state/servers.conf;  # path for FreeBSD\n

\n

\nThe state is currently limited to the list of servers with their parameters.\nThe file is read when parsing the configuration and is updated each time\nthe upstream configuration is\nchanged.\nChanging the file content directly should be avoided.\nThe directive cannot be used\nalong with the server directive.\n

\n

\nChanges made during\nconfiguration reload\nor binary upgrade\ncan be lost.\n

\n

\n

\nThis directive is available as part of our\ncommercial subscription.\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n hash key [consistent];
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n upstream
\n

\nSpecifies a load balancing method for a server group\nwhere the client-server mapping is based on the hashed key value.\nThe key can contain text, variables,\nand their combinations (1.11.2).\nUsage example:\n

\nhash $remote_addr;\n

\nNote that adding or removing a server from the group\nmay result in remapping most of the keys to different servers.\nThe method is compatible with the\nCache::Memcached\nPerl library.\n

\nIf the consistent parameter is specified,\nthe ketama\nconsistent hashing method will be used instead.\nThe method ensures that only a few keys\nwill be remapped to different servers\nwhen a server is added to or removed from the group.\nThis helps to achieve a higher cache hit ratio for caching servers.\nThe method is compatible with the\nCache::Memcached::Fast\nPerl library with the ketama_points parameter set to 160.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n least_conn;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n upstream
\n

\nSpecifies that a group should use a load balancing method where a connection\nis passed to the server with the least number of active connections,\ntaking into account weights of servers.\nIf there are several such servers, they are tried in turn using a\nweighted round-robin balancing method.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n least_time \n connect |\n first_byte |\n last_byte\n [inflight];
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n upstream
\n

This directive appeared in version 1.7.11.\n

\nSpecifies that a group should use a load balancing method where a connection\nis passed to the server with the least average time and\nleast number of active connections, taking into account weights of servers.\nIf there are several such servers, they are tried in turn using a\nweighted round-robin balancing method.\n

\nIf the connect parameter is specified,\ntime to\nconnect\nto the upstream server is used.\nIf the first_byte parameter is specified,\ntime to receive the\nfirst byte of data is used.\nIf the last_byte is specified,\ntime to receive the\nlast byte of data is used.\nIf the inflight parameter is specified (1.11.6),\nincomplete connections are also taken into account.\n

\nPrior to version 1.11.6,\nincomplete connections were taken into account by default.\n

\n

\n

\nPrior to version 1.31.0,\nthis directive was available only as part of our\ncommercial subscription.\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n random [two [method]];
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n upstream
\n

This directive appeared in version 1.15.1.\n

\nSpecifies that a group should use a load balancing method where a connection\nis passed to a randomly selected server, taking into account weights\nof servers.\n

\nThe optional two parameter\ninstructs nginx to randomly select\ntwo\nservers and then choose a server\nusing the specified method.\nThe default method is least_conn\nwhich passes a connection to a server\nwith the least number of active connections.\n

\nThe least_time method passes a connection to a server\nwith the least average time and least number of active connections.\nIf least_time=connect parameter is specified,\ntime to\nconnect\nto the upstream server is used.\nIf least_time=first_byte parameter is specified,\ntime to receive the\nfirst byte of data is used.\nIf least_time=last_byte is specified,\ntime to receive the\nlast byte of data is used.\n

\nThe least_time method is available as a part of our\ncommercial subscription.\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n resolver \n address ...\n [valid=time]\n [ipv4=on|off]\n [ipv6=on|off]\n [status_zone=zone];
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n upstream
\n

This directive appeared in version 1.27.3.\n

\nConfigures name servers used to resolve names of upstream servers\ninto addresses, for example:\n

\nresolver 127.0.0.1 [::1]:5353;\n

\nThe address can be specified as a domain name or IP address,\nwith an optional port.\nIf port is not specified, the port 53 is used.\nName servers are queried in a round-robin fashion.\n

\nBy default, nginx will look up both IPv4 and IPv6 addresses while resolving.\nIf looking up of IPv4 or IPv6 addresses is not desired,\nthe ipv4=off (1.23.1) or\nthe ipv6=off parameter can be specified.\n

\nBy default, nginx caches answers using the TTL value of a response.\nThe optional valid parameter allows overriding it:\n

\nresolver 127.0.0.1 [::1]:5353 valid=30s;\n

\n

\nTo prevent DNS spoofing, it is recommended\nconfiguring DNS servers in a properly secured trusted local network.\n

\n

\nThe optional status_zone parameter (1.17.5)\nenables\ncollection\nof DNS server statistics of requests and responses\nin the specified zone.\nThe parameter is available as part of our\ncommercial subscription.\n

\n

\nSince version 1.17.5 and prior to version 1.27.3,\nthis directive was available only as part of our\ncommercial subscription.\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n resolver_timeout time;
\n
\n Default:\n \n
resolver_timeout 30s;
\n
\n Context:\n \n upstream
\n

This directive appeared in version 1.27.3.\n

\nSets a timeout for name resolution, for example:\n

\nresolver_timeout 5s;\n

\n

\n

\nSince version 1.17.5 and prior to version 1.27.3,\nthis directive was available only as part of our\ncommercial subscription.\n

\n

\n\n\n

Embedded Variables

\nThe ngx_stream_upstream_module module\nsupports the following embedded variables:\n

\n\n
$upstream_addr
\n
\nkeeps the IP address and port,\nor the path to the UNIX-domain socket of the upstream server (1.11.4).\nIf several servers were contacted during proxying,\ntheir addresses are separated by commas, e.g.\n“192.168.1.1:12345, 192.168.1.2:12345, unix:/tmp/sock”.\nIf a server cannot be selected,\nthe variable keeps the name of the server group.\n
\n\n
$upstream_bytes_received
\n
\nnumber of bytes received from an upstream server (1.11.4).\nValues from several connections\nare separated by commas like addresses in the\n$upstream_addr variable.\n
\n\n
$upstream_bytes_sent
\n
\nnumber of bytes sent to an upstream server (1.11.4).\nValues from several connections\nare separated by commas like addresses in the\n$upstream_addr variable.\n
\n\n
$upstream_connect_time
\n
\ntime to connect to the upstream server (1.11.4);\nthe time is kept in seconds with millisecond resolution.\nTimes of several connections\nare separated by commas like addresses in the\n$upstream_addr variable.\n
\n\n
$upstream_first_byte_time
\n
\ntime to receive the first byte of data (1.11.4);\nthe time is kept in seconds with millisecond resolution.\nTimes of several connections\nare separated by commas like addresses in the\n$upstream_addr variable.\n
\n\n
$upstream_last_addr
\n
\nkeeps the IP address or the path to the UNIX-domain socket\nof the last selected upstream server (1.29.3).\n\n

\n

\nThis variable is available as part of our\ncommercial subscription.\n

\n

\n\n
\n\n
$upstream_session_time
\n
\nsession duration in seconds with millisecond resolution (1.11.4).\nTimes of several connections\nare separated by commas like addresses in the\n$upstream_addr variable.\n
\n\n

\n

\n\n
\n", "encoding": "utf-8"} +{"path": "en\\docs\\stream\\ngx_stream_zone_sync_module.html", "extension": ".html", "size_bytes": 31567, "content": "\nModule ngx_stream_zone_sync_module
\n\nPlanning your ingress-nginx migration? Start here:\nkubernetes.nginx.org.\n\n

Module ngx_stream_zone_sync_module

Example Configuration
Directives
     zone_sync
     zone_sync_buffers
     zone_sync_connect_retry_interval
     zone_sync_connect_timeout
     zone_sync_interval
     zone_sync_recv_buffer_size
     zone_sync_server
     zone_sync_ssl
     zone_sync_ssl_certificate
     zone_sync_ssl_certificate_key
     zone_sync_ssl_ciphers
     zone_sync_ssl_conf_command
     zone_sync_ssl_crl
     zone_sync_ssl_name
     zone_sync_ssl_password_file
     zone_sync_ssl_protocols
     zone_sync_ssl_server_name
     zone_sync_ssl_trusted_certificate
     zone_sync_ssl_verify
     zone_sync_ssl_verify_depth
     zone_sync_timeout
API endpoints
Starting, stopping, removing a cluster node
\n\n

\nThe ngx_stream_zone_sync_module module (1.13.8)\nprovides the necessary support for synchronizing contents of\nshared memory zones\nbetween nodes of a cluster.\nTo enable synchronization for a particular zone, a corresponding module\nmust support this feature.\nCurrently, it is possible to synchronize HTTP\nsticky\nsessions, information about\nexcessive HTTP requests,\nand key-value pairs both in\nhttp\nand stream.\n

\n

\nThis module is available as part of our\ncommercial subscription.\n

\n

\n\n\n

Example Configuration

\nMinimal configuration:\n

\nhttp {\n    ...\n\n    upstream backend {\n       server backend1.example.com:8080;\n       server backend2.example.com:8081;\n\n       sticky learn\n              create=$upstream_cookie_examplecookie\n              lookup=$cookie_examplecookie\n              zone=client_sessions:1m sync;\n    }\n\n    ...\n}\n\nstream {\n    ...\n\n\n    server {\n        zone_sync;\n\n        listen 127.0.0.1:12345;\n\n        # cluster of 2 nodes\n        zone_sync_server a.example.com:12345;\n        zone_sync_server b.example.com:12345;\n\n    }\n

\nA more complex configuration with SSL enabled\nand with cluster members defined by DNS:\n

\n...\n\nstream {\n    ...\n\n    resolver 127.0.0.1 valid=10s;\n\n    server {\n        zone_sync;\n\n        # the name resolves to multiple addresses that correspond to cluster nodes\n        zone_sync_server cluster.example.com:12345 resolve;\n\n        listen 127.0.0.1:4433 ssl;\n\n        ssl_certificate     localhost.crt;\n        ssl_certificate_key localhost.key;\n\n        zone_sync_ssl on;\n\n        zone_sync_ssl_certificate     localhost.crt;\n        zone_sync_ssl_certificate_key localhost.key;\n    }\n}\n

\n

\n\n\n

Directives

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n zone_sync;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n server
\n

\nEnables the synchronization of shared memory zones between cluster nodes.\nCluster nodes are defined using zone_sync_server directives.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n zone_sync_buffers number size;
\n
\n Default:\n \n
zone_sync_buffers 8 4k|8k;
\n
\n Context:\n \n stream, server
\n

\nSets the number and size of the\nper-zone buffers used for pushing zone contents.\nBy default, the buffer size is equal to one memory page.\nThis is either 4K or 8K, depending on a platform.\n

\n

\nA single buffer must be large enough to hold any entry of each zone being\nsynchronized.\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n zone_sync_connect_retry_interval time;
\n
\n Default:\n \n
zone_sync_connect_retry_interval 1s;
\n
\n Context:\n \n stream, server
\n

\nDefines an interval between connection attempts to another cluster node.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n zone_sync_connect_timeout time;
\n
\n Default:\n \n
zone_sync_connect_timeout 5s;
\n
\n Context:\n \n stream, server
\n

\nDefines a timeout for establishing a connection with another cluster node.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n zone_sync_interval time;
\n
\n Default:\n \n
zone_sync_interval 1s;
\n
\n Context:\n \n stream, server
\n

\nDefines an interval for polling updates in a shared memory zone.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n zone_sync_recv_buffer_size size;
\n
\n Default:\n \n
zone_sync_recv_buffer_size 4k|8k;
\n
\n Context:\n \n stream, server
\n

\nSets size of a per-connection receive buffer used to parse\nincoming stream of synchronization messages.\nThe buffer size must be equal or greater than one of the\nzone_sync_buffers.\nBy default, the buffer size is equal to\nzone_sync_buffers size\nmultiplied by number.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n zone_sync_server address [resolve];
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n server
\n

\nDefines the address of a cluster node.\nThe address can be specified as a domain name or IP address\nwith a mandatory port, or as a UNIX-domain socket path\nspecified after the “unix:” prefix.\nA domain name that resolves to several IP addresses defines\nmultiple nodes at once.\n

\nThe resolve parameter instructs nginx to monitor\nchanges of the IP addresses that correspond to a domain name of the node\nand automatically modify the configuration\nwithout the need of restarting nginx.\n

\nCluster nodes are specified either dynamically as a single\nzone_sync_server directive with\nthe resolve parameter, or statically as a series of several\ndirectives without the parameter.\n

\nEach cluster node should be specified only once.\n

\n

\nAll cluster nodes should use the same configuration.\n

\n

\nIn order for the resolve parameter to work,\nthe resolver directive\nmust be specified in the\nstream block.\nExample:\n

\nstream {\n    resolver 10.0.0.1;\n\n    server {\n        zone_sync;\n        zone_sync_server cluster.example.com:12345 resolve;\n        ...\n    }\n}\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n zone_sync_ssl on | off;
\n
\n Default:\n \n
zone_sync_ssl off;
\n
\n Context:\n \n stream, server
\n

\nEnables the SSL/TLS protocol for connections to another cluster server.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n zone_sync_ssl_certificate file;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n stream, server
\n

\nSpecifies a file with the certificate in the PEM format\nused for authentication to another cluster server.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n zone_sync_ssl_certificate_key file;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n stream, server
\n

\nSpecifies a file with the secret key in the PEM format\nused for authentication to another cluster server.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n zone_sync_ssl_ciphers ciphers;
\n
\n Default:\n \n
zone_sync_ssl_ciphers DEFAULT;
\n
\n Context:\n \n stream, server
\n

\nSpecifies the enabled ciphers for connections to another cluster server.\nThe ciphers are specified in the format understood by the OpenSSL library.\n

\nThe full list can be viewed using the\n“openssl ciphers” command.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n zone_sync_ssl_conf_command name value;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n stream, server
\n

This directive appeared in version 1.19.4.\n

\nSets arbitrary OpenSSL configuration\ncommands\nwhen establishing a connection with another cluster server.\n

\nThe directive is supported when using OpenSSL 1.0.2 or higher.\n

\n

\nSeveral zone_sync_ssl_conf_command directives\ncan be specified on the same level.\nThese directives are inherited from the previous configuration level\nif and only if there are\nno zone_sync_ssl_conf_command directives\ndefined on the current level.\n

\n

\nNote that configuring OpenSSL directly\nmight result in unexpected behavior.\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n zone_sync_ssl_crl file;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n stream, server
\n

\nSpecifies a file with revoked certificates (CRL)\nin the PEM format used to verify\nthe certificate of another cluster server.\nWhen using intermediate certificates, their CRLs should be\nspecified in the same file.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n zone_sync_ssl_name name;
\n
\n Default:\n \n
zone_sync_ssl_name host from zone_sync_server;
\n
\n Context:\n \n stream, server
\n

This directive appeared in version 1.15.7.\n

\nAllows overriding the server name used to\nverify\nthe certificate of a cluster server and to be\npassed through SNI\nwhen establishing a connection with the cluster server.\n

\nBy default, the host part of the zone_sync_server address is used,\nor resolved IP address if the resolve parameter is specified.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n zone_sync_ssl_password_file file;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n stream, server
\n

\nSpecifies a file with passphrases for\nsecret keys\nwhere each passphrase is specified on a separate line.\nPassphrases are tried in turn when loading the key.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n zone_sync_ssl_protocols \n [SSLv2]\n [SSLv3]\n [TLSv1]\n [TLSv1.1]\n [TLSv1.2]\n [TLSv1.3];
\n
\n Default:\n \n
zone_sync_ssl_protocols TLSv1.2 TLSv1.3;
\n
\n Context:\n \n stream, server
\n

\nEnables the specified protocols for connections to another cluster server.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n zone_sync_ssl_server_name on | off;
\n
\n Default:\n \n
zone_sync_ssl_server_name off;
\n
\n Context:\n \n stream, server
\n

This directive appeared in version 1.15.7.\n

\nEnables or disables passing of the server name through\nTLS\nServer Name Indication extension (SNI, RFC 6066)\nwhen establishing a connection with another cluster server.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n zone_sync_ssl_trusted_certificate file;
\n
\n Default:\n \n \n —\n \n
\n Context:\n \n stream, server
\n

\nSpecifies a file with trusted CA certificates in the PEM format\nused to verify\nthe certificate of another cluster server.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n zone_sync_ssl_verify on | off;
\n
\n Default:\n \n
zone_sync_ssl_verify off;
\n
\n Context:\n \n stream, server
\n

\nEnables or disables verification of another cluster server certificate.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n zone_sync_ssl_verify_depth number;
\n
\n Default:\n \n
zone_sync_ssl_verify_depth 1;
\n
\n Context:\n \n stream, server
\n

\nSets the verification depth in another cluster server certificates chain.\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Syntax:\n \n zone_sync_timeout timeout;
\n
\n Default:\n \n
zone_sync_timeout 5s;
\n
\n Context:\n \n stream, server
\n

\nSets the timeout between two successive\nread or write operations on connection to another cluster node.\nIf no data is transmitted within this time, the connection is closed.\n

\n\n\n

API endpoints

\nThe synchronization status of a node is available via the\n/stream/zone_sync/\nendpoint of the API which returns the\nfollowing\nmetrics.\n

\n\n\n

Starting, stopping, removing a cluster node

\nTo start a new node, update a DNS record of a cluster hostname\nwith the IP address of the new node and start an instance.\nThe new node will discover other nodes from DNS or static configuration\nand will start sending updates to them.\nOther nodes will eventually discover the new node using DNS and\nstart pushing updates to it.\nIn case of static configuration,\nother nodes need to be reloaded in order to send updates to the new node.\n

\nTo stop a node, send the QUIT signal to the instance.\nThe node will finish zone synchronization\nand gracefully close open connections.\n

\nTo remove a node, update a DNS record of a cluster hostname\nand remove the IP address of the node.\nAll other nodes will eventually discover that the node is removed,\nclose connections to the node, and will no longer try to connect to it.\nAfter the node is removed, it can be stopped as described above.\nIn case of static configuration, other nodes need to be reloaded\nin order to stop sending updates to the removed node.\n

\n\n
\n", "encoding": "utf-8"} +{"path": "en\\docs\\stream\\stream_processing.html", "extension": ".html", "size_bytes": 4597, "content": "\nHow nginx processes a TCP/UDP session
\n\nPlanning your ingress-nginx migration? Start here:\nkubernetes.nginx.org.\n\n

How nginx processes a TCP/UDP session

\nA TCP/UDP session from a client is processed\nin successive steps called phases:\n\n

\n\n
\nPost-accept\n
\n
\nThe first phase after accepting a client connection.\nThe ngx_stream_realip_module\nmodule is invoked at this phase.\n
\n\n
\nPre-access\n
\n
\nPreliminary check for access.\nThe\nngx_stream_limit_conn_module\nand\nngx_stream_set_module\nmodules are invoked at this phase.\n
\n\n
\nAccess\n
\n
\nClient access limitation before actual data processing.\nAt this phase,\nthe ngx_stream_access_module\nmodule is invoked,\nfor njs,\nthe js_access directive\nis invoked.\n
\n\n
\nSSL\n
\n
\nTLS/SSL termination.\nThe ngx_stream_ssl_module\nmodule is invoked at this phase.\n
\n\n
\nPreread\n
\n
\nReading initial bytes of data into the\npreread buffer\nto allow modules such as\nngx_stream_ssl_preread_module\nanalyze the data before its processing.\nFor njs,\nthe js_preread directive\nis invoked at this phase.\n
\n\n
\nContent\n
\n
\nMandatory phase where data is actually processed, usually\nproxied to\nupstream servers,\nor a specified value\nis returned to a client.\nFor njs,\nthe js_filter directive\nis invoked at this phase.\n
\n\n
\nLog\n
\n
\nThe final phase\nwhere the result of a client session processing is recorded.\nThe ngx_stream_log_module\nmodule is invoked at this phase.\n
\n

\n\n

\n", "encoding": "utf-8"}