aboutsummaryrefslogtreecommitdiffstats
path: root/openresty-ext/src/assembly/resources
diff options
context:
space:
mode:
authorHuabingZhao <zhao.huabing@zte.com.cn>2018-03-05 14:59:44 +0800
committerHuabingZhao <zhao.huabing@zte.com.cn>2018-03-05 15:00:54 +0800
commitdecc4a36e208e38c9944481908652435aaa51ca7 (patch)
treecad63af7fee73706c3eedf695ee4fe3a8be648d3 /openresty-ext/src/assembly/resources
parent3ea845d26d864935511ca93c64669c5d1890c87b (diff)
Support websocket request forwarding
Issue-ID: MSB-156 Change-Id: Id63da46c6321d5d007e8078847ad093aaebe0a45 Signed-off-by: HuabingZhao <zhao.huabing@zte.com.cn>
Diffstat (limited to 'openresty-ext/src/assembly/resources')
-rw-r--r--openresty-ext/src/assembly/resources/openresty/nginx/luaext/conf/msbinit.lua2
-rw-r--r--openresty-ext/src/assembly/resources/openresty/nginx/luaext/conf/svcconf.lua2
-rw-r--r--openresty-ext/src/assembly/resources/openresty/nginx/luaext/core/error_handler.lua2
-rw-r--r--openresty-ext/src/assembly/resources/openresty/nginx/luaext/core/peerwatcher.lua2
-rw-r--r--openresty-ext/src/assembly/resources/openresty/nginx/luaext/dao/dao.lua2
-rw-r--r--openresty-ext/src/assembly/resources/openresty/nginx/luaext/dao/db_access.lua2
-rw-r--r--openresty-ext/src/assembly/resources/openresty/nginx/luaext/dao/redis_db.lua2
-rw-r--r--openresty-ext/src/assembly/resources/openresty/nginx/luaext/lib/tools/db_cache.lua2
-rw-r--r--openresty-ext/src/assembly/resources/openresty/nginx/luaext/lib/tools/rr_cache.lua2
-rw-r--r--openresty-ext/src/assembly/resources/openresty/nginx/luaext/lib/utils/error_handler.lua48
-rw-r--r--openresty-ext/src/assembly/resources/openresty/nginx/luaext/lib/utils/log_util.lua2
-rw-r--r--openresty-ext/src/assembly/resources/openresty/nginx/luaext/lib/utils/table_util.lua2
-rw-r--r--openresty-ext/src/assembly/resources/openresty/nginx/luaext/loadbalance/peerwatcher.lua107
-rw-r--r--openresty-ext/src/assembly/resources/openresty/nginx/luaext/loadbalance/policy/roundrobin.lua2
-rw-r--r--openresty-ext/src/assembly/resources/openresty/nginx/luaext/plugins/base_plugin.lua2
-rw-r--r--openresty-ext/src/assembly/resources/openresty/nginx/luaext/plugins/config_custom.lua2
-rw-r--r--openresty-ext/src/assembly/resources/openresty/nginx/luaext/plugins/redirect-transformer/handler.lua2
-rw-r--r--openresty-ext/src/assembly/resources/openresty/nginx/luaext/plugins/sampleplugin/handler.lua2
-rw-r--r--openresty-ext/src/assembly/resources/openresty/nginx/luaext/rewrite/commonrewrite.lua138
-rw-r--r--openresty-ext/src/assembly/resources/openresty/nginx/luaext/rewrite/customrewrite.lua203
-rw-r--r--openresty-ext/src/assembly/resources/openresty/nginx/msb-enabled/location-ext/defaultpage.conf9
-rw-r--r--openresty-ext/src/assembly/resources/openresty/run.sh2
-rw-r--r--openresty-ext/src/assembly/resources/openresty/run4docker.sh2
-rw-r--r--openresty-ext/src/assembly/resources/openresty/stop.sh2
24 files changed, 19 insertions, 524 deletions
diff --git a/openresty-ext/src/assembly/resources/openresty/nginx/luaext/conf/msbinit.lua b/openresty-ext/src/assembly/resources/openresty/nginx/luaext/conf/msbinit.lua
index ec7d7b0..195cc72 100644
--- a/openresty-ext/src/assembly/resources/openresty/nginx/luaext/conf/msbinit.lua
+++ b/openresty-ext/src/assembly/resources/openresty/nginx/luaext/conf/msbinit.lua
@@ -1,6 +1,6 @@
--[[
- Copyright (C) 2018 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.
diff --git a/openresty-ext/src/assembly/resources/openresty/nginx/luaext/conf/svcconf.lua b/openresty-ext/src/assembly/resources/openresty/nginx/luaext/conf/svcconf.lua
index df6356e..8c464dc 100644
--- a/openresty-ext/src/assembly/resources/openresty/nginx/luaext/conf/svcconf.lua
+++ b/openresty-ext/src/assembly/resources/openresty/nginx/luaext/conf/svcconf.lua
@@ -1,6 +1,6 @@
--[[
- 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.
diff --git a/openresty-ext/src/assembly/resources/openresty/nginx/luaext/core/error_handler.lua b/openresty-ext/src/assembly/resources/openresty/nginx/luaext/core/error_handler.lua
index f21f10a..a3f6a23 100644
--- a/openresty-ext/src/assembly/resources/openresty/nginx/luaext/core/error_handler.lua
+++ b/openresty-ext/src/assembly/resources/openresty/nginx/luaext/core/error_handler.lua
@@ -1,6 +1,6 @@
--[[
- 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.
diff --git a/openresty-ext/src/assembly/resources/openresty/nginx/luaext/core/peerwatcher.lua b/openresty-ext/src/assembly/resources/openresty/nginx/luaext/core/peerwatcher.lua
index 6b7e522..916d0e1 100644
--- a/openresty-ext/src/assembly/resources/openresty/nginx/luaext/core/peerwatcher.lua
+++ b/openresty-ext/src/assembly/resources/openresty/nginx/luaext/core/peerwatcher.lua
@@ -1,6 +1,6 @@
--[[
- 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.
diff --git a/openresty-ext/src/assembly/resources/openresty/nginx/luaext/dao/dao.lua b/openresty-ext/src/assembly/resources/openresty/nginx/luaext/dao/dao.lua
index 8a69499..2adc3fc 100644
--- a/openresty-ext/src/assembly/resources/openresty/nginx/luaext/dao/dao.lua
+++ b/openresty-ext/src/assembly/resources/openresty/nginx/luaext/dao/dao.lua
@@ -1,6 +1,6 @@
--[[
- Copyright (C) 2018 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.
diff --git a/openresty-ext/src/assembly/resources/openresty/nginx/luaext/dao/db_access.lua b/openresty-ext/src/assembly/resources/openresty/nginx/luaext/dao/db_access.lua
index 35572cc..11439d9 100644
--- a/openresty-ext/src/assembly/resources/openresty/nginx/luaext/dao/db_access.lua
+++ b/openresty-ext/src/assembly/resources/openresty/nginx/luaext/dao/db_access.lua
@@ -1,6 +1,6 @@
--[[
- 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.
diff --git a/openresty-ext/src/assembly/resources/openresty/nginx/luaext/dao/redis_db.lua b/openresty-ext/src/assembly/resources/openresty/nginx/luaext/dao/redis_db.lua
index d35cb8e..cdb72ae 100644
--- a/openresty-ext/src/assembly/resources/openresty/nginx/luaext/dao/redis_db.lua
+++ b/openresty-ext/src/assembly/resources/openresty/nginx/luaext/dao/redis_db.lua
@@ -1,6 +1,6 @@
--[[
- 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.
diff --git a/openresty-ext/src/assembly/resources/openresty/nginx/luaext/lib/tools/db_cache.lua b/openresty-ext/src/assembly/resources/openresty/nginx/luaext/lib/tools/db_cache.lua
index 7f40590..c4d2bb5 100644
--- a/openresty-ext/src/assembly/resources/openresty/nginx/luaext/lib/tools/db_cache.lua
+++ b/openresty-ext/src/assembly/resources/openresty/nginx/luaext/lib/tools/db_cache.lua
@@ -1,6 +1,6 @@
--[[
- 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.
diff --git a/openresty-ext/src/assembly/resources/openresty/nginx/luaext/lib/tools/rr_cache.lua b/openresty-ext/src/assembly/resources/openresty/nginx/luaext/lib/tools/rr_cache.lua
index bfcc157..45a2b3d 100644
--- a/openresty-ext/src/assembly/resources/openresty/nginx/luaext/lib/tools/rr_cache.lua
+++ b/openresty-ext/src/assembly/resources/openresty/nginx/luaext/lib/tools/rr_cache.lua
@@ -1,6 +1,6 @@
--[[
- 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.
diff --git a/openresty-ext/src/assembly/resources/openresty/nginx/luaext/lib/utils/error_handler.lua b/openresty-ext/src/assembly/resources/openresty/nginx/luaext/lib/utils/error_handler.lua
deleted file mode 100644
index 784eb86..0000000
--- a/openresty-ext/src/assembly/resources/openresty/nginx/luaext/lib/utils/error_handler.lua
+++ /dev/null
@@ -1,48 +0,0 @@
---[[
-
- Copyright (C) 2016 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.
-
---]]
-
-local _M = {}
-_M._VERSION = '1.0.0'
-local msbConf = require('conf.msbinit')
-local enablefullsearch = msbConf.systemConf.enablefullsearch
-local ngx_var = ngx.var
-local error_page_head = '<html><head><title>502 Bad Gateway</title></head><body bgcolor="white"><center><h1>502 Bad Gateway</h1></center><center>error message:'
-local error_page_foot = '</center><hr><center>nginx</center></body></html>'
-local upstream_not_found_err = "service info is incorrect:using own upstream flag is on but upstream name is empty"
-
-function _M.svc_not_found(err_info,detail_info)
- ngx.log(ngx.WARN, ngx.var.request_id.." "..(err_info or "").." detail_info:"..(detail_info or ""))
- if enablefullsearch and ngx_var.svc_type ~= "custom" then
- -- test against the custom services after the commonrewrite phase
- --ngx.status = ngx.HTTP_GONE
- return ngx.exec("@commonnotfound");
- else
- ngx.status = ngx.HTTP_BAD_GATEWAY
- ngx.print(error_page_head..err_info..error_page_foot)
- end
- return ngx.exit(ngx.status)
-end
-
-function _M.upstream_not_found()
- ngx.log(ngx.WARN, ngx.var.request_id.." "..upstream_not_found_err)
- ngx.status = ngx.HTTP_BAD_GATEWAY
- ngx.print(error_page_head..upstream_not_found_err..error_page_foot)
- return ngx.exit(ngx.status)
-end
-
-return _M \ No newline at end of file
diff --git a/openresty-ext/src/assembly/resources/openresty/nginx/luaext/lib/utils/log_util.lua b/openresty-ext/src/assembly/resources/openresty/nginx/luaext/lib/utils/log_util.lua
index 67b0e26..744b14c 100644
--- a/openresty-ext/src/assembly/resources/openresty/nginx/luaext/lib/utils/log_util.lua
+++ b/openresty-ext/src/assembly/resources/openresty/nginx/luaext/lib/utils/log_util.lua
@@ -1,6 +1,6 @@
--[[
- 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.
diff --git a/openresty-ext/src/assembly/resources/openresty/nginx/luaext/lib/utils/table_util.lua b/openresty-ext/src/assembly/resources/openresty/nginx/luaext/lib/utils/table_util.lua
index c1ddbfe..0e3d853 100644
--- a/openresty-ext/src/assembly/resources/openresty/nginx/luaext/lib/utils/table_util.lua
+++ b/openresty-ext/src/assembly/resources/openresty/nginx/luaext/lib/utils/table_util.lua
@@ -1,6 +1,6 @@
--[[
- 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.
diff --git a/openresty-ext/src/assembly/resources/openresty/nginx/luaext/loadbalance/peerwatcher.lua b/openresty-ext/src/assembly/resources/openresty/nginx/luaext/loadbalance/peerwatcher.lua
deleted file mode 100644
index 6b7e522..0000000
--- a/openresty-ext/src/assembly/resources/openresty/nginx/luaext/loadbalance/peerwatcher.lua
+++ /dev/null
@@ -1,107 +0,0 @@
---[[
-
- Copyright (C) 2016 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.
-
---]]
-
-local _M = {
- _VERSION = '1.0.0',
- STATUS_OK = 0, STATUS_UNSTABLE = 1, STATUS_ERR = 2
-}
-local msbConf = require('conf.msbinit')
-local str_format = string.format
-local now = ngx.now
-local fail_timeout = msbConf.server.fail_timeout or 10
-local max_fails = msbConf.server.max_fails or 1
-
-local cluster_status = {}
-_M.cluster_status = cluster_status
-
-function _M.is_server_ok(skey, srv)
- return _M.get_srv_status(skey, srv)==_M.STATUS_OK
-end
-
-function _M.get_srv_status(skey, srv)
- local server_status = cluster_status[skey]
- if not server_status then
- return _M.STATUS_OK
- end
-
- local srv_key = str_format("%s:%d", srv.ip, srv.port)
- local srv_status = server_status[srv_key]
-
- if srv_status and srv_status.lastmodify + fail_timeout > now() then
- return srv_status.status
- end
-
- return _M.STATUS_OK
-end
-
-function _M.set_srv_status(skey, srv, failed)
- local server_status = cluster_status[skey]
- if not server_status then
- server_status = {}
- cluster_status[skey] = server_status
- end
-
- local time_now = now()
- local srv_key = str_format("%s:%d", srv.ip, srv.port)
- local srv_status = server_status[srv_key]
- if not srv_status then -- first set
- srv_status = {
- status = _M.STATUS_OK,
- failed_count = 0,
- lastmodify = time_now
- }
- server_status[srv_key] = srv_status
- elseif srv_status.lastmodify + fail_timeout < time_now then -- srv_status expired
- srv_status.status = _M.STATUS_OK
- srv_status.failed_count = 0
- srv_status.lastmodify = time_now
- end
-
- if failed then
- srv_status.failed_count = srv_status.failed_count + 1
- if srv_status.failed_count >= max_fails then
- srv_status.status = _M.STATUS_ERR
- end
- end
-end
-
-function _M.check_and_reset_srv_status_ifneed(skey,servers)
- local server_status = cluster_status[skey]
- --if disabled servers of the service is empty,do nothing
- if not server_status then
- ngx.log(ngx.DEBUG, "service:",skey," server_status is nil")
- return
- end
- local need_reset = true
- for _, srv in ipairs(servers) do
- local srv_key = str_format("%s:%d", srv.ip, srv.port)
- local srv_status = server_status[srv_key]
- if not (srv_status and srv_status.status == _M.STATUS_ERR and srv_status.lastmodify + fail_timeout > now()) then
- --once find the server is not disabled now, no need to reset the status table. break the loop
- ngx.log(ngx.DEBUG, "service:",skey," donot need reset,break the loop")
- need_reset = false
- break
- end
- end
- if need_reset then
- ngx.log(ngx.DEBUG, "service:",skey," need reset")
- cluster_status[skey] = {}
- end
-end
-
-return _M \ No newline at end of file
diff --git a/openresty-ext/src/assembly/resources/openresty/nginx/luaext/loadbalance/policy/roundrobin.lua b/openresty-ext/src/assembly/resources/openresty/nginx/luaext/loadbalance/policy/roundrobin.lua
index 0a1b8e8..739b57b 100644
--- a/openresty-ext/src/assembly/resources/openresty/nginx/luaext/loadbalance/policy/roundrobin.lua
+++ b/openresty-ext/src/assembly/resources/openresty/nginx/luaext/loadbalance/policy/roundrobin.lua
@@ -1,6 +1,6 @@
--[[
- Copyright (C) 2016 ZTE, Inc. and others. All rights reserved. (ZTE)
+ Copyright (C) 2017 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.
diff --git a/openresty-ext/src/assembly/resources/openresty/nginx/luaext/plugins/base_plugin.lua b/openresty-ext/src/assembly/resources/openresty/nginx/luaext/plugins/base_plugin.lua
index 5ad9c78..1c73495 100644
--- a/openresty-ext/src/assembly/resources/openresty/nginx/luaext/plugins/base_plugin.lua
+++ b/openresty-ext/src/assembly/resources/openresty/nginx/luaext/plugins/base_plugin.lua
@@ -1,6 +1,6 @@
--[[
- Copyright (C) 2016 ZTE, Inc. and others. All rights reserved. (ZTE)
+ Copyright (C) 2017 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.
diff --git a/openresty-ext/src/assembly/resources/openresty/nginx/luaext/plugins/config_custom.lua b/openresty-ext/src/assembly/resources/openresty/nginx/luaext/plugins/config_custom.lua
index bc84ebc..d02b621 100644
--- a/openresty-ext/src/assembly/resources/openresty/nginx/luaext/plugins/config_custom.lua
+++ b/openresty-ext/src/assembly/resources/openresty/nginx/luaext/plugins/config_custom.lua
@@ -1,6 +1,6 @@
--[[
- Copyright (C) 2016 ZTE, Inc. and others. All rights reserved. (ZTE)
+ Copyright (C) 2017 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.
diff --git a/openresty-ext/src/assembly/resources/openresty/nginx/luaext/plugins/redirect-transformer/handler.lua b/openresty-ext/src/assembly/resources/openresty/nginx/luaext/plugins/redirect-transformer/handler.lua
index f469aa0..4c58349 100644
--- a/openresty-ext/src/assembly/resources/openresty/nginx/luaext/plugins/redirect-transformer/handler.lua
+++ b/openresty-ext/src/assembly/resources/openresty/nginx/luaext/plugins/redirect-transformer/handler.lua
@@ -1,6 +1,6 @@
--[[
- Copyright (C) 201-2018 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.
diff --git a/openresty-ext/src/assembly/resources/openresty/nginx/luaext/plugins/sampleplugin/handler.lua b/openresty-ext/src/assembly/resources/openresty/nginx/luaext/plugins/sampleplugin/handler.lua
index 539053a..9e6fa10 100644
--- a/openresty-ext/src/assembly/resources/openresty/nginx/luaext/plugins/sampleplugin/handler.lua
+++ b/openresty-ext/src/assembly/resources/openresty/nginx/luaext/plugins/sampleplugin/handler.lua
@@ -1,6 +1,6 @@
--[[
- Copyright (C) 2016 ZTE, Inc. and others. All rights reserved. (ZTE)
+ Copyright (C) 2017 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.
diff --git a/openresty-ext/src/assembly/resources/openresty/nginx/luaext/rewrite/commonrewrite.lua b/openresty-ext/src/assembly/resources/openresty/nginx/luaext/rewrite/commonrewrite.lua
deleted file mode 100644
index 6bea893..0000000
--- a/openresty-ext/src/assembly/resources/openresty/nginx/luaext/rewrite/commonrewrite.lua
+++ /dev/null
@@ -1,138 +0,0 @@
---[[
-
- Copyright (C) 2016 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.
-
---]]
-
-local dbclient = require('dao.db_access')
-local tbl_util = require('lib.utils.table_util')
-local svc_util = require('lib.utils.svc_util')
-local log_util = require('lib.utils.log_util')
-local error_handler = require('lib.utils.error_handler')
-
-local tbl_concat = table.concat
-local tbl_isempty = tbl_util.isempty
-local svc_isactive = svc_util.isactive
-local svc_get_url = svc_util.get_url
-local svc_get_backend_protocol = svc_util.get_backend_protocol
-local svc_use_own_upstream = svc_util.use_own_upstream
-local svc_get_key_prefix = svc_util.get_key_prefix
-local svc_is_api_related_types = svc_util.is_api_related_types
-local error_svc_not_found = error_handler.svc_not_found
-local error_upstream_not_found = error_handler.upstream_not_found
-
-local str_sub = string.sub
-local str_len = string.len
-local str_low = string.lower
-local ngx_var = ngx.var
-local ngx_ctx = ngx.ctx
-local log = log_util.log
-
----------------------------------------------------------------
---preCheck:
--- determine whether it is websocket request
--- and do internal redirect
----------------------------------------------------------------
-local http_upgrade = ngx_var.http_upgrade
-if(ngx_var.websocket_internal_redirect == "on") and http_upgrade and str_low(http_upgrade) == "websocket" then
- --ngx.log(ngx.ERR, "Websocket request and redirect to @commonwebsocket")
- return ngx.exec("@commonwebsocket");
-end
-
----------------------------------------------------------------
---step0:Preparation
--- svc_info_key
--- svc_server_keypattern
----------------------------------------------------------------
-local svc_name = ngx_var.svc_name
-local req_res = ngx_var.req_res
-local svc_type = ngx_var.svc_type
-
-local key_prefix = svc_get_key_prefix()
-
-local svc_key = ""
-if(svc_is_api_related_types(svc_type)) then
- -- process version info first
- local version1 = ngx_var.svc_version1
- local version2 = ngx_var.svc_version2
- local version = ""
- -- check version info appearing befor or after
- if(not version2) then version2 = "" end --convert nil to empty sting avoiding throw error
- if(not version1 or version1 == "") then
- version = version2
- else
- version = version1
- req_res = version2..req_res
- end
- -- remove the slash in front of the version (e.g. /V1.0)
- local svc_version=str_sub(version,2,str_len(version))
- svc_key = tbl_concat({key_prefix,"api",svc_name,svc_version},":")
-else
- svc_key = tbl_concat({key_prefix,"iui",svc_name},":")
-end
-
----------------------------------------------------------------
---step1:query the service info from share memory or back db
--- svcinfo: the requested service information
----------------------------------------------------------------
-local svcinfo = dbclient.load_serviceinfo(svc_key)
-if tbl_isempty(svcinfo) then
- error_svc_not_found("No route found for this request!","common not match. key--"..svc_key)
-end
-if not svc_isactive(svcinfo) then
- error_svc_not_found("Service is disabled!","common not match. key--"..svc_key)
-end
-
-local svc_url = svc_get_url(svcinfo,svc_type)
-
----------------------------------------------------------------
---step2:rewrite the request uri using the svcinfo
----------------------------------------------------------------
-local rewrited_uri = svc_url..req_res
---special handling: avoid throws internal error when it is empty
---if (rewrited_uri == "") then rewrited_uri = "/" end
-if (rewrited_uri == "") then return ngx.redirect(ngx.var.uri.."/") end
-ngx.req.set_uri(rewrited_uri)
-
-log("matched",svc_name)
---log("rewrited_uri",rewrited_uri)
----------------------------------------------------------------
---step2.1:store the svcinfo in the context, plugins may use it
----------------------------------------------------------------
-ngx_ctx.svcinfo = svcinfo
-
----------------------------------------------------------------
---step3:process the proxy upstream part
--- con1-using consul template:set the upstream name
--- con2-using msb balancer:query the server list and store in the ctx
----------------------------------------------------------------
---set the http_protocol used by proxy_pass directive
-ngx_var.http_protocol = svc_get_backend_protocol(svcinfo)
-
-if svc_use_own_upstream(svcinfo) then
- local consul_servicename = svcinfo.spec["consulServiceName"]
- if not consul_servicename or consul_servicename == "" then
- error_upstream_not_found()
- end
- ngx_var.backend = consul_servicename
- ngx.ctx.use_ownupstream = true
-else
- local backservers = svcinfo.spec.nodes
- if tbl_isempty(backservers) then
- error_svc_not_found("No active backend server found!"," key--"..svc_key)
- end
- ngx_ctx.backservers = backservers
- ngx_ctx.svc_key = svc_key
-end \ No newline at end of file
diff --git a/openresty-ext/src/assembly/resources/openresty/nginx/luaext/rewrite/customrewrite.lua b/openresty-ext/src/assembly/resources/openresty/nginx/luaext/rewrite/customrewrite.lua
deleted file mode 100644
index 89a829d..0000000
--- a/openresty-ext/src/assembly/resources/openresty/nginx/luaext/rewrite/customrewrite.lua
+++ /dev/null
@@ -1,203 +0,0 @@
---[[
-
- Copyright (C) 2016 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.
-
---]]
-
-local msbConf = require('conf.msbinit')
-local dbclient = require('dao.db_access')
-local tbl_util = require('lib.utils.table_util')
-local svc_util = require('lib.utils.svc_util')
-local log_util = require('lib.utils.log_util')
-local error_handler = require('lib.utils.error_handler')
-
-local tbl_concat = table.concat
-local tbl_isempty = tbl_util.isempty
-local svc_isactive = svc_util.isactive
-local svc_get_url = svc_util.get_url
-local svc_get_backend_protocol = svc_util.get_backend_protocol
-local svc_use_own_upstream = svc_util.use_own_upstream
-local svc_get_key_prefix = svc_util.get_key_prefix
-local str_low = string.lower
-local ngx_var = ngx.var
-local ngx_ctx = ngx.ctx
-local log = log_util.log
-local error_svc_not_found = error_handler.svc_not_found
-local error_upstream_not_found = error_handler.upstream_not_found
-
-local enablerefercheck = msbConf.systemConf.enablerefercheck
-local useconsultemplate = msbConf.systemConf.useconsultemplate
-
----------------------------------------------------------------
---preCheck:
--- determine whether it is websocket request
--- and do internal redirect
----------------------------------------------------------------
-if ngx.var.uri == "/" then
- local m, err = ngx.re.match(ngx.var.host, "^((25[0-5]|2[0-4]\\d|[01]?\\d\\d?)\\.){3}(25[0-5]|2[0-4]\\d|[01]?\\d\\d?)$","o")
- if m then
- return ngx.exec("@defaultpage")
- end
-end
-
-local http_upgrade = ngx_var.http_upgrade
-if(ngx_var.websocket_internal_redirect == "on") and http_upgrade and str_low(http_upgrade)== "websocket" then
- --ngx.log(ngx.ERR, "Websocket request and redirect to @customwebsocket")
- return ngx.exec("@customwebsocket")
-end
-
----------------------------------------------------------------
---step0:Preparation
--- svcnames:service names registered under this port
----------------------------------------------------------------
-local req_res = ngx_var.uri
-local svc_type = ngx_var.svc_type
-local key_prefix = svc_get_key_prefix()
-
-local custom_svc_keypattern = tbl_concat({key_prefix,"custom","*"},":")
-
-local get_svckey_custom = function(svcname)
- return tbl_concat({key_prefix,"custom",svcname},":")
-end
-
-local svcnames,err = dbclient.load_customsvcnames(custom_svc_keypattern)
-if not svcnames then
- error_svc_not_found("Failed to load the route table!","keypattern--"..custom_svc_keypattern)
-end
-
----------------------------------------------------------------
---step1:run the match process(check whether the request
--- match the name in the svcnames one by one)
--- and return the matched serice info
----------------------------------------------------------------
-local matchedsvcname
-local svcinfo
-local svc_key = ""
---add by wangyg:20160418 special handler for refer
-local matched_usingrefer = false
---end of add by wangyg:20160418 special handler for refer
-for _, svcname in ipairs(svcnames) do
- if (svcname == "/") then
- svc_key = get_svckey_custom(svcname)
- local svc_info,err = dbclient.load_serviceinfo(svc_key)
- if svc_info and svc_isactive(svc_info)then
- matchedsvcname = svcname
- svcinfo = svc_info
- break
- end
- end
- local from, to, err = ngx.re.find(req_res, "^"..svcname.."(/(.*))?$", "jo")
- --check whether svcname is the prefix of the req uri
- if from then
- svc_key = get_svckey_custom(svcname)
- local svc_info,err = dbclient.load_serviceinfo(svc_key)
- if svc_info and svc_isactive(svc_info) then
- matchedsvcname = svcname
- svcinfo = svc_info
- break
- end
- else
- --do nothing
- end
-end
----------------------------------------------------------------
---step1.1:additional process,test against the refer
--- similar to step1
----------------------------------------------------------------
---add by wangyg:20160418 special handler for refer
-if not matchedsvcname and enablerefercheck then
- local refer = ngx_var.http_referer
- if(refer and refer~="") then
- for _, svcname in ipairs(svcnames) do
- local urlreg ="^(https://|http://|)(([1-9]|([1-9]\\d)|(1\\d\\d)|(2([0-4]\\d|5[0-5])))\\.)(([0-9]|([1-9]\\d)|(1\\d\\d)|(2([0-4]\\d|5[0-5])))\\.){2}([1-9]|([1-9]\\d)|(1\\d\\d)|(2([0-4]\\d|5[0-5])))(:\\d{1,5})?"..svcname.."(/(.*))?$";
- local from, to, err = ngx.re.find(refer, urlreg, "jo")
- ----check whether svcname is the prefix of the req refer
- if from then
- svc_key = get_svckey_custom(svcname)
- local svc_info,err = dbclient.load_serviceinfo(svc_key)
- if svc_info and svc_isactive(svc_info) then
- matchedsvcname = svcname
- svcinfo = svc_info
- matched_usingrefer = true
- break
- end
- end
- end
- end
-end
---end of add by wangyg:20160418 special handler for refer
-
-if not matchedsvcname or tbl_isempty(svcinfo) then
- error_svc_not_found("No route found for this request!","custom not match")
-end
-
-local svc_url = svc_get_url(svcinfo,svc_type)
-
----------------------------------------------------------------
---step2:rewrite the request uri using the svcinfo
----------------------------------------------------------------
-local rewrited_uri =""
-if (matchedsvcname == "/") then
- --special handling: if "/" matched, contact directly
- rewrited_uri = svc_url..req_res
-else
- --rewrited_uri = ngx.re.sub(req_res, "^"..matchedsvcname.."(.*)", svc_url.."$1", "o")
- local newuri,n,err = ngx.re.sub(req_res, "^"..matchedsvcname.."(/.*)?", svc_url.."$1", "o")
- --add by wangyg:20160418 special handler for refer
- if(n==0 and matched_usingrefer) then newuri = svc_url..req_res end --special handling if matched using refer
- --end of add by wangyg:20160418 special handler for refer
- rewrited_uri = newuri
-end
---if (rewrited_uri == "") then rewrited_uri = "/" end --avoid throws internal error when it is empty
-if (rewrited_uri == "") then return ngx.redirect(ngx.var.uri.."/") end
-ngx.req.set_uri(rewrited_uri)
-
---set the matched service info,used in the proxy_redirect directive
-ngx_var.svc_name = matchedsvcname
-ngx_var.svc_url = svc_url
-
---log the route info
-log("matched",matchedsvcname)
-if(matched_usingrefer) then log("matched_usingrefer",true) end
---log("rewrited_uri",rewrited_uri)
-
----------------------------------------------------------------
---step2.1:store the svcinfo in the context, plugins may use it
----------------------------------------------------------------
-ngx_ctx.svcinfo = svcinfo
-
----------------------------------------------------------------
---step3:process the proxy upstream part
--- con1-using consul template:set the upstream name
--- con2-using msb balancer:query the backserver list and store in the ctx
----------------------------------------------------------------
---set the http_protocol used by proxy_pass directive
-ngx_var.http_protocol = svc_get_backend_protocol(svcinfo)
-
-if svc_use_own_upstream(svcinfo) then
- local consul_servicename = svcinfo.spec["consulServiceName"]
- if not consul_servicename or consul_servicename == "" then
- error_upstream_not_found()
- end
- ngx_var.backend = consul_servicename
- ngx.ctx.use_ownupstream = true
-else
- local backservers = svcinfo.spec.nodes
- if tbl_isempty(backservers) then
- error_svc_not_found("No active backend server found!","key--"..svc_key)
- end
- ngx_ctx.backservers = backservers
- ngx_ctx.svc_key = svc_key
-end \ No newline at end of file
diff --git a/openresty-ext/src/assembly/resources/openresty/nginx/msb-enabled/location-ext/defaultpage.conf b/openresty-ext/src/assembly/resources/openresty/nginx/msb-enabled/location-ext/defaultpage.conf
deleted file mode 100644
index edd9ed9..0000000
--- a/openresty-ext/src/assembly/resources/openresty/nginx/msb-enabled/location-ext/defaultpage.conf
+++ /dev/null
@@ -1,9 +0,0 @@
-location @defaultpage {
- content_by_lua_block{
- local error_page_head = '<html><head><title>502 Bad Gateway</title></head><body bgcolor="white"><center><h1>502 Bad Gateway</h1></center><center>error message:'
- local error_page_foot = '</center><hr><center>nginx</center></body></html>'
- ngx.status = ngx.HTTP_BAD_GATEWAY
- ngx.print(error_page_head.."default homepage undefined"..error_page_foot)
- return ngx.exit(ngx.status)
- }
-} \ No newline at end of file
diff --git a/openresty-ext/src/assembly/resources/openresty/run.sh b/openresty-ext/src/assembly/resources/openresty/run.sh
index 1b64c0d..ed2a393 100644
--- a/openresty-ext/src/assembly/resources/openresty/run.sh
+++ b/openresty-ext/src/assembly/resources/openresty/run.sh
@@ -1,6 +1,6 @@
#!/bin/sh
#
-# Copyright (C) 2016 ZTE, Inc. and others. All rights reserved. (ZTE)
+# Copyright (C) 2017 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.
diff --git a/openresty-ext/src/assembly/resources/openresty/run4docker.sh b/openresty-ext/src/assembly/resources/openresty/run4docker.sh
index 329dabc..e956aa7 100644
--- a/openresty-ext/src/assembly/resources/openresty/run4docker.sh
+++ b/openresty-ext/src/assembly/resources/openresty/run4docker.sh
@@ -1,6 +1,6 @@
#!/bin/sh
#
-# Copyright (C) 2016 ZTE, Inc. and others. All rights reserved. (ZTE)
+# Copyright (C) 2017 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.
diff --git a/openresty-ext/src/assembly/resources/openresty/stop.sh b/openresty-ext/src/assembly/resources/openresty/stop.sh
index 343bff4..a5cbac1 100644
--- a/openresty-ext/src/assembly/resources/openresty/stop.sh
+++ b/openresty-ext/src/assembly/resources/openresty/stop.sh
@@ -1,6 +1,6 @@
#!/bin/bash
#
-# Copyright (C) 2016 ZTE, Inc. and others. All rights reserved. (ZTE)
+# Copyright (C) 2017 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.