Commit 3be52cb0 authored by 周尚's avatar 周尚

优化数据同步接口 [完成]

parent 2b5305ba
No preview for this file type
No preview for this file type
No preview for this file type
...@@ -33,6 +33,7 @@ http { ...@@ -33,6 +33,7 @@ http {
lua_package_path "/Users/zhoush/openresty/nginx/lua/luabiz/?.lua;;";
init_by_lua_file "lua/luainit/init.lua"; init_by_lua_file "lua/luainit/init.lua";
# init_worker_by_lua_file "luabiz/settle/settle.lua"; # init_worker_by_lua_file "luabiz/settle/settle.lua";
...@@ -48,7 +49,7 @@ http { ...@@ -48,7 +49,7 @@ http {
# ssl_ciphers HIGH:!aNULL:!MD5; # ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on; # ssl_prefer_server_ciphers on;
set $server_dir /Users/zhoush/openresty/; set $server_dir /Users/zhoush/openresty;
# set $lua_dir lua/; # set $lua_dir lua/;
set $biz_dir lua/luabiz; set $biz_dir lua/luabiz;
set $logs_path $server_dir/nginx/logs; set $logs_path $server_dir/nginx/logs;
...@@ -78,6 +79,13 @@ http { ...@@ -78,6 +79,13 @@ http {
} }
} }
location /table_sync {
content_by_lua_block {
local tk_sync = loadmod("tk_sync")
tk_sync:sync()
}
}
location /echo { location /echo {
content_by_lua_block { content_by_lua_block {
......
...@@ -150,6 +150,11 @@ local function main() ...@@ -150,6 +150,11 @@ local function main()
local str = "" local str = ""
local resp = {} local resp = {}
if ngx.req.get_method() ~= "POST" then
return sync_err_tell(resp, "03", "Invalid Method")
end
local req = json.decode(ngx.var.request_body) local req = json.decode(ngx.var.request_body)
ok, err, msg, str = sync_bizz_switch(req) ok, err, msg, str = sync_bizz_switch(req)
......
local _CASHER = {}
local MODULE="S" -- Settle
-- 加载模块
local mysql = loadmod("resty.mysql")
local zx_base = loadmod("zx_base")
local json = loadmod('cjson')
local db_conf = "tk7_dbs.json"
-- 协和组
local tasks = {}
local function EOF()
zx_base:log(MODULE, "-----------------------> END[TK_CASHER]")
ngx.eof()
end
-- 门店信息
-- @param table tk_biz 节点机数据库对象
-- table tk_control 总控机数据库对象
-- @return nil
local function casher_sql(tk_biz, tk_control)
zx_base:log(MODULE, "-----------------------> START[TK_CASHER]")
-- 新建mysql连接
local db, err = mysql:new()
if not db then
zx_base:log(MODULE, "[TK_CASHER]", "failed to instantiate mysql: ", err)
return false
end
-- 连接节点机MySQL
local ok, err, errcode, sqlstate = db:connect{
host = tk_biz['host'],
port = tk_biz['port'],
database = tk_biz['database'],
user = tk_biz['user'],
password = tk_biz['password'],
timeout = tk_biz['timeout'],
charset = 'utf8'
}
if not ok then
zx_base:log(MODULE, "[TK_CASHER]", "failed to connect:", json.encode(tk_biz), ":",
err, ":", errcode, sqlstate)
return
end
-- 查询节点机
local sql = string.format([[SELECT * FROM tk_casher where update_time > %s]],
-- os.date("%Y%m%d000000", os.time()-24*60*60)
"20180716000000"
)
local cashers
cashers, err, errcode, sqlstate = db:query(sql)
if not cashers then
zx_base:log(MODULE, "[TK_CASHER]", sql)
zx_base:log(MODULE, "[TK_CASHER]", "failed to query:", json.encode(tk_biz), ":",
err, ":", errcode, ":", sqlstate, ".")
return
end
if #cashers == 0 then
ngx.say("no cashers found")
ngx.eof()
return
end
-- 重置MySQL连接
zx_base:close_db(db)
db, err = mysql:new()
if not db then
zx_base:log(MODULE, "[TK_CASHER]", "failed to instantiate mysql: ", err)
return false
end
-- 连接总控机MySQL
ok, err, errcode, sqlstate = db:connect{
host = tk_control['host'],
port = tk_control['port'],
database = tk_control['database'],
user = tk_control['user'],
password = tk_control['password'],
timeout = tk_control['timeout'],
charset = 'utf8'
}
if not ok then
zx_base:log(MODULE, "[TK_CASHER]", "failed to connect:", json.encode(tk_biz), ":", errcode, sqlstate)
return
end
-- 插入总控机
for i = 1, #cashers do
local casher = cashers[i]
local sql_result = zx_base:sql_concate("duplicate", "tk_casher", casher)
ok, err, errcode, sqlstate = db:query(sql_result)
if not ok then
zx_base:log(MODULE, "[TK_CASHER]", sql_result)
zx_base:log(MODULE, "[TK_CASHER]", "failed to query:", json.encode(tk_control), ":",
err, ":", errcode, ":", sqlstate, ".")
end
end
ngx.say("SUCCESS")
EOF()
end
local function async(tk_biz, tk_control)
local co = coroutine.wrap(
function()
casher_sql(tk_biz, tk_control)
end
)
table.insert(tasks, co)
end
local function dispatch()
local i = 1
while true do
if tasks[i] == nil then
if tasks[1] == nil then
break
end
i = 1
end
local res = tasks[i]()
if not res then
table.remove(tasks, i)
else
i = i + 1
end
end
end
function _CASHER.run()
local dbs_st = zx_base:db_read(db_conf)
for i = 1, #dbs_st.tk_biz do
async(dbs_st.tk_biz[i], dbs_st.tk_control)
end
dispatch()
end
return _CASHER
local _SHOP = {} local TK_SYNC = {}
local MODULE="S" -- Settle local MODULE="S" -- Settle
...@@ -14,57 +14,58 @@ local tasks = {} ...@@ -14,57 +14,58 @@ local tasks = {}
local function EOF() local function EOF()
zx_base:log(MODULE, "-----------------------> END[TK_SHOP]") zx_base:log(MODULE, "-----------------------> END[TK_SYNC]")
ngx.eof() ngx.eof()
end end
-- 门店信息 -- 信息
-- @param table tk_biz 节点机数据库对象 -- @param table tk_biz 节点机数据库对象
-- table tk_control 总控机数据库对象 -- table tk_control 总控机数据库对象
-- @return nil -- @return nil
local function shop_sql(tk_biz, tk_control) local function sync_sql(tk_biz, tk_control, tk_table, tk_database)
zx_base:log(MODULE, "-----------------------> START[TK_SHOP]") zx_base:log(MODULE, "-----------------------> START[TK_SYNC]")
-- 新建mysql连接 -- 新建mysql连接
local db, err = mysql:new() local db, err = mysql:new()
if not db then if not db then
zx_base:log(MODULE, "[TK_SHOP]", "failed to instantiate mysql: ", err) zx_base:log(MODULE, "[TK_SYNC]", "failed to instantiate mysql: ", err)
return false return false
end end
-- 连接节点机MySQL -- 连接节点机MySQL
local ok, err, errcode, sqlstate = db:connect{ local ok, err, errcode, sqlstate = db:connect{
host = tk_biz['host'], host = tk_biz['host'],
port = tk_biz['port'], port = tk_biz['port'],
database = tk_biz['database'], database = tk_database,
user = tk_biz['user'], user = tk_biz['user'],
password = tk_biz['password'], password = tk_biz['password'],
timeout = tk_biz['timeout'], timeout = tk_biz['timeout'],
charset = 'utf8' charset = 'utf8'
} }
if not ok then if not ok then
zx_base:log(MODULE, "[TK_SHOP]", "failed to connect:", json.encode(tk_biz), ":", zx_base:log(MODULE, "[TK_SYNC]", "failed to connect:", json.encode(tk_biz), ":",
err, ":", errcode, sqlstate) err, ":", errcode, sqlstate)
return return
end end
-- 查询节点机 -- 查询节点机
local sql = string.format([[SELECT * FROM tk_shop where update_time > %s]], local sql = string.format([[SELECT * FROM %s where update_time > %s]],
-- os.date("%Y%m%d000000", os.time()-24*60*60) -- os.date("%Y%m%d000000", os.time()-24*60*60)
tk_table,
"20180716000000" "20180716000000"
) )
local shops local syncs
shops, err, errcode, sqlstate = db:query(sql) syncs, err, errcode, sqlstate = db:query(sql)
if not shops then if not syncs then
zx_base:log(MODULE, "[TK_SHOP]", sql) zx_base:log(MODULE, "[TK_SYNC]", sql)
zx_base:log(MODULE, "[TK_SHOP]", "failed to query:", json.encode(tk_biz), ":", zx_base:log(MODULE, "[TK_SYNC]", "failed to query:", json.encode(tk_biz), ":",
err, ":", errcode, ":", sqlstate, ".") err, ":", errcode, ":", sqlstate, ".")
return return
end end
if #shops == 0 then if #syncs == 0 then
ngx.say("no shops found") ngx.say("no syncs found")
ngx.eof() ngx.eof()
return return
end end
...@@ -75,7 +76,7 @@ local function shop_sql(tk_biz, tk_control) ...@@ -75,7 +76,7 @@ local function shop_sql(tk_biz, tk_control)
zx_base:close_db(db) zx_base:close_db(db)
db, err = mysql:new() db, err = mysql:new()
if not db then if not db then
zx_base:log(MODULE, "[TK_SHOP]", "failed to instantiate mysql: ", err) zx_base:log(MODULE, "[TK_SYNC]", "failed to instantiate mysql: ", err)
return false return false
end end
-- 连接总控机MySQL -- 连接总控机MySQL
...@@ -89,20 +90,20 @@ local function shop_sql(tk_biz, tk_control) ...@@ -89,20 +90,20 @@ local function shop_sql(tk_biz, tk_control)
charset = 'utf8' charset = 'utf8'
} }
if not ok then if not ok then
zx_base:log(MODULE, "[TK_SHOP]", "failed to connect:", json.encode(tk_biz), ":", errcode, sqlstate) zx_base:log(MODULE, "[TK_SYNC]", "failed to connect:", json.encode(tk_biz), ":", errcode, sqlstate)
return return
end end
-- 插入总控机 -- 插入总控机
for i = 1, #shops do for i = 1, #syncs do
local shop = shops[i] local sync = syncs[i]
local sql_result = zx_base:sql_concate("duplicate", "tk_shop", shop) local sql_result = zx_base:sql_concate("duplicate", tk_table, sync)
ok, err, errcode, sqlstate = db:query(sql_result) ok, err, errcode, sqlstate = db:query(sql_result)
if not ok then if not ok then
zx_base:log(MODULE, "[TK_SHOP]", sql_result) zx_base:log(MODULE, "[TK_SYNC]", sql_result)
zx_base:log(MODULE, "[TK_SHOP]", "failed to query:", json.encode(tk_control), ":", zx_base:log(MODULE, "[TK_SYNC]", "failed to query:", json.encode(tk_control), ":",
err, ":", errcode, ":", sqlstate, ".") err, ":", errcode, ":", sqlstate, ".")
end end
end end
...@@ -112,10 +113,10 @@ local function shop_sql(tk_biz, tk_control) ...@@ -112,10 +113,10 @@ local function shop_sql(tk_biz, tk_control)
end end
local function async(tk_biz, tk_control) local function async(tk_biz, tk_control, tk_database, tk_table)
local co = coroutine.wrap( local co = coroutine.wrap(
function() function()
shop_sql(tk_biz, tk_control) sync_sql(tk_biz, tk_control, tk_database, tk_table)
end end
) )
table.insert(tasks, co) table.insert(tasks, co)
...@@ -140,12 +141,46 @@ local function dispatch() ...@@ -140,12 +141,46 @@ local function dispatch()
end end
end end
function _SHOP.run() function TK_SYNC.run()
local dbs_st = zx_base:db_read(db_conf) local dbs_st = zx_base:db_read(db_conf)
for i = 1, #dbs_st.tk_biz do for i = 1, #dbs_st.tk_biz do
async(dbs_st.tk_biz[i], dbs_st.tk_control) async(dbs_st.tk_biz[i], dbs_st.tk_control, dbs_st.tk_biz[i].database, "tk_shop")
async(dbs_st.tk_biz[i], dbs_st.tk_control, dbs_st.tk_biz[i].database, "tk_casher")
end end
dispatch() dispatch()
end end
return _SHOP function TK_SYNC.sync()
local dbs_st = zx_base:db_read(db_conf)
if ngx.req.get_method() ~= "POST" then
ngx.say(json.encode({mesgRetCode="A7", mesgRetDesc="invalid method"}))
else
local data = json.decode(ngx.var.request_body)
if data.mesgType ~= "table_sync" then
ngx.say(json.encode({mesgRetcode="N1", mesgRetDesc="mesgType invalid"}))
elseif data.dbHost == ngx.null then
ngx.say(json.encode({mesgRetCode="N0", mesgRetDesc="dbHost missing"}))
else
for i = 1, #dbs_st.tk_biz do
if dbs_st.tk_biz[i].host == data.dbHost then
if data.dbTable == ngx.null then
ngx.say(json.encode({mesgRetCode="N0", mesgRetDesc="dbTable missing"}))
else
async(dbs_st.tk_biz[i], dbs_st.tk_control, dbs_st.tk_biz[i].database, data.dbTable)
return ngx.say(json.encode({mesgRetCode="00", mesgRetDesc="SUCCESS"}))
end
end
end
ngx.say(json.encode({mesgRetCode="N1", mesgRetDesc="dbHost invalid"}))
end
end
ngx.eof()
end
return TK_SYNC
...@@ -10,7 +10,6 @@ local __loaded_mods = {} ...@@ -10,7 +10,6 @@ local __loaded_mods = {}
-- @param string namespace 模块名 -- @param string namespace 模块名
-- @return table 模块 -- @return table 模块
function _G.loadmod(namespace) function _G.loadmod(namespace)
package.path = package.path ..string.format(";nginx/%s/?.lua;;", ngx.var.biz_dir)
-- 查找系统模块 -- 查找系统模块
local module = __loaded_mods[namespace] local module = __loaded_mods[namespace]
...@@ -19,7 +18,8 @@ function _G.loadmod(namespace) ...@@ -19,7 +18,8 @@ function _G.loadmod(namespace)
end end
-- 查找项目模块 -- 查找项目模块
local p_namespace = ngx.var.biz_dir .. '.' .. namespace -- local p_namespace = ngx.var.biz_dir .. '.' .. namespace
local p_namespace = namespace
local p_module = __loaded_mods[p_namespace] local p_module = __loaded_mods[p_namespace]
if p_module then if p_module then
return p_module return p_module
......
...@@ -74,7 +74,7 @@ After all clients are serviced, old worker processes are shut down. ...@@ -74,7 +74,7 @@ After all clients are serviced, old worker processes are shut down.
Let’s illustrate this by example. Let’s illustrate this by example.
Imagine that nginx is run on FreeBSD 4.x and the command Imagine that nginx is run on FreeBSD and the command
ps axw -o pid,ppid,user,%cpu,vsz,wchan,command | egrep '(nginx|PID)' ps axw -o pid,ppid,user,%cpu,vsz,wchan,command | egrep '(nginx|PID)'
...@@ -264,8 +264,8 @@ the F<.oldbin> suffix from the file name with the process ID. ...@@ -264,8 +264,8 @@ the F<.oldbin> suffix from the file name with the process ID.
If upgrade was successful, then the old master process should be sent If upgrade was successful, then the QUIT signal should be sent to
the QUIT signal, and only new processes will stay: the old master process, and only new processes will stay:
PID PPID USER %CPU VSZ WCHAN COMMAND PID PPID USER %CPU VSZ WCHAN COMMAND
......
...@@ -115,7 +115,7 @@ images and requests starting with "E<sol>downloadE<sol>". ...@@ -115,7 +115,7 @@ images and requests starting with "E<sol>downloadE<sol>".
error_page 404 /404.html; error_page 404 /404.html;
location /404.html { location = /404.html {
root /spool/www; root /spool/www;
} }
......
...@@ -1342,7 +1342,7 @@ Example: ...@@ -1342,7 +1342,7 @@ Example:
error_page 404 /404.html; error_page 404 /404.html;
location /404.html { location = /404.html {
internal; internal;
} }
...@@ -2197,9 +2197,12 @@ C<reuseport> ...@@ -2197,9 +2197,12 @@ C<reuseport>
this parameter (1.9.1) instructs to create an individual listening socket this parameter (1.9.1) instructs to create an individual listening socket
for each worker process for each worker process
(using the C<SO_REUSEPORT> socket option), allowing a kernel (using the
C<SO_REUSEPORT> socket option on Linux 3.9+ and DragonFly BSD,
or C<SO_REUSEPORT_LB> on FreeBSDE<nbsp>12+), allowing a kernel
to distribute incoming connections between worker processes. to distribute incoming connections between worker processes.
This currently works only on Linux 3.9+ and DragonFly BSD. This currently works only on Linux 3.9+, DragonFly BSD,
and FreeBSD 12+ (1.15.1).
B<NOTE> B<NOTE>
......
...@@ -1221,7 +1221,7 @@ server has returned an invalid response. ...@@ -1221,7 +1221,7 @@ server has returned an invalid response.
This allows handling application errors in nginx, for example: This allows handling application errors in nginx, for example:
location /php { location /php/ {
fastcgi_pass backend:9000; fastcgi_pass backend:9000;
... ...
fastcgi_catch_stderr "PHP Fatal error"; fastcgi_catch_stderr "PHP Fatal error";
......
...@@ -278,11 +278,11 @@ instead of C<$uri> ...@@ -278,11 +278,11 @@ instead of C<$uri>
server { server {
... ...
location /hls { location /hls/ {
hls; hls;
hls_forward_args on; hls_forward_args on;
alias /var/videos; alias /var/videos/;
secure_link $arg_md5,$arg_expires; secure_link $arg_md5,$arg_expires;
secure_link_md5 "$secure_link_expires$hls_uri$remote_addr secret"; secure_link_md5 "$secure_link_expires$hls_uri$remote_addr secret";
......
...@@ -20,29 +20,9 @@ a subset of the JavaScript language. ...@@ -20,29 +20,9 @@ a subset of the JavaScript language.
This module is not built by default, it should be compiled with This module is not built by default.
the njs module using the Download and install instructions are available
C<--add-module> configuration parameter: L<here|njs_about>.
./configure --add-module=<value>path-to-njs</value>/nginx
The L<repository|http://hg.nginx.org/njs>
with the njs module can be cloned with the following command
(requires L<Mercurial|https://www.mercurial-scm.org> client):
hg clone http://hg.nginx.org/njs
This module can also be built as
L<dynamic|ngx_core_module>:
./configure --add-dynamic-module=<value>path-to-njs</value>/nginx
...@@ -53,6 +33,10 @@ L<dynamic|ngx_core_module>: ...@@ -53,6 +33,10 @@ L<dynamic|ngx_core_module>:
load_module modules/ngx_http_js_module.so;
...
http {
js_include http.js; js_include http.js;
js_set $foo foo; js_set $foo foo;
...@@ -66,9 +50,14 @@ L<dynamic|ngx_core_module>: ...@@ -66,9 +50,14 @@ L<dynamic|ngx_core_module>:
js_content baz; js_content baz;
} }
location /summary { location = /summary {
return 200 $summary; return 200 $summary;
} }
location = /hello {
js_content hello;
}
}
} }
...@@ -80,46 +69,50 @@ L<dynamic|ngx_core_module>: ...@@ -80,46 +69,50 @@ L<dynamic|ngx_core_module>:
The F<http.js> file: The F<http.js> file:
function foo(req, res) { function foo(r) {
req.log("hello from foo() handler"); r.log("hello from foo() handler");
return "foo"; return "foo";
} }
function summary(req, res) { function summary(r) {
var a, s, h; var a, s, h;
s = "JS summary\n\n"; s = "JS summary\n\n";
s += "Method: " + req.method + "\n"; s += "Method: " + r.method + "\n";
s += "HTTP version: " + req.httpVersion + "\n"; s += "HTTP version: " + r.httpVersion + "\n";
s += "Host: " + req.headers.host + "\n"; s += "Host: " + r.headersIn.host + "\n";
s += "Remote Address: " + req.remoteAddress + "\n"; s += "Remote Address: " + r.remoteAddress + "\n";
s += "URI: " + req.uri + "\n"; s += "URI: " + r.uri + "\n";
s += "Headers:\n"; s += "Headers:\n";
for (h in req.headers) { for (h in r.headersIn) {
s += " header '" + h + "' is '" + req.headers[h] + "'\n"; s += " header '" + h + "' is '" + r.headersIn[h] + "'\n";
} }
s += "Args:\n"; s += "Args:\n";
for (a in req.args) { for (a in r.args) {
s += " arg '" + a + "' is '" + req.args[a] + "'\n"; s += " arg '" + a + "' is '" + r.args[a] + "'\n";
} }
return s; return s;
} }
function baz(req, res) { function baz(r) {
res.headers.foo = 1234; r.status = 200;
res.status = 200; r.headersOut.foo = 1234;
res.contentType = "text/plain; charset=utf-8"; r.headersOut['Content-Type'] = "text/plain; charset=utf-8";
res.contentLength = 15; r.headersOut['Content-Length'] = 15;
res.sendHeader(); r.sendHeader();
res.send("nginx"); r.send("nginx");
res.send("java"); r.send("java");
res.send("script"); r.send("script");
res.finish(); r.finish();
}
function hello(r) {
r.return(200, "Hello world!");
} }
...@@ -196,13 +189,12 @@ Sets an njs function for the specified variable. ...@@ -196,13 +189,12 @@ Sets an njs function for the specified variable.
=head1 Request and Response Arguments =head1 Request Argument
Each HTTP njs handler receives two arguments, Each HTTP njs handler receives one argument, a request
L<request|njs_api> L<object|njs_api>.
and L<response|njs_api>.
......
...@@ -30,7 +30,7 @@ Responses to mirror subrequests are ignored. ...@@ -30,7 +30,7 @@ Responses to mirror subrequests are ignored.
proxy_pass http://backend; proxy_pass http://backend;
} }
location /mirror { location = /mirror {
internal; internal;
proxy_pass http://test_backend$request_uri; proxy_pass http://test_backend$request_uri;
} }
...@@ -112,7 +112,7 @@ directives will be disabled. ...@@ -112,7 +112,7 @@ directives will be disabled.
proxy_pass http://backend; proxy_pass http://backend;
} }
location /mirror { location = /mirror {
internal; internal;
proxy_pass http://log_backend; proxy_pass http://log_backend;
proxy_pass_request_body off; proxy_pass_request_body off;
......
...@@ -606,7 +606,7 @@ L<ngx_http_core_module> ...@@ -606,7 +606,7 @@ L<ngx_http_core_module>
directive (1.13.10): directive (1.13.10):
location /remote { location /remote/ {
subrequest_output_buffer_size 64k; subrequest_output_buffer_size 64k;
... ...
} }
......
...@@ -31,7 +31,7 @@ configuration parameter. ...@@ -31,7 +31,7 @@ configuration parameter.
location /basic_status { location = /basic_status {
stub_status; stub_status;
} }
......
...@@ -1111,6 +1111,46 @@ commercial subscription. ...@@ -1111,6 +1111,46 @@ commercial subscription.
=head2 random
B<syntax:> random I<[C<two> [I<C<method>>]]>
B<context:> I<upstream>
This directive appeared in version 1.15.1.
Specifies that a group should use a load balancing method where a request
is passed to a randomly selected server, taking into account weights
of servers.
The optional C<two> parameter
instructs nginx to randomly select
L<two|https://homes.cs.washington.edu/~karlin/papers/balls.pdf>
servers and then choose a server
using the specified C<method>.
The default method is C<least_conn>
which passes a request to a server
with the least number of active connections.
=head2 sticky =head2 sticky
......
...@@ -254,9 +254,12 @@ C<reuseport> ...@@ -254,9 +254,12 @@ C<reuseport>
this parameter (1.9.1) instructs to create an individual listening socket this parameter (1.9.1) instructs to create an individual listening socket
for each worker process for each worker process
(using the C<SO_REUSEPORT> socket option), allowing a kernel (using the
C<SO_REUSEPORT> socket option on Linux 3.9+ and DragonFly BSD,
or C<SO_REUSEPORT_LB> on FreeBSD 12+), allowing a kernel
to distribute incoming connections between worker processes. to distribute incoming connections between worker processes.
This currently works only on Linux 3.9+ and DragonFly BSD. This currently works only on Linux 3.9+, DragonFly BSD,
and FreeBSD 12+ (1.15.1).
B<NOTE> B<NOTE>
......
...@@ -19,29 +19,9 @@ a subset of the JavaScript language. ...@@ -19,29 +19,9 @@ a subset of the JavaScript language.
This module is not built by default, it should be compiled with This module is not built by default.
the njs module using the Download and install instructions are available
C<--add-module> configuration parameter: L<here|njs_about>.
./configure --add-module=<value>path-to-njs</value>/nginx
The L<repository|http://hg.nginx.org/njs>
with the njs module can be cloned with the following command
(requires L<Mercurial|https://www.mercurial-scm.org> client):
hg clone http://hg.nginx.org/njs
This module can also be built as
L<dynamic|ngx_core_module>:
./configure --add-dynamic-module=<value>path-to-njs</value>/nginx
...@@ -52,6 +32,9 @@ L<dynamic|ngx_core_module>: ...@@ -52,6 +32,9 @@ L<dynamic|ngx_core_module>:
load_module modules/ngx_stream_js_module.so;
...
stream { stream {
js_include stream.js; js_include stream.js;
......
...@@ -81,6 +81,28 @@ Selecting an upstream based on protocol: ...@@ -81,6 +81,28 @@ Selecting an upstream based on protocol:
Selecting an upstream based on SSL protocol version:
map $ssl_preread_protocol $upstream {
"" ssh.example.com:22;
"TLSv1.2" new.example.com:443;
default tls.example.com:443;
}
# ssh and https on the same port
server {
listen 192.168.0.1:443;
proxy_pass $upstream;
ssl_preread on;
}
=head1 Directives =head1 Directives
=head2 ssl_preread =head2 ssl_preread
...@@ -119,6 +141,15 @@ the L<preread|stream_processing> phase. ...@@ -119,6 +141,15 @@ the L<preread|stream_processing> phase.
=item C<$ssl_preread_protocol>
the highest SSL protocol version supported by the client (1.15.2)
=item C<$ssl_preread_server_name> =item C<$ssl_preread_server_name>
......
...@@ -651,11 +651,15 @@ weighted round-robin balancing method. ...@@ -651,11 +651,15 @@ weighted round-robin balancing method.
If the C<connect> parameter is specified, If the C<connect> parameter is specified,
time to connect to the upstream server is used. time to
connect
to the upstream server is used.
If the C<first_byte> parameter is specified, If the C<first_byte> parameter is specified,
time to receive the first byte of data is used. time to receive the
first byte of data is used.
If the C<last_byte> is specified, If the C<last_byte> is specified,
time to receive the last byte of data is used. time to receive the
last byte of data is used.
If the C<inflight> parameter is specified (1.11.6), If the C<inflight> parameter is specified (1.11.6),
incomplete connections are also taken into account. incomplete connections are also taken into account.
...@@ -682,6 +686,46 @@ commercial subscription. ...@@ -682,6 +686,46 @@ commercial subscription.
=head2 random
B<syntax:> random I<[C<two> [I<C<method>>]]>
B<context:> I<upstream>
This directive appeared in version 1.15.1.
Specifies that a group should use a load balancing method where a connection
is passed to a randomly selected server, taking into account weights
of servers.
The optional C<two> parameter
instructs nginx to randomly select
L<two|https://homes.cs.washington.edu/~karlin/papers/balls.pdf>
servers and then choose a server
using the specified C<method>.
The default method is C<least_conn>
which passes a connection to a server
with the least number of active connections.
=head1 Embedded Variables =head1 Embedded Variables
......
...@@ -20,6 +20,567 @@ for extending nginx functionality. ...@@ -20,6 +20,567 @@ for extending nginx functionality.
=head1 Core =head1 Core
=head2 String
There are two types of strings:
a C<Unicode string> (default) and
a C<byte string>.
A C<Unicode string> corresponds to an ECMAScript string
which contains Unicode characters.
C<Byte strings> contain a sequence of bytes.
They are used to serialize Unicode strings
to external data and deserialize from external sources.
For example, the toUTF8() method serializes
a Unicode string to a byte string using UTF8 encoding:
>> '£'.toUTF8().toString('hex')
c2a3 /* C2 A3 is the UTF8 representation of 00A3 ('£') code point */
The toBytes() method serializes
a Unicode string with code points up to 255 into a byte string,
otherwise, C<null> is returned:
>> '£'.toBytes().toString('hex')
a3 /* a3 is a byte equal to 00A3 ('£') code point */
Only byte strings can be converted to different encodings.
For example, a string cannot be encoded to C<hex> directly:
>> 'αβγδ'.toString('base64')
TypeError: argument must be a byte string
at String.prototype.toString (native)
at main (native)
To convert a Unicode string to hex,
first, it should be converted to a byte string and then to hex:
>> 'αβγδ'.toUTF8().toString('base64')
zrHOss6zzrQ=
=over
=item C<String.fromCodePoint(I<C<codePoint1>>[, ...[,
I<C<codePoint2>>]])>
Returns a string from one or more Unicode code points.
>> String.fromCodePoint(97, 98, 99, 100)
abcd
=item C<String.prototype.concat(I<C<string1>>[, ...,
I<C<stringN>>])>
Returns a string that contains the concatenation of specified
C<strings>.
>> "a".concat("b", "c")
abc
=item C<String.prototype.endsWith(I<C<searchString>>[,
I<C<length>>])>
Returns C<true> if a string ends with the characters
of a specified string, otherwise C<false>.
The optional C<length> parameter is the the length of string.
If omitted, the default value is the length of the string.
>> 'abc'.endsWith('abc')
true
>> 'abca'.endsWith('abc')
false
=item C<String.prototype.fromBytes(I<C<start>>[,
I<C<end>>])>
(njs specific) Returns a new Unicode string from a byte string
where each byte is replaced with a corresponding Unicode code point.
=item C<String.prototype.fromUTF8(I<C<start>>[,
I<C<end>>])>
(njs specific) Converts a byte string containing a valid UTF8 string
into a Unicode string,
otherwise C<null> is returned.
=item C<String.prototype.includes(I<C<searchString>>[,
I<C<position>>]))>
Returns C<true> if a string is found within another string,
otherwise C<false>.
The optional C<position> parameter is the position
within the string at which to begin search for C<searchString>.
Default value is 0.
>> 'abc'.includes('bc')
true
=item C<String.prototype.indexOf(I<C<searchString>>[,
I<C<fromIndex>>])>
Returns the position of the first occurrence
of the C<searchString>
The search is started at C<fromIndex>.
Returns I<C<-1>> if the value is not found.
The C<fromIndex> is an integer,
default value is 0.
If C<fromIndex> is lower than 0
or greater than
String.prototype.lengthI<C<>>,
the search starts at index I<C<0>> and
I<C<String.prototype.length>>.
>> 'abcdef'.indexOf('de', 2)
3
=item C<String.prototype.lastIndexOf(I<C<searchString>>[,
I<C<fromIndex>>])>
Returns the position of the last occurrence
of the C<searchString>,
searching backwards from C<fromIndex>.
Returns I<C<-1>> if the value is not found.
If C<searchString> is empty,
then C<fromIndex> is returned.
>> "nginx".lastIndexOf("gi")
1
=item C<String.prototype.length>
Returns the length of the string.
>> 'αβγδ'.length
4
=item C<String.prototype.match([I<C<regexp>>])>
Matches a string against a C<regexp>.
>> 'nginx'.match( /ng/i )
ng
=item C<String.prototype.repeat(I<C<number>>)>
Returns a string
with the specified C<number> of copies of the string.
>> 'abc'.repeat(3)
abcabcabc
=item C<String.prototype.replace([I<C<regexp>>E<verbar>I<C<string>>[,
I<C<string>>E<verbar>I<C<function>>]])>
Returns a new string with matches of a pattern
(C<string> or a C<regexp>)
replaced by a C<string> or a C<function>.
>> 'abcdefgh'.replace('d', 1)
abc1efgh
=item C<String.prototype.search([I<C<regexp>>])>
Searches for a string using a C<regexp>
>> 'abcdefgh'.search('def')
3
=item C<String.prototype.slice(I<C<start>>[,
I<C<end>>])>
Returns a new string containing a part of an
original string between C<start>
and C<end> or
from C<start> to the end of the string.
>> 'abcdefghijklmno'.slice(NaN, 5)
abcde
=item C<String.prototype.startsWith(I<C<searchString>>[,
I<C<position>>])>
Returns C<true> if a string begins with the characters
of a specified string, otherwise C<false>.
The optional C<position> parameter is the position
in this string at which to begin search for C<searchString>.
Default value is 0.
>> 'abc'.startsWith('abc')
true
> 'aabc'.startsWith('abc')
false
=item C<String.prototype.substr(I<C<start>>[,
I<C<length>>])>
Returns the part of the string of the specified C<length>
from C<start>
or from C<start> to the end of the string.
>> 'abcdefghijklmno'.substr(3, 5)
defgh
=item C<String.prototype.substring(I<C<start>>[,
I<C<end>>])>
Returns the part of the string between
C<start> and C<end> or
from C<start> to the end of the string.
>> 'abcdefghijklmno'.substring(3, 5)
de
=item C<String.prototype.toBytes(start[,
end])>
(njs specific) Serializes a Unicode string to a byte string.
Returns C<null> if a character larger than 255 is
found in the string.
=item C<String.prototype.toLowerCase()>
Converts a string to lower case.
The method supports only simple Unicode folding.
>> 'ΑΒΓΔ'.toLowerCase()
αβγδ
=item C<String.prototype.toString([I<C<encoding>>])>
If no C<encoding> is specified,
returns a specified Unicode string or byte string as in ECMAScript.
(njs specific) If C<encoding> is specified,
encodes a byte string to
C<hex>,
C<base64>, or
C<base64url>.
>> 'αβγδ'.toUTF8().toString('base64url')
zrHOss6zzrQ
=item C<String.prototype.toUpperCase()>
Converts a string to upper case.
The method supports only simple Unicode folding.
>> 'αβγδ'.toUpperCase()
ΑΒΓΔ
=item C<String.prototype.toUTF8(I<C<start>>[,
I<C<end>>])>
(njs specific) Serializes a Unicode string
to a byte string using UTF8 encoding.
>> 'αβγδ'.toUTF8().length
8
>> 'αβγδ'.length
4
=item C<String.prototype.trim()>
Removes whitespaces from both ends of a string.
>> ' abc '.trim()
abc
=item C<String.prototype.split(([I<C<string>>E<verbar>I<C<regexp>>[,
I<C<limit>>]]))>
Returns match of a string against a C<regexp>.
The optional C<limit> parameter is an integer that specifies
a limit on the number of splits to be found.
>> 'abc'.split('')
a,b,c
=item C<encodeURI(I<C<URI>>)>
encodes a URI by replacing each instance of certain characters by
one, two, three, or four escape sequences
representing the UTF-8 encoding of the character
>> encodeURI('012αβγδ')
012%CE%B1%CE%B2%CE%B3%CE%B4
=item C<encodeURIComponent(I<C<encodedURIString>>)>
Encodes a URI by replacing each instance of certain characters
by one, two, three, or four escape sequences
representing the UTF-8 encoding of the character.
>> encodeURIComponent('[@?=')
%5B%40%3F%3D
=item C<decodeURI(I<C<encodedURI>>)>
Decodes a previously encoded URI.
>> decodeURI('012%CE%B1%CE%B2%CE%B3%CE%B4')
012αβγδ
=item C<decodeURIComponent(I<C<decodedURIString>>)>
Decodes an encoded component of a previously encoded URI.
>> decodeURIComponent('%5B%40%3F%3D')
[@?=
=back
=head2 JSON =head2 JSON
...@@ -274,180 +835,220 @@ If encoding is not provided, a byte string is returned. ...@@ -274,180 +835,220 @@ If encoding is not provided, a byte string is returned.
=head1 HTTP =head2 Timers
The C<HTTP> objects are available only in the
L<ngx_http_js_module|ngx_http_js_module> module.
=over
=head2 Request =item C<clearTimeout(I<C<timeout>>)>
=over Cancels a C<timeout> object
created by setTimeout().
=item C<req.uri> =item C<setTimeout(I<C<function>>,
I<C<ms>>[, I<C<arg1>>, I<C<argN>>])>
current URI in a request, read-only Calls a C<function>
after a specified number of C<milliseconds>.
One or more optional C<arguments>
can be passed to the specified function.
Returns a C<timeout> object.
function handler(v)
{
// ...
}
=item C<req.method> t = setTimeout(handler, 12);
// ...
clearTimeout(t);
request method, read-only
=item C<req.httpVersion>
=back
HTTP version, read-only
=item C<req.remoteAddress> =head2 File System
The File System module provides operations with files.
The module object is returned by C<require('fs')>.
client address, read-only =over
=item C<req.headers{}> =item C<appendFileSync(I<C<filename>>,
I<C<data>>[, I<C<options>>])>
request headers object, read-only. Synchronously appends specified C<data>
to a file with provided C<filename>.
If the file does not exist, it will be created.
The C<options> parameter is expected to be
an object with the following keys:
=over
For example, the C<Header-Name> header
can be accessed with the syntax C<headers['Header-Name']>
or C<headers.Header_name>
=item C<mode>
=item C<req.args{}>
mode option, by default is C<0o666>
request arguments object, read-only =item C<flag>
=item C<request.variables{}>
file system flag,
by default is C<a>
nginx variables object, read-only
=back
=item C<req.response>
=item C<readFileSync(I<C<filename>>[,
I<C<options>>])>
the response object (0.2.0), read-only
=item C<req.log(I<C<string>>)> Synchronously returns the contents of the file
with provided C<filename>.
The C<options> parameter holds
C<string> that specifies encoding.
If not specified, a byte string is returned.
If C<utf8> encoding is specified, a Unicode string is returned.
Otherwise, C<options> is expected to be
an object with the following keys:
=over
writes a C<string> to the error log =item C<encoding>
on the C<info> level of logging
=item C<req.warn(I<C<string>>)>
encoding, by default is not specified.
The encoding can be C<utf8>
writes a C<string> to the error log =item C<flag>
on the C<warning> level of logging (0.2.0)
=item C<req.error(I<C<string>>)>
file system flag,
by default is C<r>
writes a C<string> to the error log
on the C<error> level of logging (0.2.0)
=back
=item C<req.subrequest(I<C<uri>>[,
I<C<options>>[, I<C<callback>>]])>
>> var fs = require('fs')
undefined
>> var file = fs.readFileSync('/file/path.tar.gz')
undefined
>> var gzipped = /^\x1f\x8b/.test(file); gzipped
true
creates a subrequest with the given C<uri> and
C<options>, and installs
an optional completion C<callback> (0.2.0).
If C<options> is a string, then it =item C<writeFileSync(I<C<filename>>,
holds the subrequest arguments string. I<C<data>>[,
Otherwise, C<options> is expected to be I<C<options>>])>
an object with the following keys:
Synchronously writes C<data> to a file
with provided C<filename>.
If the file does not exist, it will be created,
if the file exists, it will be replaced.
The C<options> parameter is expected to be
an object with the following keys:
=over =over
=item C<args> =item C<mode>
arguments string mode option, by default is C<0o666>
=item C<body> =item C<flag>
request body file system flag,
by default is C<w>
=item C<method>
=back
HTTP method >> var fs = require('fs')
undefined
>> var file = fs.writeFileSync('hello.txt', 'Hello world')
undefined
...@@ -459,11 +1060,110 @@ HTTP method ...@@ -459,11 +1060,110 @@ HTTP method
The completion C<callback> =head3 File System Flags
receives a reply object.
The C<flag> option can accept the following values:
=over
=item *
C<a>E<mdash>open a file for appending.
The file is created if it does not exist
=item *
C<ax>E<mdash>the same as C<a>
but fails if the file already exists
=item *
C<a+>E<mdash>open a file for reading and appending.
If the file does not exist, it will be created
=item *
C<ax+>E<mdash>the same as C<a+>
but fails if the file already exists
=item *
C<as>E<mdash>open a file for appending in synchronous mode.
If the file does not exist, it will be created
=item *
C<as+>E<mdash>open a file for reading and appending
in synchronous mode.
If the file does not exist, it will be created
=item *
C<r>E<mdash>open a file for reading.
An exception occurs if the file does not exist
=item *
C<r+>E<mdash>open a file for reading and writing.
An exception occurs if the file does not exist
=item *
C<rs+>E<mdash>open a file for reading and writing
in synchronous mode.
Instructs the operating system to bypass the local file system cache
=item *
C<w>E<mdash>open a file for writing.
If the file does not exist, it will be created.
If the file exists, it will be replaced
=item *
C<wx>E<mdash>the same as C<w>
but fails if the file already exists
=item *
C<w+>E<mdash>open a file for reading and writing.
If the file does not exist, it will be created.
If the file exists, it will be replaced
=item *
C<wx+>E<mdash>the same as C<w+>
but fails if the file already exists
...@@ -474,199 +1174,273 @@ receives a reply object. ...@@ -474,199 +1174,273 @@ receives a reply object.
=head2 Response =head1 HTTP Request
The HTTP request object is available only in the
L<ngx_http_js_module|ngx_http_js_module> module.
All string properties of the object are byte strings.
=over =over
=item C<res.status> =item C<r.args{}>
request arguments object, read-only
response status, writable
=item C<r.error(I<C<string>>)>
=item C<res.headers{}>
writes a C<string> to the error log
on the C<error> level of logging
response headers object
=item C<r.finish()>
=item C<res.contentType>
finishes sending a response to the client
the response C<Content-Type> header field value, writable
=item C<r.headersIn{}>
=item C<res.contentLength>
incoming headers object, read-only.
the response C<Content-Length> header field value, writable
For example, the C<Foo> header
can be accessed with the syntax C<headersIn.foo>
or C<headersIn['Foo']>
=item C<res.sendHeader()>
=item C<r.headersOut{}>
sends the HTTP header to the client
=item C<res.send(I<C<string>>)> outgoing headers object, writable.
For example, the C<Foo> header
can be accessed with the syntax C<headersOut.foo>
or C<headersOut['Foo']>
sends a part of the response body to the client
=item C<res.finish()> =item C<r.httpVersion>
finishes sending a response to the client HTTP version, read-only
=item C<r.log(I<C<string>>)>
=item C<res.return(status[, string])>
writes a C<string> to the error log
on the C<info> level of logging
sends
the entire response with the specified C<status> to the client
(0.2.0)
=item C<r.internalRedirect(I<C<uri>>)>
It is possible to specify either a redirect URL
(for codes 301, 302, 303, 307, and 308)
or the response body text (for other codes) as the second argument
performs an internal redirect to the specified C<uri>.
If the uri starts with the “C<@>” prefix,
it is considered a named location.
=back =item C<r.method>
HTTP method, read-only
=head2 Reply
=item C<r.parent>
=over
references the parent request object
=item C<r.remoteAddress>
=item C<reply.uri>
client address, read-only
current URI in a reply, read-only
=item C<r.requestBody>
=item C<reply.method>
holds the request body, read-only
reply method, read-only
=item C<r.responseBody>
=item C<reply.status>
holds the subrequest response body, read-only.
The size of C<r.responseBody> is limited by the
L<ngx_http_core_module>
directive.
reply status, writable
=item C<r.return(status[, string])>
=item C<reply.contentType>
sends the entire response
with the specified C<status> to the client
the response C<Content-Type> header field value, writable
It is possible to specify either a redirect URL
(for codes 301, 302, 303, 307, and 308)
or the response body text (for other codes) as the second argument
=item C<reply.contentLength>
=item C<r.send(I<C<string>>)>
the response C<Content-Length> header field value, writable
=item C<reply.headers{}> sends a part of the response body to the client
=item C<r.sendHeader()>
reply headers object, read-only
sends the HTTP headers to the client
=item C<r.status>
status, writable
=item C<r.variables{}>
nginx variables object, read-only
=item C<r.warn(I<C<string>>)>
writes a C<string> to the error log
on the C<warning> level of logging
=back
=item C<r.uri>
current URI, read-only
Additionally, the C<reply> object has
the following properties: =item C<r.subrequest(I<C<uri>>[,
I<C<options>>[, I<C<callback>>]])>
creates a subrequest with the given C<uri> and
C<options>, and installs
an optional completion C<callback>.
If C<options> is a string, then it
holds the subrequest arguments string.
Otherwise, C<options> is expected to be
an object with the following keys:
=over =over
=item C<args>
arguments string
=item C<reply.body>
=item C<body>
holds the subrequest response body
request body
=item C<reply.parent>
=item C<method>
references the parent request object
HTTP method
...@@ -678,21 +1452,31 @@ references the parent request object ...@@ -678,21 +1452,31 @@ references the parent request object
=head1 Stream
The completion C<callback> receives
a subrequest response object with methods and properties
identical to the parent request object.
The C<stream> objects are available only in the
L<ngx_stream_js_module|ngx_stream_js_module> =back
module.
=head1 Stream Session
=head2 Session
The stream session object is available only in the
L<ngx_stream_js_module|ngx_stream_js_module>
module.
All string properties of the object are byte strings.
=over =over
...@@ -806,7 +1590,7 @@ on the C<info> level of logging ...@@ -806,7 +1590,7 @@ on the C<info> level of logging
writes a sent C<string> to the error log writes a sent C<string> to the error log
on the C<warning> level of logging (0.2.0) on the C<warning> level of logging
...@@ -816,7 +1600,7 @@ on the C<warning> level of logging (0.2.0) ...@@ -816,7 +1600,7 @@ on the C<warning> level of logging (0.2.0)
writes a sent C<string> to the error log writes a sent C<string> to the error log
on the C<error> level of logging (0.2.0) on the C<error> level of logging
...@@ -850,8 +1634,8 @@ on the C<error> level of logging (0.2.0) ...@@ -850,8 +1634,8 @@ on the C<error> level of logging (0.2.0)
The F<urldecode.js> file: The F<urldecode.js> file:
function decoded_foo(req, res) { function decoded_foo(r) {
return decodeURIComponent(req.args.foo); return decodeURIComponent(r.args.foo);
} }
...@@ -883,7 +1667,7 @@ The F<urldecode.js> file: ...@@ -883,7 +1667,7 @@ The F<urldecode.js> file:
The F<urlencode.js> file: The F<urlencode.js> file:
function encoded_foo(req, res) { function encoded_foo(r) {
return encodeURIComponent('foo & bar?'); return encodeURIComponent('foo & bar?');
} }
...@@ -892,6 +1676,40 @@ The F<urlencode.js> file: ...@@ -892,6 +1676,40 @@ The F<urlencode.js> file:
=head2 Internal Redirect
js_include redirect.js;
location /redirect {
js_content redirect;
}
location @named {
return 200 named;
}
The F<redirect.js> file:
function redirect(r) {
r.internalRedirect('@named');
}
=head2 Returning Fastest Response from Proxy =head2 Returning Fastest Response from Proxy
...@@ -921,17 +1739,17 @@ The F<urlencode.js> file: ...@@ -921,17 +1739,17 @@ The F<urlencode.js> file:
The F<fastresponse.js> file: The F<fastresponse.js> file:
function content(req, res) { function content(r) {
var n = 0; var n = 0;
function done(reply) { function done(res) {
if (n++ == 0) { if (n++ == 0) {
res.return(reply.status, reply.body); r.return(res.status, res.responseBody);
} }
} }
req.subrequest('/foo', req.variables.args, done); r.subrequest('/foo', r.variables.args, done);
req.subrequest('/bar', req.variables.args, done); r.subrequest('/bar', r.variables.args, done);
} }
...@@ -969,7 +1787,7 @@ The F<hs_jwt.js> file: ...@@ -969,7 +1787,7 @@ The F<hs_jwt.js> file:
return s + '.' + h.update(s).digest().toString('base64url'); return s + '.' + h.update(s).digest().toString('base64url');
} }
function jwt(req, res) { function jwt(r) {
var claims = { var claims = {
"iss" : "nginx", "iss" : "nginx",
"sub" : "alice", "sub" : "alice",
...@@ -1018,28 +1836,29 @@ The F<hs_jwt.js> file: ...@@ -1018,28 +1836,29 @@ The F<hs_jwt.js> file:
The F<subrequest.js> file: The F<subrequest.js> file:
function set_keyval(req, res) { function set_keyval(r) {
req.subrequest('/api/3/http/keyvals/foo', r.subrequest('/api/3/http/keyvals/foo',
{ method: 'POST', { method: 'POST',
body: JSON.stringify({ foo: 789, bar: "ss dd 00" })}, body: JSON.stringify({ foo: 789, bar: "ss dd 00" })},
function(reply) { function(res) {
if (reply.status >= 300) { if (res.status >= 300) {
res.return(reply.status, reply.body); r.return(res.status, res.responseBody);
return; return;
} }
res.return(500); r.return(500);
}); });
} }
function version(req, res) {
req.subrequest('/api/3/nginx', { method: 'GET' }, function(reply) { function version(r) {
if (reply.status != 200) { r.subrequest('/api/3/nginx', { method: 'GET' }, function(res) {
res.return(reply.status); if (res.status != 200) {
r.return(res.status);
return; return;
} }
var json = JSON.parse(reply.body); var json = JSON.parse(res.responseBody);
res.return(200, json.version); r.return(200, json.version);
}); });
} }
...@@ -1079,9 +1898,9 @@ The F<subrequest.js> file: ...@@ -1079,9 +1898,9 @@ The F<subrequest.js> file:
The F<hash.js> file: The F<hash.js> file:
function create_secure_link(req, res) { function create_secure_link(r) {
return require('crypto').createHash('md5') return require('crypto').createHash('md5')
.update(req.uri).update(" mykey") .update(r.uri).update(" mykey")
.digest('base64url'); .digest('base64url');
} }
......
...@@ -7,6 +7,236 @@ ...@@ -7,6 +7,236 @@
njs_changes - njs Changes njs_changes - njs Changes
=head1 Changes with 0.2.2
Release Date:
19 June 2018
nginx modules:
=over
=item *
Change:
merged HTTP C<Response> and C<Reply>
into L<HTTP Request|njs_api>.
New members of C<Request>:
=over
=item *
C<req.status> (C<res.status>)
=item *
C<req.parent> (C<reply.parent>)
=item *
C<req.requestBody> (C<req.body>)
=item *
C<req.responseBody> (C<reply.body>)
=item *
C<req.headersIn> (C<req.headers>)
=item *
C<req.headersOut> (C<res.headers>)
=item *
C<req.sendHeader()> (C<res.sendHeader()>)
=item *
C<req.send()> (C<res.send()>)
=item *
C<req.finish()> (C<res.finish()>)
=item *
C<req.return()> (C<res.return()>)
=back
Deprecated members of C<Request>:
=over
=item *
C<req.body> (use C<req.requestBody>
or C<req.responseBody>)
=item *
C<req.headers> (use C<req.headersIn>
or C<req.headersOut>)
=item *
C<req.response>
=back
The deprecated properties will be removed in next releases.
=item *
Feature:
HTTP L<internalRedirect()|njs_api>
method.
=back
Core:
=over
=item *
Bugfix:
fixed heap-buffer-overflow in C<crypto.createHmac()>.
=back
=head1 Changes with 0.2.1 =head1 Changes with 0.2.1
......
...@@ -38,9 +38,9 @@ module contributing_changes ...@@ -38,9 +38,9 @@ module contributing_changes
module control module control
section 18 899 name section 18 899 name
section 899 3111 changing configuration section 899 3107 changing configuration
section 3111 3735 rotating log-files section 3107 3731 rotating log-files
section 3735 7797 upgrading executable on the fly section 3731 7796 upgrading executable on the fly
module converting_rewrite_rules module converting_rewrite_rules
section 18 86 name section 18 86 name
...@@ -135,7 +135,7 @@ module events ...@@ -135,7 +135,7 @@ module events
section 18 1854 name section 18 1854 name
module example module example
section 18 4367 name section 18 4369 name
module faq module faq
section 18 325 name section 18 325 name
...@@ -323,7 +323,7 @@ module ngx_http_charset_module ...@@ -323,7 +323,7 @@ module ngx_http_charset_module
module ngx_http_core_module module ngx_http_core_module
aliases ngx_core aliases ngx_core
section 17 85 name section 17 85 name
section 85 63672 directives section 85 63773 directives
section 104 472 absolute_redirect section 104 472 absolute_redirect
section 472 2923 aio section 472 2923 aio
section 2923 3347 aio_write section 2923 3347 aio_write
...@@ -354,111 +354,111 @@ module ngx_http_core_module ...@@ -354,111 +354,111 @@ module ngx_http_core_module
section 16008 16043 exact section 16008 16043 exact
section 16043 16198 before section 16043 16198 before
section 16198 16794 ignore_invalid_headers section 16198 16794 ignore_invalid_headers
section 16794 18103 internal section 16794 18105 internal
section 18103 18934 keepalive_disable section 18105 18936 keepalive_disable
section 18934 19321 keepalive_requests section 18936 19323 keepalive_requests
section 19321 19996 keepalive_timeout section 19323 19998 keepalive_timeout
section 19996 20752 large_client_header_buffers section 19998 20754 large_client_header_buffers
section 20752 21592 limit_except section 20754 21594 limit_except
section 21592 22608 limit_rate section 21594 22610 limit_rate
section 22608 23088 limit_rate_after section 22610 23090 limit_rate_after
section 23088 23954 lingering_close section 23090 23956 lingering_close
section 23954 24368 lingering_time section 23956 24370 lingering_time
section 24368 24932 lingering_timeout section 24370 24934 lingering_timeout
section 24932 33675 listen section 24934 33776 listen
section 33675 37841 location section 33776 37942 location
section 37841 38104 log_not_found section 37942 38205 log_not_found
section 38104 38357 log_subrequest section 38205 38458 log_subrequest
section 38357 38809 max_ranges section 38458 38910 max_ranges
section 38809 39861 merge_slashes section 38910 39962 merge_slashes
section 39861 40176 msie_padding section 39962 40277 msie_padding
section 40176 40430 msie_refresh section 40277 40531 msie_refresh
section 40430 41687 open_file_cache section 40531 41788 open_file_cache
section 41687 41955 open_file_cache_errors section 41788 42056 open_file_cache_errors
section 41955 42347 open_file_cache_min_uses section 42056 42448 open_file_cache_min_uses
section 42347 42604 open_file_cache_valid section 42448 42705 open_file_cache_valid
section 42604 42945 output_buffers section 42705 43046 output_buffers
section 42945 43321 port_in_redirect section 43046 43422 port_in_redirect
section 43321 43669 postpone_output section 43422 43770 postpone_output
section 43669 44237 read_ahead section 43770 44338 read_ahead
section 44237 44553 recursive_error_pages section 44338 44654 recursive_error_pages
section 44553 44842 request_pool_size section 44654 44943 request_pool_size
section 44842 45523 reset_timedout_connection section 44943 45624 reset_timedout_connection
section 45523 46939 resolver section 45624 47040 resolver
section 46939 47194 resolver_timeout section 47040 47295 resolver_timeout
section 47194 47905 root section 47295 48006 root
section 47905 48596 satisfy section 48006 48697 satisfy
section 48596 49082 send_lowat section 48697 49183 send_lowat
section 49082 49502 send_timeout section 49183 49603 send_timeout
section 49502 50516 sendfile section 49603 50617 sendfile
section 50516 50880 sendfile_max_chunk section 50617 50981 sendfile_max_chunk
section 50880 51392 server section 50981 51493 server
section 51392 54126 server_name section 51493 54227 server_name
section 54126 54730 server_name_in_redirect section 54227 54831 server_name_in_redirect
section 54730 55110 server_names_hash_bucket_size section 54831 55211 server_names_hash_bucket_size
section 55110 55397 server_names_hash_max_size section 55211 55498 server_names_hash_max_size
section 55397 56129 server_tokens section 55498 56230 server_tokens
section 56129 56778 subrequest_output_buffer_size section 56230 56879 subrequest_output_buffer_size
section 56778 57207 tcp_nodelay section 56879 57308 tcp_nodelay
section 57207 57758 tcp_nopush section 57308 57859 tcp_nopush
section 57758 60807 try_files section 57859 60908 try_files
section 60807 61678 types section 60908 61779 types
section 61678 62101 types_hash_bucket_size section 61779 62202 types_hash_bucket_size
section 62101 62418 types_hash_max_size section 62202 62519 types_hash_max_size
section 62418 63055 underscores_in_headers section 62519 63156 underscores_in_headers
section 63055 63331 variables_hash_bucket_size section 63156 63432 variables_hash_bucket_size
section 63331 63672 variables_hash_max_size section 63432 63773 variables_hash_max_size
section 63672 70336 embedded variables section 63773 70437 embedded variables
section 63989 64061 $arg_i<name> section 64090 64162 $arg_i<name>
section 64061 64113 $args section 64162 64214 $args
section 64113 64267 $binary_remote_addr section 64214 64368 $binary_remote_addr
section 64267 64466 $body_bytes_sent section 64368 64567 $body_bytes_sent
section 64466 64542 $bytes_sent section 64567 64643 $bytes_sent
section 64542 64610 $connection section 64643 64711 $connection
section 64610 64715 $connection_requests section 64711 64816 $connection_requests
section 64715 64786 $content_length section 64816 64887 $content_length
section 64786 64853 $content_type section 64887 64954 $content_type
section 64853 64910 $cookie_i<name> section 64954 65011 $cookie_i<name>
section 64910 65007 $document_root section 65011 65108 $document_root
section 65007 65053 $document_uri section 65108 65154 $document_uri
section 65053 65227 $host section 65154 65328 $host
section 65227 65263 $hostname section 65328 65364 $hostname
section 65263 65439 $http_i<name> section 65364 65540 $http_i<name>
section 65439 65539 $https section 65540 65640 $https
section 65539 65637 $is_args section 65640 65738 $is_args
section 65637 65738 $limit_rate section 65738 65839 $limit_rate
section 65738 65832 $msec section 65839 65933 $msec
section 65832 65877 $nginx_version section 65933 65978 $nginx_version
section 65877 65924 $pid section 65978 66025 $pid
section 65924 66020 $pipe section 66025 66121 $pipe
section 66020 66264 $proxy_protocol_addr section 66121 66365 $proxy_protocol_addr
section 66264 66505 $proxy_protocol_port section 66365 66606 $proxy_protocol_port
section 66505 66552 $query_string section 66606 66653 $query_string
section 66552 66739 $realpath_root section 66653 66840 $realpath_root
section 66739 66783 $remote_addr section 66840 66884 $remote_addr
section 66783 66824 $remote_port section 66884 66925 $remote_port
section 66824 66902 $remote_user section 66925 67003 $remote_user
section 66902 66954 $request section 67003 67055 $request
section 66954 67242 $request_body section 67055 67343 $request_body
section 67242 67898 $request_body_file section 67343 67999 $request_body_file
section 67898 68003 $request_completion section 67999 68104 $request_completion
section 68003 68139 $request_filename section 68104 68240 $request_filename
section 68139 68249 $request_id section 68240 68350 $request_id
section 68249 68363 $request_length section 68350 68464 $request_length
section 68363 68449 $request_method section 68464 68550 $request_method
section 68449 68622 $request_time section 68550 68723 $request_time
section 68622 68694 $request_uri section 68723 68795 $request_uri
section 68694 68766 $scheme section 68795 68867 $scheme
section 68766 68948 $sent_http_i<name> section 68867 69049 $sent_http_i<name>
section 68948 69158 $sent_trailer_i<name> section 69049 69259 $sent_trailer_i<name>
section 69158 69414 $server_addr section 69259 69515 $server_addr
section 69414 69487 $server_name section 69515 69588 $server_name
section 69487 69560 $server_port section 69588 69661 $server_port
section 69560 69712 $server_protocol section 69661 69813 $server_protocol
section 69712 69972 $status section 69813 70073 $status
section 69972 70061 $time_iso8601 section 70073 70162 $time_iso8601
section 70061 70141 $time_local section 70162 70242 $time_local
section 70141 70336 $uri section 70242 70437 $uri
module ngx_http_dav_module module ngx_http_dav_module
aliases ngx_dav aliases ngx_dav
...@@ -489,7 +489,7 @@ module ngx_http_fastcgi_module ...@@ -489,7 +489,7 @@ module ngx_http_fastcgi_module
aliases ngx_fastcgi aliases ngx_fastcgi
section 17 188 name section 17 188 name
section 188 628 example configuration section 188 628 example configuration
section 628 39574 directives section 628 39575 directives
section 647 1912 fastcgi_bind section 647 1912 fastcgi_bind
section 1912 2409 fastcgi_buffer_size section 1912 2409 fastcgi_buffer_size
section 2409 3673 fastcgi_buffering section 2409 3673 fastcgi_buffering
...@@ -510,49 +510,49 @@ module ngx_http_fastcgi_module ...@@ -510,49 +510,49 @@ module ngx_http_fastcgi_module
section 15592 15975 fastcgi_cache_revalidate section 15592 15975 fastcgi_cache_revalidate
section 15975 17766 fastcgi_cache_use_stale section 15975 17766 fastcgi_cache_use_stale
section 17766 19656 fastcgi_cache_valid section 17766 19656 fastcgi_cache_valid
section 19656 20274 fastcgi_catch_stderr section 19656 20275 fastcgi_catch_stderr
section 20274 20603 fastcgi_connect_timeout section 20275 20604 fastcgi_connect_timeout
section 20603 20992 fastcgi_force_ranges section 20604 20993 fastcgi_force_ranges
section 20992 21484 fastcgi_hide_header section 20993 21485 fastcgi_hide_header
section 21484 21832 fastcgi_ignore_client_abort section 21485 21833 fastcgi_ignore_client_abort
section 21832 22951 fastcgi_ignore_headers section 21833 22952 fastcgi_ignore_headers
section 22951 23655 fastcgi_index section 22952 23656 fastcgi_index
section 23655 24070 fastcgi_intercept_errors section 23656 24071 fastcgi_intercept_errors
section 24070 24618 fastcgi_keep_conn section 24071 24619 fastcgi_keep_conn
section 24618 25251 fastcgi_limit_rate section 24619 25252 fastcgi_limit_rate
section 25251 26044 fastcgi_max_temp_file_size section 25252 26045 fastcgi_max_temp_file_size
section 26044 28542 fastcgi_next_upstream section 26045 28543 fastcgi_next_upstream
section 26563 26707 error section 26564 26708 error
section 26707 26858 timeout section 26708 26859 timeout
section 26858 26935 invalid_header section 26859 26936 invalid_header
section 26935 27006 http_500 section 26936 27007 http_500
section 27006 27077 http_503 section 27007 27078 http_503
section 27077 27148 http_403 section 27078 27149 http_403
section 27148 27219 http_404 section 27149 27220 http_404
section 27219 27300 http_429 section 27220 27301 http_429
section 27300 27616 non_idempotent section 27301 27617 non_idempotent
section 27616 28542 off section 27617 28543 off
section 28542 28899 fastcgi_next_upstream_timeout section 28543 28900 fastcgi_next_upstream_timeout
section 28899 29259 fastcgi_next_upstream_tries section 28900 29260 fastcgi_next_upstream_tries
section 29259 29809 fastcgi_no_cache section 29260 29810 fastcgi_no_cache
section 29809 31322 fastcgi_param section 29810 31323 fastcgi_param
section 31322 32137 fastcgi_pass section 31323 32138 fastcgi_pass
section 32137 32381 fastcgi_pass_header section 32138 32382 fastcgi_pass_header
section 32381 32717 fastcgi_pass_request_body section 32382 32718 fastcgi_pass_request_body
section 32717 33073 fastcgi_pass_request_headers section 32718 33074 fastcgi_pass_request_headers
section 33073 33525 fastcgi_read_timeout section 33074 33526 fastcgi_read_timeout
section 33525 34205 fastcgi_request_buffering section 33526 34206 fastcgi_request_buffering
section 34205 34717 fastcgi_send_lowat section 34206 34718 fastcgi_send_lowat
section 34717 35167 fastcgi_send_timeout section 34718 35168 fastcgi_send_timeout
section 35167 36069 fastcgi_split_path_info section 35168 36070 fastcgi_split_path_info
section 36069 37739 fastcgi_store section 36070 37740 fastcgi_store
section 37739 38229 fastcgi_store_access section 37740 38230 fastcgi_store_access
section 38229 38802 fastcgi_temp_file_write_size section 38230 38803 fastcgi_temp_file_write_size
section 38802 39574 fastcgi_temp_path section 38803 39575 fastcgi_temp_path
section 39574 40042 parameters passed to a fastcgi server section 39575 40043 parameters passed to a fastcgi server
section 40042 41202 embedded variables section 40043 41203 embedded variables
section 40221 41012 $fastcgi_script_name section 40222 41013 $fastcgi_script_name
section 41012 41202 $fastcgi_path_info section 41013 41203 $fastcgi_path_info
module ngx_http_flv_module module ngx_http_flv_module
aliases ngx_flv aliases ngx_flv
...@@ -698,13 +698,13 @@ module ngx_http_hls_module ...@@ -698,13 +698,13 @@ module ngx_http_hls_module
aliases ngx_hls aliases ngx_hls
section 17 1284 name section 17 1284 name
section 1284 1850 example configuration section 1284 1850 example configuration
section 1850 5659 directives section 1850 5661 directives
section 1869 1972 hls section 1869 1972 hls
section 1972 2256 hls_buffers section 1972 2256 hls_buffers
section 2256 4598 hls_forward_args section 2256 4600 hls_forward_args
section 4598 4861 hls_fragment section 4600 4863 hls_fragment
section 4861 5122 hls_mp4_buffer_size section 4863 5124 hls_mp4_buffer_size
section 5122 5659 hls_mp4_max_buffer_size section 5124 5661 hls_mp4_max_buffer_size
module ngx_http_image_filter_module module ngx_http_image_filter_module
aliases ngx_image_filter aliases ngx_image_filter
...@@ -734,13 +734,13 @@ module ngx_http_index_module ...@@ -734,13 +734,13 @@ module ngx_http_index_module
module ngx_http_js_module module ngx_http_js_module
aliases ngx_js aliases ngx_js
section 17 796 name section 17 351 name
section 796 2255 example configuration section 351 2080 example configuration
section 2255 2771 directives section 2080 2596 directives
section 2274 2455 js_content section 2099 2280 js_content
section 2455 2618 js_include section 2280 2443 js_include
section 2618 2771 js_set section 2443 2596 js_set
section 2771 2906 request and response arguments section 2596 2701 request argument
module ngx_http_keyval_module module ngx_http_keyval_module
aliases ngx_keyval aliases ngx_keyval
...@@ -835,10 +835,10 @@ module ngx_http_memcached_module ...@@ -835,10 +835,10 @@ module ngx_http_memcached_module
module ngx_http_mirror_module module ngx_http_mirror_module
aliases ngx_mirror aliases ngx_mirror
section 17 281 name section 17 281 name
section 281 511 example configuration section 281 513 example configuration
section 511 1696 directives section 513 1700 directives
section 530 811 mirror section 532 813 mirror
section 811 1696 mirror_request_body section 813 1700 mirror_request_body
module ngx_http_mp4_module module ngx_http_mp4_module
aliases ngx_mp4 aliases ngx_mp4
...@@ -1141,7 +1141,7 @@ module ngx_http_ssi_module ...@@ -1141,7 +1141,7 @@ module ngx_http_ssi_module
section 1556 1895 ssi_silent_errors section 1556 1895 ssi_silent_errors
section 1895 2253 ssi_types section 1895 2253 ssi_types
section 2253 2489 ssi_value_length section 2253 2489 ssi_value_length
section 2489 7931 ssi commands section 2489 7932 ssi commands
section 2683 2865 block section 2683 2865 block
section 2865 2992 name section 2865 2992 name
section 2992 3079 config section 2992 3079 config
...@@ -1158,13 +1158,13 @@ module ngx_http_ssi_module ...@@ -1158,13 +1158,13 @@ module ngx_http_ssi_module
section 5626 5972 virtual section 5626 5972 virtual
section 5972 6397 stub section 5972 6397 stub
section 6397 6633 wait section 6397 6633 wait
section 6633 7657 set section 6633 7658 set
section 7657 7754 set section 7658 7755 set
section 7754 7793 var section 7755 7794 var
section 7793 7931 value section 7794 7932 value
section 7931 8310 embedded variables section 7932 8311 embedded variables
section 8037 8176 $date_local section 8038 8177 $date_local
section 8176 8310 $date_gmt section 8177 8311 $date_gmt
module ngx_http_ssl_module module ngx_http_ssl_module
aliases ngx_ssl aliases ngx_ssl
...@@ -1358,22 +1358,22 @@ module ngx_http_status_module ...@@ -1358,22 +1358,22 @@ module ngx_http_status_module
module ngx_http_stub_status_module module ngx_http_stub_status_module
aliases ngx_stub_status aliases ngx_stub_status
section 17 331 name section 17 331 name
section 331 679 example configuration section 331 681 example configuration
section 679 995 directives section 681 997 directives
section 698 995 stub_status section 700 997 stub_status
section 995 1852 data section 997 1854 data
section 1066 1183 active connections section 1068 1185 active connections
section 1183 1256 accepts section 1185 1258 accepts
section 1256 1469 handled section 1258 1471 handled
section 1469 1531 requests section 1471 1533 requests
section 1531 1632 reading section 1533 1634 reading
section 1632 1746 writing section 1634 1748 writing
section 1746 1852 waiting section 1748 1854 waiting
section 1852 2276 embedded variables section 1854 2278 embedded variables
section 1985 2062 $connections_active section 1987 2064 $connections_active
section 2062 2129 $connections_reading section 2064 2131 $connections_reading
section 2129 2196 $connections_writing section 2131 2198 $connections_writing
section 2196 2276 $connections_waiting section 2198 2278 $connections_waiting
module ngx_http_sub_module module ngx_http_sub_module
aliases ngx_sub aliases ngx_sub
...@@ -1420,7 +1420,7 @@ module ngx_http_upstream_module ...@@ -1420,7 +1420,7 @@ module ngx_http_upstream_module
aliases ngx_upstream aliases ngx_upstream
section 17 387 name section 17 387 name
section 387 1639 example configuration section 387 1639 example configuration
section 1639 24710 directives section 1639 25325 directives
section 1658 2738 upstream section 1658 2738 upstream
section 2738 8252 server section 2738 8252 server
section 8252 9081 zone section 8252 9081 zone
...@@ -1432,29 +1432,30 @@ module ngx_http_upstream_module ...@@ -1432,29 +1432,30 @@ module ngx_http_upstream_module
section 16036 16472 least_conn section 16036 16472 least_conn
section 16472 17437 least_time section 16472 17437 least_time
section 17437 18336 queue section 17437 18336 queue
section 18336 24290 sticky section 18336 18951 random
section 19000 20413 cookie section 18951 24905 sticky
section 20413 20710 expires=time section 19615 21028 cookie
section 20710 20848 domain=domain section 21028 21325 expires=time
section 20848 20928 httponly section 21325 21463 domain=domain
section 20928 21005 secure section 21463 21543 httponly
section 21005 21179 path=path section 21543 21620 secure
section 21179 22577 route section 21620 21794 path=path
section 22577 24290 learn section 21794 23192 route
section 24290 24710 sticky_cookie_insert section 23192 24905 learn
section 24710 28504 embedded variables section 24905 25325 sticky_cookie_insert
section 24831 25517 $upstream_addr section 25325 29119 embedded variables
section 25517 25731 $upstream_bytes_received section 25446 26132 $upstream_addr
section 25731 25976 $upstream_cache_status section 26132 26346 $upstream_bytes_received
section 25976 26314 $upstream_connect_time section 26346 26591 $upstream_cache_status
section 26314 26541 $upstream_cookie_i<name> section 26591 26929 $upstream_connect_time
section 26541 26831 $upstream_header_time section 26929 27156 $upstream_cookie_i<name>
section 26831 27249 $upstream_http_i<name> section 27156 27446 $upstream_header_time
section 27249 27513 $upstream_queue_time section 27446 27864 $upstream_http_i<name>
section 27513 27773 $upstream_response_length section 27864 28128 $upstream_queue_time
section 27773 28049 $upstream_response_time section 28128 28388 $upstream_response_length
section 28049 28359 $upstream_status section 28388 28664 $upstream_response_time
section 28359 28504 $upstream_trailer_i<name> section 28664 28974 $upstream_status
section 28974 29119 $upstream_trailer_i<name>
module ngx_http_userid_module module ngx_http_userid_module
aliases ngx_userid aliases ngx_userid
...@@ -1690,38 +1691,38 @@ module ngx_stream_access_module ...@@ -1690,38 +1691,38 @@ module ngx_stream_access_module
module ngx_stream_core_module module ngx_stream_core_module
section 17 283 name section 17 283 name
section 283 1262 example configuration section 283 1262 example configuration
section 1262 9557 directives section 1262 9650 directives
section 1281 6028 listen section 1281 6121 listen
section 6028 6296 preread_buffer_size section 6121 6389 preread_buffer_size
section 6296 6561 preread_timeout section 6389 6654 preread_timeout
section 6561 6927 proxy_protocol_timeout section 6654 7020 proxy_protocol_timeout
section 6927 7934 resolver section 7020 8027 resolver
section 7934 8314 resolver_timeout section 8027 8407 resolver_timeout
section 8314 8422 server section 8407 8515 server
section 8422 8584 stream section 8515 8677 stream
section 8584 8907 tcp_nodelay section 8677 9000 tcp_nodelay
section 8907 9231 variables_hash_bucket_size section 9000 9324 variables_hash_bucket_size
section 9231 9557 variables_hash_max_size section 9324 9650 variables_hash_max_size
section 9557 12126 embedded variables section 9650 12219 embedded variables
section 9666 9820 $binary_remote_addr section 9759 9913 $binary_remote_addr
section 9820 9900 $bytes_received section 9913 9993 $bytes_received
section 9900 9961 $bytes_sent section 9993 10054 $bytes_sent
section 9961 10014 $connection section 10054 10107 $connection
section 10014 10050 $hostname section 10107 10143 $hostname
section 10050 10129 $msec section 10143 10222 $msec
section 10129 10174 $nginx_version section 10222 10267 $nginx_version
section 10174 10221 $pid section 10267 10314 $pid
section 10221 10319 $protocol section 10314 10412 $protocol
section 10319 10563 $proxy_protocol_addr section 10412 10656 $proxy_protocol_addr
section 10563 10804 $proxy_protocol_port section 10656 10897 $proxy_protocol_port
section 10804 10848 $remote_addr section 10897 10941 $remote_addr
section 10848 10889 $remote_port section 10941 10982 $remote_port
section 10889 11148 $server_addr section 10982 11241 $server_addr
section 11148 11224 $server_port section 11241 11317 $server_port
section 11224 11323 $session_time section 11317 11416 $session_time
section 11323 11976 $status section 11416 12069 $status
section 11976 12049 $time_iso8601 section 12069 12142 $time_iso8601
section 12049 12126 $time_local section 12142 12219 $time_local
module ngx_stream_geo_module module ngx_stream_geo_module
section 17 212 name section 17 212 name
...@@ -1757,15 +1758,15 @@ module ngx_stream_geoip_module ...@@ -1757,15 +1758,15 @@ module ngx_stream_geoip_module
section 3557 3667 $geoip_org section 3557 3667 $geoip_org
module ngx_stream_js_module module ngx_stream_js_module
section 17 780 name section 17 335 name
section 780 3088 example configuration section 335 2705 example configuration
section 3088 3973 directives section 2705 3590 directives
section 3107 3310 js_access section 2724 2927 js_access
section 3310 3449 js_filter section 2927 3066 js_filter
section 3449 3612 js_include section 3066 3229 js_include
section 3612 3818 js_preread section 3229 3435 js_preread
section 3818 3973 js_set section 3435 3590 js_set
section 3973 4096 session object properties section 3590 3713 session object properties
module ngx_stream_keyval_module module ngx_stream_keyval_module
section 17 336 name section 17 336 name
...@@ -1905,12 +1906,13 @@ module ngx_stream_ssl_module ...@@ -1905,12 +1906,13 @@ module ngx_stream_ssl_module
module ngx_stream_ssl_preread_module module ngx_stream_ssl_preread_module
section 17 617 name section 17 617 name
section 617 1478 example configuration section 617 1861 example configuration
section 1478 1751 directives section 1861 2134 directives
section 1497 1751 ssl_preread section 1880 2134 ssl_preread
section 1751 2025 embedded variables section 2134 2512 embedded variables
section 1790 1865 $ssl_preread_server_name section 2173 2277 $ssl_preread_protocol
section 1865 2025 $ssl_preread_alpn_protocols section 2277 2352 $ssl_preread_server_name
section 2352 2512 $ssl_preread_alpn_protocols
module ngx_stream_upstream_hc_module module ngx_stream_upstream_hc_module
section 17 752 name section 17 752 name
...@@ -1923,7 +1925,7 @@ module ngx_stream_upstream_hc_module ...@@ -1923,7 +1925,7 @@ module ngx_stream_upstream_hc_module
module ngx_stream_upstream_module module ngx_stream_upstream_module
section 17 264 name section 17 264 name
section 264 1528 example configuration section 264 1528 example configuration
section 1528 11610 directives section 1528 12231 directives
section 1547 2641 upstream section 1547 2641 upstream
section 2641 7401 server section 2641 7401 server
section 7401 8184 zone section 7401 8184 zone
...@@ -1931,13 +1933,14 @@ module ngx_stream_upstream_module ...@@ -1931,13 +1933,14 @@ module ngx_stream_upstream_module
section 9087 10215 hash section 9087 10215 hash
section 10215 10571 least_conn section 10215 10571 least_conn
section 10571 11610 least_time section 10571 11610 least_time
section 11610 13224 embedded variables section 11610 12231 random
section 11733 12117 $upstream_addr section 12231 13845 embedded variables
section 12117 12310 $upstream_bytes_sent section 12354 12738 $upstream_addr
section 12310 12513 $upstream_bytes_received section 12738 12931 $upstream_bytes_sent
section 12513 12758 $upstream_connect_time section 12931 13134 $upstream_bytes_received
section 12758 13006 $upstream_first_byte_time section 13134 13379 $upstream_connect_time
section 13006 13224 $upstream_session_time section 13379 13627 $upstream_first_byte_time
section 13627 13845 $upstream_session_time
module ngx_stream_zone_sync_module module ngx_stream_zone_sync_module
section 17 569 name section 17 569 name
...@@ -1977,91 +1980,125 @@ module njs_about ...@@ -1977,91 +1980,125 @@ module njs_about
module njs_api module njs_api
section 18 159 name section 18 159 name
section 159 3563 core section 159 15474 core
section 173 1892 json section 173 8163 string
section 292 584 c<json.parse(string[, section 1435 1634 c<string.fromcodepoint(codepoint1[, ...[,
section 584 1892 c<json.stringify(value[, section 1634 1829 c<string.prototype.concat(string1[, ...,
section 1892 3563 crypto section 1829 2210 c<string.prototype.endswith(searchstring[,
section 2050 2263 crypto.createhash(algorithm) section 2210 2411 c<string.prototype.frombytes(start[,
section 2263 2492 c<crypto.createhmac(algorithm, section 2411 2602 c<string.prototype.fromutf8(start[,
section 2492 3024 hash section 2602 2944 c<string.prototype.includes(searchstring[,
section 2517 2609 hash.update(data) section 2944 3423 c<string.prototype.indexof(searchstring[,
section 2609 3024 hash.digest([encoding]) section 3423 3766 c<string.prototype.lastindexof(searchstring[,
section 3024 3563 hmac section 3766 3879 string.prototype.length
section 3049 3141 hmac.update(data) section 3879 4017 string.prototype.match([regexp])
section 3141 3563 hmac.digest([encoding]) section 4017 4188 string.prototype.repeat(number)
section 3563 6725 http section 4188 4476 c<string.prototype.replace([regexpe<verbar>string[,
section 3678 5211 request section 4476 4618 string.prototype.search([regexp])
section 3706 3766 req.uri section 4618 4872 c<string.prototype.slice(start[,
section 3766 3819 req.method section 4872 5273 c<string.prototype.startswith(searchstring[,
section 3819 3875 req.httpversion section 5273 5514 c<string.prototype.substr(start[,
section 3875 3935 req.remoteaddress section 5514 5741 c<string.prototype.substring(start[,
section 3935 4127 req.headers{} section 5741 5928 c<string.prototype.tobytes(start[,
section 4127 4190 req.args{} section 5928 6110 string.prototype.tolowercase()
section 4190 4260 request.variables{} section 6110 6458 string.prototype.tostring([encoding])
section 4260 4328 req.response section 6458 6640 string.prototype.touppercase()
section 4328 4434 req.log(string) section 6640 6866 c<string.prototype.toutf8(start[,
section 4434 4552 req.warn(string) section 6866 6995 string.prototype.trim()
section 4552 4669 req.error(string) section 6995 7282 c<string.prototype.split(([stringe<verbar>regexp[,
section 4669 5021 c<req.subrequest(uri[, section 7282 7548 encodeuri(uri)
section 5021 5059 args section 7548 7824 encodeuricomponent(encodeduristring)
section 5059 5093 body section 7824 7974 decodeuri(encodeduri)
section 5093 5211 method section 7974 8163 decodeuricomponent(decodeduristring)
section 5211 6052 response section 8163 9882 json
section 5240 5293 res.status section 8282 8574 c<json.parse(string[,
section 5293 5347 res.headers{} section 8574 9882 c<json.stringify(value[,
section 5347 5437 res.contenttype section 9882 11553 crypto
section 5437 5531 res.contentlength section 10040 10253 crypto.createhash(algorithm)
section 5531 5600 res.sendheader() section 10253 10482 c<crypto.createhmac(algorithm,
section 5600 5687 res.send(string) section 10482 11014 hash
section 5687 5758 res.finish() section 10507 10599 hash.update(data)
section 5758 6052 res.return(status[, string]) section 10599 11014 hash.digest([encoding])
section 6052 6725 reply section 11014 11553 hmac
section 6078 6138 reply.uri section 11039 11131 hmac.update(data)
section 6138 6191 reply.method section 11131 11553 hmac.digest([encoding])
section 6191 6243 reply.status section 11553 12078 timers
section 6243 6335 reply.contenttype section 11581 11678 cleartimeout(timeout)
section 6335 6431 reply.contentlength section 11678 12078 c<settimeout(function,
section 6431 6584 reply.headers{} section 12078 15474 file system
section 6584 6646 reply.body section 12216 12502 c<appendfilesync(filename,
section 6646 6725 reply.parent section 12502 12559 mode
section 6725 7891 stream section 12559 12629 flag
section 6848 7891 session section 12629 13022 c<readfilesync(filename[,
section 6876 6934 s.remoteaddress section 13022 13114 encoding
section 6934 7032 s.eof section 13114 13367 flag
section 7032 7162 s.fromupstream section 13367 13681 c<writefilesync(filename,
section 7162 7216 s.buffer section 13681 13738 mode
section 7216 7280 s.variables{} section 13738 13951 flag
section 7280 7323 s.ok section 13951 15474 file system flags
section 7323 7378 s.declined section 15474 18274 http request
section 7378 7427 s.again section 15660 15721 r.args{}
section 7427 7476 s.error section 15721 15828 r.error(string)
section 7476 7525 s.abort section 15828 15897 r.finish()
section 7525 7637 s.log(string) section 15897 16070 r.headersin{}
section 7637 7758 s.warn(string) section 16070 16245 r.headersout{}
section 7758 7891 s.error(string) section 16245 16299 r.httpversion
section 7891 11671 examples section 16299 16403 r.log(string)
section 7909 8146 url decoding section 16403 16585 r.internalredirect(uri)
section 8146 8475 url encoding section 16585 16633 r.method
section 8475 9125 returning fastest response from proxy section 16633 16695 r.parent
section 9125 9957 creating hs jwt section 16695 16753 r.remoteaddress
section 9957 11067 accessing api from a subrequest section 16753 16817 r.requestbody
section 11067 11671 creating secure_link hash section 16817 16978 r.responsebody
section 16978 17249 r.return(status[, string])
section 17249 17334 r.send(string)
section 17334 17402 r.sendheader()
section 17402 17444 r.status
section 17444 17508 r.variables{}
section 17508 17616 r.warn(string)
section 17616 17661 r.uri
section 17661 18002 c<r.subrequest(uri[,
section 18002 18040 args
section 18040 18074 body
section 18074 18274 method
section 18274 19467 stream session
section 18468 18526 s.remoteaddress
section 18526 18624 s.eof
section 18624 18754 s.fromupstream
section 18754 18808 s.buffer
section 18808 18872 s.variables{}
section 18872 18915 s.ok
section 18915 18970 s.declined
section 18970 19019 s.again
section 19019 19068 s.error
section 19068 19117 s.abort
section 19117 19229 s.log(string)
section 19229 19342 s.warn(string)
section 19342 19467 s.error(string)
section 19467 23480 examples
section 19485 19713 url decoding
section 19713 20035 url encoding
section 20035 20336 internal redirect
section 20336 20971 returning fastest response from proxy
section 20971 21796 creating hs jwt
section 21796 22885 accessing api from a subrequest
section 22885 23480 creating secure_link hash
module njs_changes module njs_changes
section 18 60 name section 18 60 name
section 60 1747 changes with 0.2.1 section 60 1270 changes with 0.2.2
section 1747 2499 changes with 0.2.0 section 1270 2957 changes with 0.2.1
section 2499 3158 changes with 0.1.15 section 2957 3709 changes with 0.2.0
section 3158 3503 changes with 0.1.14 section 3709 4368 changes with 0.1.15
section 3503 3979 changes with 0.1.13 section 4368 4713 changes with 0.1.14
section 3979 4156 changes with 0.1.12 section 4713 5189 changes with 0.1.13
section 4156 4992 changes with 0.1.11 section 5189 5366 changes with 0.1.12
section 4992 5359 changes with 0.1.10 section 5366 6202 changes with 0.1.11
section 5359 5532 changes with 0.1.9 section 6202 6569 changes with 0.1.10
section 5532 6042 changes with 0.1.8 section 6569 6742 changes with 0.1.9
section 6042 6369 changes with 0.1.7 section 6742 7252 changes with 0.1.8
section 6369 6691 changes with 0.1.6 section 7252 7579 changes with 0.1.7
section 7579 7901 changes with 0.1.6
module request_processing module request_processing
section 18 85 name section 18 85 name
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment