aboutsummaryrefslogtreecommitdiffstats
path: root/openresty-ext/src/assembly/resources/openresty/nginx/msb-enabled
diff options
context:
space:
mode:
Diffstat (limited to 'openresty-ext/src/assembly/resources/openresty/nginx/msb-enabled')
-rw-r--r--openresty-ext/src/assembly/resources/openresty/nginx/msb-enabled/location-default/msblocations.conf116
-rw-r--r--openresty-ext/src/assembly/resources/openresty/nginx/msb-enabled/location-ext/monitor.conf56
-rw-r--r--openresty-ext/src/assembly/resources/openresty/nginx/msb-enabled/msb.conf12
-rw-r--r--openresty-ext/src/assembly/resources/openresty/nginx/msb-enabled/msbhttps.conf5
4 files changed, 135 insertions, 54 deletions
diff --git a/openresty-ext/src/assembly/resources/openresty/nginx/msb-enabled/location-default/msblocations.conf b/openresty-ext/src/assembly/resources/openresty/nginx/msb-enabled/location-default/msblocations.conf
index 745c290..2150e70 100644
--- a/openresty-ext/src/assembly/resources/openresty/nginx/msb-enabled/location-default/msblocations.conf
+++ b/openresty-ext/src/assembly/resources/openresty/nginx/msb-enabled/location-default/msblocations.conf
@@ -1,5 +1,5 @@
#
-# Copyright (C) 2016 ZTE, Inc. and others. All rights reserved. (ZTE)
+# Copyright (C) 2017-2018 ZTE, Inc. and others. All rights reserved. (ZTE)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -16,10 +16,7 @@
default_type text/html;
- # the flag identify whether to check doing internal redirect or not
- set $websocket_internal_redirect "on";
set $http_protocol "http";
-
location = /iui/microservices {
try_files $uri @addslash;
@@ -37,23 +34,29 @@
set $svc_url "";
set $backend "defaultbackend";
- #rewrite by the lua file
- rewrite_by_lua_file luaext/rewrite/customrewrite.lua;
access_by_lua_block {
+ ngx.log(ngx.INFO, ngx.var.request_id..":receive the request")
+ msb.filter_websocket_req()
+ msb.route()
msb.access()
+ if ngx.ctx.use_ownupstream then
+ stats.forward_backend()
+ end
}
header_filter_by_lua_block {
+ stats.receive_response()
msb.header_filter()
+ stats.return_response()
}
#log by the lua file
log_by_lua_file luaext/log/logger.lua;
proxy_pass $http_protocol://$backend;
- proxy_redirect $http_protocol://$host:$server_port$svc_url $http_protocol://$host:$server_port$svc_name;
+ #proxy_redirect $http_protocol://$host:$server_port$svc_url $http_protocol://$host:$server_port$svc_name;
}
- location @customwebsocket {
- set $websocket_internal_redirect "off";
+ location @websocket {
+ set $stats_new_req "false";
#set header for websocket
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
@@ -63,38 +66,18 @@
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host:$server_port;
- #rewrite by the lua file
- rewrite_by_lua_file luaext/rewrite/customrewrite.lua;
- access_by_lua_block {
- msb.access()
- }
- header_filter_by_lua_block {
- msb.header_filter()
- }
- #log by the lua file
- log_by_lua_file luaext/log/logger.lua;
-
- proxy_pass $http_protocol://$backend;
- }
-
- location @commonwebsocket {
- set $websocket_internal_redirect "off";
- #set header for websocket
- proxy_http_version 1.1;
- proxy_set_header Upgrade $http_upgrade;
- proxy_set_header Connection "Upgrade";
-
- proxy_set_header X-Real-IP $remote_addr;
- proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
- proxy_set_header Host $host:$server_port;
-
- #rewrite by the lua file
- rewrite_by_lua_file luaext/rewrite/commonrewrite.lua;
access_by_lua_block {
+ ngx.log(ngx.INFO, ngx.var.request_id..":receive the request")
+ msb.route()
msb.access()
+ if ngx.ctx.use_ownupstream then
+ stats.forward_backend()
+ end
}
header_filter_by_lua_block {
+ stats.receive_response()
msb.header_filter()
+ stats.return_response()
}
#log by the lua file
log_by_lua_file luaext/log/logger.lua;
@@ -108,19 +91,26 @@
set $svc_url "";
set $backend "defaultbackend";
- #rewrite by the lua file
- rewrite_by_lua_file luaext/rewrite/customrewrite.lua;
access_by_lua_block {
+ ngx.log(ngx.INFO, ngx.var.request_id..":receive the request")
+ stats.accept_new_request()
+ msb.filter_websocket_req()
+ msb.route()
msb.access()
+ if ngx.ctx.use_ownupstream then
+ stats.forward_backend()
+ end
}
header_filter_by_lua_block {
+ stats.receive_response()
msb.header_filter()
+ stats.return_response()
}
#log by the lua file
log_by_lua_file luaext/log/logger.lua;
proxy_pass $http_protocol://$backend;
- proxy_redirect $http_protocol://$host:$server_port$svc_url $http_protocol://$host:$server_port$svc_name;
+ #proxy_redirect $http_protocol://$host:$server_port$svc_url $http_protocol://$host:$server_port$svc_name;
}
location ~ ^/(api|admin|apijson)(/[Vv]\d+(?:\.\d+)*)?/([^/]+)(/[Vv]\d+(?:\.\d+)*)?(.*) {
@@ -131,13 +121,20 @@
set $req_res $5;
set $backend "defaultbackend";
- #rewrite by the lua file
- rewrite_by_lua_file luaext/rewrite/commonrewrite.lua;
access_by_lua_block {
+ ngx.log(ngx.INFO, ngx.var.request_id..":receive the request")
+ stats.accept_new_request()
+ msb.filter_websocket_req()
+ msb.route()
msb.access()
+ if ngx.ctx.use_ownupstream then
+ stats.forward_backend()
+ end
}
header_filter_by_lua_block {
+ stats.receive_response()
msb.header_filter()
+ stats.return_response()
}
#log by the lua file
log_by_lua_file luaext/log/logger.lua;
@@ -151,13 +148,20 @@
set $req_res $2.$3;
set $backend "defaultbackend";
- #rewrite by the lua file
- rewrite_by_lua_file luaext/rewrite/commonrewrite.lua;
access_by_lua_block {
+ ngx.log(ngx.INFO, ngx.var.request_id..":receive the request")
+ stats.accept_new_request()
+ msb.filter_websocket_req()
+ msb.route()
msb.access()
+ if ngx.ctx.use_ownupstream then
+ stats.forward_backend()
+ end
}
header_filter_by_lua_block {
+ stats.receive_response()
msb.header_filter()
+ stats.return_response()
}
#log by the lua file
log_by_lua_file luaext/log/logger.lua;
@@ -173,13 +177,20 @@
set $req_res $2;
set $backend "defaultbackend";
- #rewrite by the lua file
- rewrite_by_lua_file luaext/rewrite/commonrewrite.lua;
access_by_lua_block {
+ ngx.log(ngx.INFO, ngx.var.request_id..":receive the request")
+ stats.accept_new_request()
+ msb.filter_websocket_req()
+ msb.route()
msb.access()
+ if ngx.ctx.use_ownupstream then
+ stats.forward_backend()
+ end
}
header_filter_by_lua_block {
+ stats.receive_response()
msb.header_filter()
+ stats.return_response()
}
#log by the lua file
log_by_lua_file luaext/log/logger.lua;
@@ -196,13 +207,20 @@
set $svc_url "";
set $backend "defaultbackend";
- #rewrite by the lua file
- rewrite_by_lua_file luaext/rewrite/customrewrite.lua;
access_by_lua_block {
+ ngx.log(ngx.INFO, ngx.var.request_id..":receive the request")
+ stats.accept_new_request()
+ msb.filter_websocket_req()
+ msb.route()
msb.access()
+ if ngx.ctx.use_ownupstream then
+ stats.forward_backend()
+ end
}
header_filter_by_lua_block {
+ stats.receive_response()
msb.header_filter()
+ stats.return_response()
}
#log by the lua file
log_by_lua_file luaext/log/logger.lua;
@@ -210,9 +228,9 @@
proxy_cache nginx_cache;
add_header X-Cache-Status $upstream_cache_status;
proxy_pass $http_protocol://$backend;
- proxy_redirect http://$host:$server_port$svc_url http://$host:$server_port$svc_name;
+ #proxy_redirect http://$host:$server_port$svc_url http://$host:$server_port$svc_name;
}
location = /favicon.ico {
log_not_found off;
- } \ No newline at end of file
+ }
diff --git a/openresty-ext/src/assembly/resources/openresty/nginx/msb-enabled/location-ext/monitor.conf b/openresty-ext/src/assembly/resources/openresty/nginx/msb-enabled/location-ext/monitor.conf
new file mode 100644
index 0000000..c1ae2d2
--- /dev/null
+++ b/openresty-ext/src/assembly/resources/openresty/nginx/msb-enabled/location-ext/monitor.conf
@@ -0,0 +1,56 @@
+#
+# Copyright (C) 2018 ZTE, Inc. and others. All rights reserved. (ZTE)
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+location = /admin/microservices/v1/status/connection {
+ access_log off;
+ content_by_lua_block{
+ if ngx.req.get_method() == "GET" then
+ ngx.print(stats.format_conn_status())
+ else
+ ngx.status = ngx.HTTP_NOT_FOUND
+ ngx.say("request method not supported!")
+ return ngx.exit(ngx.status)
+ end
+ }
+}
+location = /admin/microservices/v1/status/request {
+ access_log off;
+ content_by_lua_block{
+ if ngx.req.get_method() == "GET" then
+ ngx.print(stats.format_req_status())
+ else
+ ngx.status = ngx.HTTP_NOT_FOUND
+ ngx.say("request method not supported!")
+ return ngx.exit(ngx.status)
+ end
+ }
+}
+location = /admin/microservices/v1/statistics/request {
+ access_log off;
+ content_by_lua_block{
+ if ngx.req.get_method() == "GET" then
+ --if input latestNum is empty or illegal, then set to 1
+ local latest_num = tonumber(ngx.var.arg_latestNum) or 1
+ if latest_num<=0 then
+ latest_num =1
+ end
+ ngx.print(stats.get_reqnum_stats(latest_num))
+ else
+ ngx.status = ngx.HTTP_NOT_FOUND
+ ngx.say("request method not supported!")
+ return ngx.exit(ngx.status)
+ end
+ }
+}
diff --git a/openresty-ext/src/assembly/resources/openresty/nginx/msb-enabled/msb.conf b/openresty-ext/src/assembly/resources/openresty/nginx/msb-enabled/msb.conf
index 8e854bb..3e7038b 100644
--- a/openresty-ext/src/assembly/resources/openresty/nginx/msb-enabled/msb.conf
+++ b/openresty-ext/src/assembly/resources/openresty/nginx/msb-enabled/msb.conf
@@ -1,5 +1,5 @@
#
-# Copyright (C) 2016 ZTE, Inc. and others. All rights reserved. (ZTE)
+# Copyright (C) 2017-2018 ZTE, Inc. and others. All rights reserved. (ZTE)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -41,13 +41,15 @@ proxy_next_upstream error timeout;
proxy_next_upstream_tries 5;
# Lua settings
-lua_package_path "$prefix/../lualib/?.lua;$prefix/luaext/?.lua;;";
+lua_package_path "$prefix/../lualib/?.lua;$prefix/luaext/?.lua;$prefix/luaext/vendor/?.lua;;";
lua_package_cpath "$prefix/../lualib/?.so;;";
#lua_shared_dict rr_cache 1M;
#lua_shared_dict rr_locks 100k;
lua_shared_dict svc_cache 5M;
lua_shared_dict locks 200k;
+lua_shared_dict stats 1M;
+lua_shared_dict dns_cache 1M;
lua_code_cache on;
@@ -60,8 +62,12 @@ upstream defaultbackend {
init_by_lua_block {
msb = require('msb')
msb.load_plugins()
+ stats = require ('monitor.stats')
+}
+init_worker_by_lua_block {
+ stats.init_timer()
}
server {
listen 80;
include ../msb-enabled/location-default/msblocations.conf;
-} \ No newline at end of file
+}
diff --git a/openresty-ext/src/assembly/resources/openresty/nginx/msb-enabled/msbhttps.conf b/openresty-ext/src/assembly/resources/openresty/nginx/msb-enabled/msbhttps.conf
index 430c05d..9015d65 100644
--- a/openresty-ext/src/assembly/resources/openresty/nginx/msb-enabled/msbhttps.conf
+++ b/openresty-ext/src/assembly/resources/openresty/nginx/msb-enabled/msbhttps.conf
@@ -1,5 +1,5 @@
#
-# Copyright (C) 2016 ZTE, Inc. and others. All rights reserved. (ZTE)
+# Copyright (C) 2017-2018 ZTE, Inc. and others. All rights reserved. (ZTE)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -17,6 +17,7 @@ server {
listen 443 ssl;
ssl_certificate ../ssl/cert/cert.crt;
ssl_certificate_key ../ssl/cert/cert.key;
+ ssl_protocols TLSv1.1 TLSv1.2;
ssl_dhparam ../ssl/dh-pubkey/dhparams.pem;
include ../msb-enabled/location-default/msblocations.conf;
-} \ No newline at end of file
+}