summaryrefslogtreecommitdiffstats
path: root/msb-core/openresty-ext
diff options
context:
space:
mode:
authorZhaoxing <meng.zhaoxing1@zte.com.cn>2016-09-08 23:20:06 +0800
committerZhaoxing <meng.zhaoxing1@zte.com.cn>2016-09-09 14:18:38 +0800
commitb69d850757a7a8c4ff9a368df004a3cfaaf9f1e4 (patch)
tree6ba5fb3330c763fd3d550ec3671f723587beae65 /msb-core/openresty-ext
parent3be6b09b74dd3e54e631181dc37bd1e5685a1c62 (diff)
Issue-id: OCS-9
Change-Id: I73c18bdda656c43687810930338f9a949ed08848 Signed-off-by: Zhaoxing <meng.zhaoxing1@zte.com.cn>
Diffstat (limited to 'msb-core/openresty-ext')
-rw-r--r--msb-core/openresty-ext/pom.xml194
-rw-r--r--msb-core/openresty-ext/src/assembly/resources/openresty/nginx/conf/nginx.conf212
-rw-r--r--msb-core/openresty-ext/src/assembly/resources/openresty/nginx/luaext/auth.lua15
-rw-r--r--msb-core/openresty-ext/src/assembly/resources/openresty/nginx/luaext/customrouter.lua194
-rw-r--r--msb-core/openresty-ext/src/assembly/resources/openresty/nginx/luaext/iui_auth.lua41
-rw-r--r--msb-core/openresty-ext/src/assembly/resources/openresty/nginx/luaext/login.lua9
-rw-r--r--msb-core/openresty-ext/src/assembly/resources/openresty/nginx/luaext/logout.lua6
-rw-r--r--msb-core/openresty-ext/src/assembly/resources/openresty/nginx/luaext/make_authed.lua44
-rw-r--r--msb-core/openresty-ext/src/assembly/resources/openresty/nginx/luaext/openoadminrouter.lua110
-rw-r--r--msb-core/openresty-ext/src/assembly/resources/openresty/nginx/luaext/openoapijsonrouter.lua110
-rw-r--r--msb-core/openresty-ext/src/assembly/resources/openresty/nginx/luaext/openoapirouter.lua117
-rw-r--r--msb-core/openresty-ext/src/assembly/resources/openresty/nginx/luaext/openouirouter.lua115
-rw-r--r--msb-core/openresty-ext/src/assembly/resources/openresty/nginx/luaext/serviceaccess.lua15
-rw-r--r--msb-core/openresty-ext/src/assembly/resources/openresty/nginx/luaext/setnocacheflag.lua29
-rw-r--r--msb-core/openresty-ext/src/assembly/resources/openresty/nginx/sites-enabled/openomsb.conf150
-rw-r--r--msb-core/openresty-ext/src/assembly/resources/openresty/reload.sh7
-rw-r--r--msb-core/openresty-ext/src/assembly/resources/openresty/run.bat105
-rw-r--r--msb-core/openresty-ext/src/assembly/resources/openresty/run.sh7
-rw-r--r--msb-core/openresty-ext/src/assembly/resources/openresty/run4docker.sh39
-rw-r--r--msb-core/openresty-ext/src/assembly/resources/openresty/stop.bat105
-rw-r--r--msb-core/openresty-ext/src/assembly/resources/openresty/stop.sh8
21 files changed, 1075 insertions, 557 deletions
diff --git a/msb-core/openresty-ext/pom.xml b/msb-core/openresty-ext/pom.xml
index 1db2516..09b6bca 100644
--- a/msb-core/openresty-ext/pom.xml
+++ b/msb-core/openresty-ext/pom.xml
@@ -1,96 +1,98 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-
- 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.
-
--->
-
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <parent>
- <groupId>org.openo.common-services.microservice-bus</groupId>
- <artifactId>msb-core-parent</artifactId>
- <version>1.0.0-SNAPSHOT</version>
- </parent>
-
-
- <modelVersion>4.0.0</modelVersion>
- <artifactId>openresty-ext</artifactId>
- <version>1.0.0-SNAPSHOT</version>
- <name>openo/msb/msb-core/openresty-ext</name>
- <packaging>pom</packaging>
-
- <properties>
- <outputdir>target/assembly</outputdir>
- <packageid>openresty-ext</packageid>
- </properties>
-
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-resources-plugin</artifactId>
- <configuration>
- <includeEmptyDirs>true</includeEmptyDirs>
- </configuration>
- <executions>
- <execution>
- <id>copy-resources</id>
- <phase>process-resources</phase>
- <goals>
- <goal>copy-resources</goal>
- </goals>
- <configuration>
- <outputDirectory>${outputdir}</outputDirectory>
- <resources>
- <resource>
- <directory>src/assembly/resources/</directory>
- <filtering>false</filtering>
- <includes>
- <include>**/*</include>
- </includes>
- </resource>
- </resources>
- <overwrite>true</overwrite>
- </configuration>
- </execution>
- </executions>
- </plugin>
-
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-antrun-plugin</artifactId>
- <executions>
- <execution>
- <id>distribution</id>
- <phase>package</phase>
- <goals>
- <goal>run</goal>
- </goals>
- <configuration>
- <target name="distribution">
- <zip destfile="target/${packageid}-${project.version}.zip" update="true">
- <zipfileset dir="target/assembly/" includes="**"/>
- </zip>
- <attachartifact file="target/${packageid}-${project.version}.zip" type="zip"/>
- </target>
- </configuration>
- </execution>
- </executions>
- </plugin>
-
- </plugins>
- </build>
-
-
-</project>
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Copyright 2016 2015-2016 ZTE, Inc. and others. All rights reserved.
+
+ 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.
+
+ Author: Zhaoxing Meng
+ email: meng.zhaoxing1@zte.com.cn
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <parent>
+ <groupId>org.openo.common-services.microservice-bus</groupId>
+ <artifactId>msb-core-parent</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ </parent>
+
+
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>openresty-ext</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <name>openo/msb/msb-core/openresty-ext</name>
+ <packaging>pom</packaging>
+
+ <properties>
+ <outputdir>target/assembly</outputdir>
+ <packageid>openresty-ext</packageid>
+ </properties>
+
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-resources-plugin</artifactId>
+ <configuration>
+ <includeEmptyDirs>true</includeEmptyDirs>
+ </configuration>
+ <executions>
+ <execution>
+ <id>copy-resources</id>
+ <phase>process-resources</phase>
+ <goals>
+ <goal>copy-resources</goal>
+ </goals>
+ <configuration>
+ <outputDirectory>${outputdir}</outputDirectory>
+ <resources>
+ <resource>
+ <directory>src/assembly/resources/</directory>
+ <filtering>false</filtering>
+ <includes>
+ <include>**/*</include>
+ </includes>
+ </resource>
+ </resources>
+ <overwrite>true</overwrite>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>distribution</id>
+ <phase>package</phase>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ <configuration>
+ <target name="distribution">
+ <zip destfile="target/${packageid}-${project.version}.zip" update="true">
+ <zipfileset dir="target/assembly/" includes="**"/>
+ </zip>
+ <attachartifact file="target/${packageid}-${project.version}.zip" type="zip"/>
+ </target>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
+ </plugins>
+ </build>
+
+
+</project>
diff --git a/msb-core/openresty-ext/src/assembly/resources/openresty/nginx/conf/nginx.conf b/msb-core/openresty-ext/src/assembly/resources/openresty/nginx/conf/nginx.conf
index 9a2db3f..c5dc770 100644
--- a/msb-core/openresty-ext/src/assembly/resources/openresty/nginx/conf/nginx.conf
+++ b/msb-core/openresty-ext/src/assembly/resources/openresty/nginx/conf/nginx.conf
@@ -1,3 +1,22 @@
+#
+# Copyright 2016 2015-2016 ZTE, Inc. and others. All rights reserved.
+#
+# 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.
+#
+# Author: Zhaoxing Meng
+# email: meng.zhaoxing1@zte.com.cn
+#
+
#user xfs xfs;
worker_processes 1;
@@ -9,64 +28,6 @@ events {
}
http {
- include mime.types;
-
- upstream iui {
- server 127.0.0.1:8202;
- }
-
- upstream nsoc {
- server 127.0.0.1:8203;
- }
-
- upstream roc {
- server 127.0.0.1:8204;
- }
-
- upstream umc {
- server 127.0.0.1:8205;
- }
-
- upstream ssh {
- server 127.0.0.1:8209;
- }
-
- upstream yamlparser {
- server 127.0.0.1:8210;
- }
-
- upstream dac {
- server 127.0.0.1:8206;
- }
-
- upstream cmcc {
- server 127.0.0.1:8207;
- }
-
- upstream tacker {
- server 127.0.0.1:8208;
- }
-
- upstream winery {
- server 127.0.0.1:8080;
- }
-
- upstream etsi {
- server 127.0.0.1:8211;
- }
-
- upstream openstackadapter {
- server 127.0.0.1:8217;
- }
-
- upstream vimadapter {
- server 127.0.0.1:8218;
- }
-
- upstream odlsdn {
- server 127.0.0.1:8216;
- }
-
# Basic Settings
default_type application/octet-stream;
sendfile on;
@@ -84,144 +45,27 @@ http {
proxy_send_timeout 120s;
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;
+ proxy_set_header Host $host;
proxy_buffers 4 32k;
#set the nginx_cache parameter
- #proxy_cache_path temp/proxy_cache levels=1:2 keys_zone=nginx_cache:10m inactive=1d max_size=100m;
+ proxy_cache_path temp/proxy_cache levels=1:2 keys_zone=nginx_cache:1024m inactive=1d max_size=10g;
# Logging
access_log off;
# Lua settings
lua_package_path "$prefix/../lualib/?.lua;;";
- lua_package_cpath "$prefix/../lualib/?.so;;";
lua_shared_dict ceryx 10M;
lua_code_cache on;
-
- server {
- listen 80;
- default_type text/html;
-
- location = / {
- rewrite ^ /iui/framework redirect;
- }
-
- location = /openo {
- rewrite ^ /iui/framework redirect;
- }
-
- location = /iui/openo {
- rewrite ^ /iui/framework redirect;
- }
-
- location = /iui/framework/login.html {
- access_by_lua_file luaext/iui_auth.lua;
- proxy_pass http://iui;
- }
-
- location = /api/uiframe/v1/login {
- rewrite ^ /api/umcsm/v1/login break;
- proxy_pass http://umc;
- header_filter_by_lua_file luaext/login.lua;
- }
-
- location = /api/uiframe/v1/loginOut {
- access_by_lua_file luaext/logout.lua;
- rewrite ^ /api/umcsm/v1/loginOut break;
- proxy_pass http://umc;
- }
-
- location = /api/hsif/v1/authentication {
- access_by_lua_file luaext/make_authed.lua;
- }
-
- location /iui {
- access_by_lua_file luaext/iui_auth.lua;
- proxy_pass http://iui;
- }
-
- location ~ ^/api/(?:vim|nsoc)/v1 {
- access_by_lua_file luaext/auth.lua;
- proxy_pass http://nsoc;
- }
-
- location = /api/nsoc/v1/vnfgrantinfo {
- rewrite ^ /api/vim/v1/vnfgrantinfo break;
- access_by_lua_file luaext/auth.lua;
- proxy_pass http://nsoc;
- }
-
- location /api/nsocnotification/v1 {
- rewrite ^/api/nsocnotification/v1/(.*) /nsocnotification/v1/$1 break;
- access_by_lua_file luaext/auth.lua;
- proxy_pass http://nsoc;
- }
-
- location ~ ^/api/(?:roc|rocnotification)/v1 {
- access_by_lua_file luaext/auth.lua;
- proxy_pass http://roc;
- }
-
- location /api/uiframe/v1 {
- rewrite ^/api/uiframe/v1/(.*) /api/umcsm/v1/$1 break;
- access_by_lua_file luaext/iui_auth.lua;
- proxy_pass http://umc;
- }
-
- location ~ ^/api/umc(?:pm|fm|drill|sm|monitor)/v1 {
- access_by_lua_file luaext/auth.lua;
- proxy_pass http://umc;
- }
-
- location ~ ^/api/ssh/v1 {
- proxy_pass http://ssh;
- }
-
- location ~ ^/api/yamlparser/v1 {
- proxy_pass http://yamlparser;
- }
-
- location ~ ^/api/(?:dac|dacnotification)/v1 {
- access_by_lua_file luaext/auth.lua;
- proxy_pass http://dac;
- }
-
- location /api/cmccia/v1 {
- access_by_lua_file luaext/auth.lua;
- proxy_pass http://cmcc;
- }
-
- location /api/tackeria/v1 {
- access_by_lua_file luaext/auth.lua;
- proxy_pass http://tacker;
- }
- location /winery {
- access_by_lua_file luaext/auth.lua;
- proxy_pass http://winery;
- }
-
- location = /api/microservices/v1/apiRoute {
- access_by_lua_file luaext/auth.lua;
- content_by_lua_file luaext/serviceaccess.lua;
- }
-
- location /api/umcswagger/v1 {
- rewrite ^/api/umcswagger/v1/(.*) /api/$1 break;
- access_by_lua_file luaext/auth.lua;
- proxy_pass http://umc;
- }
-
- location /api/etsiia/v1 {
- access_by_lua_file luaext/auth.lua;
- proxy_pass http://etsi;
- }
+ # see https://github.com/openresty/lua-resty-core
+ #init_by_lua '
+ # require "resty.core"
+ #';
- location /api/odlsdnia/v1 {
- access_by_lua_file luaext/auth.lua;
- proxy_pass http://odlsdn;
- }
- }
+ # Includes
+ include mime.types;
+ include ../sites-enabled/*.conf;
}
diff --git a/msb-core/openresty-ext/src/assembly/resources/openresty/nginx/luaext/auth.lua b/msb-core/openresty-ext/src/assembly/resources/openresty/nginx/luaext/auth.lua
deleted file mode 100644
index 067c277..0000000
--- a/msb-core/openresty-ext/src/assembly/resources/openresty/nginx/luaext/auth.lua
+++ /dev/null
@@ -1,15 +0,0 @@
-local cache = ngx.shared.ceryx
-local client_ip = ngx.var.remote_addr
-local host = ngx.var.host
-if client_ip == '127.0.0.1' or client_ip == host or client_ip == ngx.var.server_addr then
- return
-end
-local succ, err, forcible = cache:replace(client_ip, "place_holder", 3600)
-if not succ then
- if err == 'not found' then
- ngx.log(ngx.WARN, "access record not found for "..client_ip)
- ngx.exit(401)
- else
- ngx.log(ngx.WARN, err)
- end
-end \ No newline at end of file
diff --git a/msb-core/openresty-ext/src/assembly/resources/openresty/nginx/luaext/customrouter.lua b/msb-core/openresty-ext/src/assembly/resources/openresty/nginx/luaext/customrouter.lua
new file mode 100644
index 0000000..d1f476a
--- /dev/null
+++ b/msb-core/openresty-ext/src/assembly/resources/openresty/nginx/luaext/customrouter.lua
@@ -0,0 +1,194 @@
+--[[
+
+ Copyright 2016 2015-2016 ZTE, Inc. and others. All rights reserved.
+
+ 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.
+
+ Author: Zhaoxing Meng
+ email: meng.zhaoxing1@zte.com.cn
+
+]]
+-- put red into the connection pool of size 100,
+-- with 10 seconds max idle time
+local function close_redis(red)
+ if not red then
+ return
+ end
+ --release connection to the pool
+ local pool_max_idle_time = 10000
+ local pool_size = 100
+ local ok, err = red:set_keepalive(pool_max_idle_time, pool_size)
+ if not ok then
+ ngx.log(ngx.ERR, "set keepalive error:", err)
+ end
+ return
+end
+
+local function query_ipurl_updatecache(red,key)
+ local keyprefix = "msb:routing:custom:"..key
+
+
+ local infokey=keyprefix..":info"
+ -- first of all check whether the status is 1(enabled)
+ local status = red:hget(infokey,"status")
+ if not (status=="1") then
+ ngx.log(ngx.WARN, key.."is disabled.status=", status)
+ return nil
+ end
+
+ -- Try to get url for key
+ local url, err = red:hget(infokey,"url")
+ ngx.log(ngx.WARN, "==url:", url)
+ if not url or url == ngx.null then
+ return nil
+ end
+
+ -- Try to get ip:port for key
+ local serverkey=keyprefix..":lb:server1"
+ local server, err = red:hget(serverkey,"ip")..":"..red:hget(serverkey,"port")
+ ngx.log(ngx.WARN, "==server:", server)
+ if not server or server == ngx.null then
+ return nil
+ end
+
+ -- get the local cache
+ local cache = ngx.shared.ceryx
+ local uri = ngx.var.uri
+ -- Save found key to local cache for 5 seconds
+ cache:set("custom:key:"..uri,key,5)
+ cache:set("custom:server:"..uri,server,5)
+ cache:set("custom:url:"..uri,url,5)
+
+ ngx.var.key = key
+ ngx.var.server = server
+ ngx.var.url = url
+ return true
+end
+
+local function query_allkeys_updatecache(red)
+ -- Try to get all keys start with "msb:routing:custom:"
+ local allkeys, err = red:keys("msb:routing:custom:*")
+ if not allkeys or allkeys == ngx.null then
+ ngx.log(ngx.ERR,err)
+ return ""
+ end
+ --把所有键值处理后放到集合中,去除重复
+ local key_set={}
+ for key, value in ipairs(allkeys) do
+ name = string.gsub(string.gsub(string.gsub(value,"msb:routing:custom:",""),":info",""),":lb:server1","")
+ key_set[name]=true
+ end
+ --取出所有的�?放到table中准备排�?
+ local key_table = {}
+ local index = 1
+ for key,_ in pairs(key_set) do
+ --为了避免效率问题,暂时不用table.insert()
+ --table.insert(key_table,key)
+ key_table[index] = key
+ index = index + 1
+ end
+ --对所有键进行倒序排序,用于实现最长前缀匹配
+ table.sort(key_table, function (a, b)
+ return a > b
+ end)
+
+ local servicenames = ""
+ local delimiter = "<>"
+ for i=1,#key_table do
+ servicenames=servicenames..key_table[i]..delimiter
+ end
+
+ -- get the local cache
+ local cache = ngx.shared.ceryx
+ -- Save all keys to local cache for 30 seconds(0.5 minutes)
+ cache:set("customrouter:allkeys", servicenames, 30)
+ return servicenames;
+end
+
+local function query_router_info()
+ local uri = ngx.var.uri
+ ngx.log(ngx.WARN, "==uri:", uri)
+
+ -- Check if key exists in local cache
+ local cache = ngx.shared.ceryx
+ local key, flags = cache:get("custom:key:"..uri)
+ local server, flags = cache:get("custom:server:"..uri)
+ local url, flags = cache:get("custom:url:"..uri)
+ if key and server and url then
+ ngx.var.key = key
+ ngx.var.server = server
+ ngx.var.url = url
+ ngx.log(ngx.WARN, "==using custom cache:", key.."&&"..server.."&&"..url)
+ return
+ end
+
+ local redis = require "resty.redis"
+ local red = redis:new()
+ red:set_timeout(1000) -- 1000 ms
+ local redis_host = "127.0.0.1"
+ local redis_port = 6379
+ local res, err = red:connect(redis_host, redis_port)
+
+ -- Return if could not connect to Redis
+ if not res then
+ ngx.log(ngx.ERR, "connect to redis error:", err)
+ return
+ end
+
+ -- Check if all servicenames exists in local cache
+ local servicenames, flags = cache:get("customrouter:allkeys")
+ if servicenames then
+ ngx.log(ngx.WARN,"==get all keys from cache:",servicenames)
+ else
+ servicenames = query_allkeys_updatecache(red)
+ end
+
+ local delimiter = "<>"
+ -- '.-' 表示最短匹�?
+ for key in string.gmatch(servicenames,"(.-)"..delimiter) do
+ ngx.log(ngx.WARN, "==key_table key:", key)
+ local from, to, err = ngx.re.find(uri, "^"..key.."(/(.*))?$", "jo")
+ --判断key是否为输入uri�?前缀"
+ if from then
+ ngx.log(ngx.WARN,"Matched! start-end:",from,"-",to)
+ local result = query_ipurl_updatecache(red,key)
+ if result then
+ break
+ end
+ else
+ ngx.log(ngx.WARN,"not Matched")
+ if err then
+ ngx.log(ngx.WARN,"ngx.re.find throw error: ",err)
+ return
+ end
+ end
+ end
+
+ return close_redis(red)
+end
+
+local function rewrite_router_url()
+ local server=ngx.var.server
+ if server=="fallback" then
+ ngx.status = ngx.HTTP_NOT_FOUND
+ ngx.exit(ngx.status)
+ end
+ local url=ngx.var.url
+ local key=ngx.var.key
+ local rewriteduri = ngx.re.sub(ngx.var.uri, "^"..key.."(.*)", url.."$1", "o")
+ ngx.log(ngx.WARN, "==rewrited uri:", rewriteduri)
+ ngx.req.set_uri(rewriteduri)
+end
+
+query_router_info()
+rewrite_router_url() \ No newline at end of file
diff --git a/msb-core/openresty-ext/src/assembly/resources/openresty/nginx/luaext/iui_auth.lua b/msb-core/openresty-ext/src/assembly/resources/openresty/nginx/luaext/iui_auth.lua
deleted file mode 100644
index dd7b2ed..0000000
--- a/msb-core/openresty-ext/src/assembly/resources/openresty/nginx/luaext/iui_auth.lua
+++ /dev/null
@@ -1,41 +0,0 @@
-local cache = ngx.shared.ceryx
-local client_ip = ngx.var.remote_addr
-local uri = ngx.var.uri
-if uri == "/iui/framework/login.html" then
- local value, flags = cache:get(client_ip)
- if not value then
- return
- else
- ngx.redirect("/iui/framework/main-page.html")
- end
-end
-
-local referer = ngx.var.http_referer
-local refererList = {
- "/iui/framework/login.html",
- "/iui/framework/css/login.css",
- "/iui/component/thirdparty/font%-awesome/css/font%-awesome.min.css",
- "/iui/framework/css/style%-custom.css"
-}
-local function referer_matches(t, r)
- for k,_ in pairs(t) do
- if string.match(r, t[k]) then
- return true
- end
- end
- return false
-end
-
-if referer and referer_matches(refererList, referer) then
- return
-end
-
-local succ, err, forcible = cache:replace(client_ip, "place_holder", 3600)
-if not succ then
- if err == 'not found' then
- ngx.log(ngx.WARN, "access record not found for "..client_ip..",redirect to login page")
- ngx.redirect("/iui/framework/login.html")
- else
- ngx.log(ngx.WARN, err)
- end
-end \ No newline at end of file
diff --git a/msb-core/openresty-ext/src/assembly/resources/openresty/nginx/luaext/login.lua b/msb-core/openresty-ext/src/assembly/resources/openresty/nginx/luaext/login.lua
deleted file mode 100644
index 7d6bfd8..0000000
--- a/msb-core/openresty-ext/src/assembly/resources/openresty/nginx/luaext/login.lua
+++ /dev/null
@@ -1,9 +0,0 @@
-local h = ngx.resp.get_headers()
-if h["openoauth"] and h["openoauth"] == "true" then
- local cache = ngx.shared.ceryx
- local client_ip = ngx.var.remote_addr
- local succ, err, forcible = cache:set(client_ip, "place_holder", 3600)
- if not succ then
- ngx.log(ngx.WARN, err)
- end
-end \ No newline at end of file
diff --git a/msb-core/openresty-ext/src/assembly/resources/openresty/nginx/luaext/logout.lua b/msb-core/openresty-ext/src/assembly/resources/openresty/nginx/luaext/logout.lua
deleted file mode 100644
index e23f787..0000000
--- a/msb-core/openresty-ext/src/assembly/resources/openresty/nginx/luaext/logout.lua
+++ /dev/null
@@ -1,6 +0,0 @@
-local cache = ngx.shared.ceryx
-local client_ip = ngx.var.remote_addr
-local succ, err, forcible = cache:delete(client_ip)
-if not succ then
- ngx.log(ngx.WARN, err)
-end \ No newline at end of file
diff --git a/msb-core/openresty-ext/src/assembly/resources/openresty/nginx/luaext/make_authed.lua b/msb-core/openresty-ext/src/assembly/resources/openresty/nginx/luaext/make_authed.lua
deleted file mode 100644
index c4c2d78..0000000
--- a/msb-core/openresty-ext/src/assembly/resources/openresty/nginx/luaext/make_authed.lua
+++ /dev/null
@@ -1,44 +0,0 @@
-function ipValidator(ip)
- local chunks = {ip:match("(%d+)%.(%d+)%.(%d+)%.(%d+)")}
- if #chunks == 4 then
- for _,v in pairs(chunks) do
- if tonumber(v) > 255 then return R.STRING end
- end
- return true
- end
- local chunks = {ip:match(("([a-fA-F0-9]*):"):rep(8):gsub(":$","$"))}
- if #chunks == 8 then
- for _,v in pairs(chunks) do
- if #v > 0 and tonumber(v, 16) > 65535 then return R.STRING end
- end
- return true
- end
- return false
-end
-
-if ngx.req.get_method() == "POST" then
- ngx.req.read_body()
- local body = ngx.req.get_body_data()
- local json = require('cjson')
- local tab = json.decode(body)
- local ip = tab["passIp"]
- if not ip then
- ngx.log(ngx.WARN, "ip is nil.")
- ngx.exit(500)
- end
- if ipValidator(ip) then
- local cache = ngx.shared.ceryx
- local succ, err, forcible = cache:set(ip, "place_holder", 3600)
- if not succ then
- ngx.log(ngx.WARN, err)
- ngx.exit(500)
- end
- else
- ngx.log(ngx.WARN, "not a valid ip.")
- ngx.exit(500)
- end
- ngx.exit(201)
-else
- ngx.log(ngx.WARN, "not a POST request.")
- ngx.exit(500)
-end \ No newline at end of file
diff --git a/msb-core/openresty-ext/src/assembly/resources/openresty/nginx/luaext/openoadminrouter.lua b/msb-core/openresty-ext/src/assembly/resources/openresty/nginx/luaext/openoadminrouter.lua
new file mode 100644
index 0000000..d2f0895
--- /dev/null
+++ b/msb-core/openresty-ext/src/assembly/resources/openresty/nginx/luaext/openoadminrouter.lua
@@ -0,0 +1,110 @@
+--[[
+
+ Copyright 2016 2015-2016 ZTE, Inc. and others. All rights reserved.
+
+ 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.
+
+ Author: Zhaoxing Meng
+ email: meng.zhaoxing1@zte.com.cn
+
+]]
+-- put red into the connection pool of size 100,
+-- with 10 seconds max idle time
+local function close_redis(red)
+ if not red then
+ return
+ end
+ --release connection to the pool
+ local pool_max_idle_time = 10000
+ local pool_size = 100
+ local ok, err = red:set_keepalive(pool_max_idle_time, pool_size)
+ if not ok then
+ ngx.log(ngx.ERR, "set keepalive error:", err)
+ end
+ return
+end
+
+local function rewrite_admin_url()
+ local apiserver=ngx.var.apiserver
+ if apiserver=="fallback" then
+ ngx.status = ngx.HTTP_NOT_FOUND
+ ngx.exit(ngx.status)
+ end
+ local adminurl=ngx.var.adminurl
+ local uri = ngx.re.sub(ngx.var.uri, "^/admin/([^/]+)(/[Vv][^/]*)?(.*)", adminurl.."$3", "o")
+ ngx.req.set_uri(uri)
+end
+
+local function query_admin_info()
+ local apiserver = ngx.var.apiserver
+ local apiname = ngx.var.apiname
+ local apiversion = ngx.var.apiversion
+ apiversion=string.sub(apiversion,2,string.len(apiversion))
+
+ -- Check if key exists in local cache
+ local cache = ngx.shared.ceryx
+ local server, flags = cache:get("server:admin:"..apiname..":"..apiversion)
+ local url, flags = cache:get("url:admin:"..apiname..":"..apiversion)
+ if server and url then
+ ngx.var.apiserver = server
+ ngx.var.adminurl = url
+ ngx.log(ngx.WARN, "==using admin cache:", server.."&&"..url)
+ return
+ end
+
+ local redis = require "resty.redis"
+ local red = redis:new()
+ red:set_timeout(1000) -- 1000 ms
+ local redis_host = "127.0.0.1"
+ local redis_port = 6379
+ local res, err = red:connect(redis_host, redis_port)
+
+ -- Return if could not connect to Redis
+ if not res then
+ ngx.log(ngx.ERR, "connect to redis error:", err)
+ return
+ end
+
+ -- Construct Redis key
+ local prefix = "msb"
+ local keyprefix = prefix..":routing:api:"..apiname..":"..apiversion
+
+
+ -- Try to get ip:port for apiname
+ local serverkey=keyprefix..":lb:server1"
+ local server, err = red:hget(serverkey,"ip")..":"..red:hget(serverkey,"port")
+ ngx.log(ngx.WARN, "==adminserver:", server)
+ if not server or server == ngx.null then
+ return close_redis(red)
+ end
+
+ -- Try to get admin url for apiname
+ local infokey=keyprefix..":info"
+ local url, err = red:hget(infokey,"metricsUrl")
+ ngx.log(ngx.WARN, "==adminurl:", url)
+ if not url or url == ngx.null then
+ return close_redis(red)
+ end
+
+ -- Save found key to local cache for 5 seconds
+ cache:set("server:admin:"..apiname..":"..apiversion, server, 5)
+ cache:set("url:admin:"..apiname..":"..apiversion, url, 5)
+
+ ngx.log(ngx.WARN, "==admin result:", server.."&&"..url)
+ ngx.var.apiserver = server
+ ngx.var.adminurl = url
+
+ return close_redis(red)
+end
+query_admin_info()
+rewrite_admin_url() \ No newline at end of file
diff --git a/msb-core/openresty-ext/src/assembly/resources/openresty/nginx/luaext/openoapijsonrouter.lua b/msb-core/openresty-ext/src/assembly/resources/openresty/nginx/luaext/openoapijsonrouter.lua
new file mode 100644
index 0000000..1a061f0
--- /dev/null
+++ b/msb-core/openresty-ext/src/assembly/resources/openresty/nginx/luaext/openoapijsonrouter.lua
@@ -0,0 +1,110 @@
+--[[
+
+ Copyright 2016 2015-2016 ZTE, Inc. and others. All rights reserved.
+
+ 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.
+
+ Author: Zhaoxing Meng
+ email: meng.zhaoxing1@zte.com.cn
+
+]]
+-- put red into the connection pool of size 100,
+-- with 10 seconds max idle time
+local function close_redis(red)
+ if not red then
+ return
+ end
+ --release connection to the pool
+ local pool_max_idle_time = 10000
+ local pool_size = 100
+ local ok, err = red:set_keepalive(pool_max_idle_time, pool_size)
+ if not ok then
+ ngx.log(ngx.ERR, "set keepalive error:", err)
+ end
+ return
+end
+
+local function rewrite_apijson_url()
+ local apiserver=ngx.var.apiserver
+ if apiserver=="fallback" then
+ ngx.status = ngx.HTTP_NOT_FOUND
+ ngx.exit(ngx.status)
+ end
+ local apijsonurl=ngx.var.apijsonurl
+ local uri = ngx.re.sub(ngx.var.uri, "^/apijson/([^/]+)(/[Vv][^/]*)?(.*)", apijsonurl.."$3", "o")
+ ngx.req.set_uri(uri)
+end
+
+local function query_apijson_info()
+ local apiserver = ngx.var.apiserver
+ local apiname = ngx.var.apiname
+ local apiversion = ngx.var.apiversion
+ apiversion=string.sub(apiversion,2,string.len(apiversion))
+
+ -- Check if key exists in local cache
+ local cache = ngx.shared.ceryx
+ local server, flags = cache:get("server:apijson:"..apiname..":"..apiversion)
+ local url, flags = cache:get("url:apijson:"..apiname..":"..apiversion)
+ if server and url then
+ ngx.var.apiserver = server
+ ngx.var.apijsonurl = url
+ ngx.log(ngx.WARN, "==using apijson cache:", server.."&&"..url)
+ return
+ end
+
+ local redis = require "resty.redis"
+ local red = redis:new()
+ red:set_timeout(1000) -- 1000 ms
+ local redis_host = "127.0.0.1"
+ local redis_port = 6379
+ local res, err = red:connect(redis_host, redis_port)
+
+ -- Return if could not connect to Redis
+ if not res then
+ ngx.log(ngx.ERR, "connect to redis error:", err)
+ return
+ end
+
+ -- Construct Redis key
+ local prefix = "msb"
+ local keyprefix = prefix..":routing:api:"..apiname..":"..apiversion
+
+
+ -- Try to get ip:port for apiname
+ local serverkey=keyprefix..":lb:server1"
+ local server, err = red:hget(serverkey,"ip")..":"..red:hget(serverkey,"port")
+ ngx.log(ngx.WARN, "==apijsonserver:", server)
+ if not server or server == ngx.null then
+ return close_redis(red)
+ end
+
+ -- Try to get apijson url for apiname
+ local infokey=keyprefix..":info"
+ local url, err = red:hget(infokey,"apijson")
+ ngx.log(ngx.WARN, "==apijsonurl:", url)
+ if not url or url == ngx.null then
+ return close_redis(red)
+ end
+
+ -- Save found key to local cache for 5 seconds
+ cache:set("server:apijson:"..apiname..":"..apiversion, server, 5)
+ cache:set("url:apijson:"..apiname..":"..apiversion, url, 5)
+
+ ngx.log(ngx.WARN, "==apijson result:", server.."&&"..url)
+ ngx.var.apiserver = server
+ ngx.var.apijsonurl = url
+
+ return close_redis(red)
+end
+query_apijson_info()
+rewrite_apijson_url() \ No newline at end of file
diff --git a/msb-core/openresty-ext/src/assembly/resources/openresty/nginx/luaext/openoapirouter.lua b/msb-core/openresty-ext/src/assembly/resources/openresty/nginx/luaext/openoapirouter.lua
new file mode 100644
index 0000000..9dec2a9
--- /dev/null
+++ b/msb-core/openresty-ext/src/assembly/resources/openresty/nginx/luaext/openoapirouter.lua
@@ -0,0 +1,117 @@
+--[[
+
+ Copyright 2016 2015-2016 ZTE, Inc. and others. All rights reserved.
+
+ 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.
+
+ Author: Zhaoxing Meng
+ email: meng.zhaoxing1@zte.com.cn
+
+]]
+-- put red into the connection pool of size 100,
+-- with 10 seconds max idle time
+local function close_redis(red)
+ if not red then
+ return
+ end
+ --release connection to the pool
+ local pool_max_idle_time = 10000
+ local pool_size = 100
+ local ok, err = red:set_keepalive(pool_max_idle_time, pool_size)
+ if not ok then
+ ngx.log(ngx.ERR, "set keepalive error:", err)
+ end
+ return
+end
+
+local function rewrite_api_url()
+ local apiserver=ngx.var.apiserver
+ if apiserver=="fallback" then
+ ngx.status = ngx.HTTP_NOT_FOUND
+ ngx.exit(ngx.status)
+ end
+ local apiurl=ngx.var.apiurl
+ local uri = ngx.re.sub(ngx.var.uri, "^/openoapi/([^/]+)(/[Vv][^/]*)?(.*)", apiurl.."$3", "o")
+ ngx.req.set_uri(uri)
+end
+
+local function query_api_info()
+ local apiserver = ngx.var.apiserver
+ local apiname = ngx.var.apiname
+ local apiversion = ngx.var.apiversion
+ apiversion=string.sub(apiversion,2,string.len(apiversion))
+
+ -- Check if key exists in local cache
+ local cache = ngx.shared.ceryx
+ local server, flags = cache:get("server:api:"..apiname..":"..apiversion)
+ local url, flags = cache:get("url:api:"..apiname..":"..apiversion)
+ if server and url then
+ ngx.var.apiserver = server
+ ngx.var.apiurl = url
+ ngx.log(ngx.WARN, "==using api cache:", server.."&&"..url)
+ return
+ end
+
+ local redis = require "resty.redis"
+ local red = redis:new()
+ red:set_timeout(1000) -- 1000 ms
+ local redis_host = "127.0.0.1"
+ local redis_port = 6379
+ local res, err = red:connect(redis_host, redis_port)
+
+ -- Return if could not connect to Redis
+ if not res then
+ ngx.log(ngx.ERR, "connect to redis error:", err)
+ return
+ end
+
+ -- Construct Redis key
+ local prefix = "msb"
+ local keyprefix = prefix..":routing:api:"..apiname..":"..apiversion
+
+ local infokey=keyprefix..":info"
+ -- first of all check whether the status is 1(enabled)
+ local status = red:hget(infokey,"status")
+ if not (status=="1") then
+ ngx.log(ngx.WARN, keyprefix.."is disabled.status=", status)
+ return close_redis(red)
+ end
+
+ -- Try to get url for apiname
+ local url, err = red:hget(infokey,"url")
+ ngx.log(ngx.WARN, "==url:", url)
+ if not url or url == ngx.null then
+ return close_redis(red)
+ end
+
+ -- Try to get ip:port for apiname
+ local serverkey=keyprefix..":lb:server1"
+ local server, err = red:hget(serverkey,"ip")..":"..red:hget(serverkey,"port")
+ ngx.log(ngx.WARN, "==server:", server)
+ if not server or server == ngx.null then
+ return close_redis(red)
+ end
+
+
+ -- Save found key to local cache for 5 seconds
+ cache:set("server:api:"..apiname..":"..apiversion, server, 5)
+ cache:set("url:api:"..apiname..":"..apiversion, url, 5)
+
+ ngx.log(ngx.WARN, "==api result:", server.."&&"..url)
+ ngx.var.apiserver = server
+ ngx.var.apiurl = url
+
+ return close_redis(red)
+end
+query_api_info()
+rewrite_api_url() \ No newline at end of file
diff --git a/msb-core/openresty-ext/src/assembly/resources/openresty/nginx/luaext/openouirouter.lua b/msb-core/openresty-ext/src/assembly/resources/openresty/nginx/luaext/openouirouter.lua
new file mode 100644
index 0000000..736aacd
--- /dev/null
+++ b/msb-core/openresty-ext/src/assembly/resources/openresty/nginx/luaext/openouirouter.lua
@@ -0,0 +1,115 @@
+--[[
+
+ Copyright 2016 2015-2016 ZTE, Inc. and others. All rights reserved.
+
+ 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.
+
+ Author: Zhaoxing Meng
+ email: meng.zhaoxing1@zte.com.cn
+
+]]
+-- put red into the connection pool of size 100,
+-- with 10 seconds max idle time
+local function close_redis(red)
+ if not red then
+ return
+ end
+ --release connection to the pool
+ local pool_max_idle_time = 10000
+ local pool_size = 100
+ local ok, err = red:set_keepalive(pool_max_idle_time, pool_size)
+ if not ok then
+ ngx.log(ngx.ERR, "set keepalive error:", err)
+ end
+ return
+end
+
+local function rewrite_iui_url()
+ local iuiserver=ngx.var.iuiserver
+ if iuiserver=="fallback" then
+ ngx.status = ngx.HTTP_NOT_FOUND
+ ngx.exit(ngx.status)
+ end
+ local iuiurl=ngx.var.iuiurl
+ local uri = ngx.re.sub(ngx.var.uri, "^/openoui/([^/]+)(.*)", iuiurl.."$2", "o")
+ ngx.req.set_uri(uri)
+end
+
+local function query_iui_info()
+ local iuiserver = ngx.var.iuiserver
+ local iuiname = ngx.var.iuiname
+
+ -- Check if key exists in local cache
+ local cache = ngx.shared.ceryx
+ local server, flags = cache:get("server:iui:"..iuiname)
+ local url, flags = cache:get("url:iui:"..iuiname)
+ if server and url then
+ ngx.var.iuiserver = server
+ ngx.var.iuiurl = url
+ ngx.log(ngx.WARN, "==using iui cache:", server.."&&"..url)
+ return
+ end
+
+ local redis = require "resty.redis"
+ local red = redis:new()
+ red:set_timeout(1000) -- 1000 ms
+ local redis_host = "127.0.0.1"
+ local redis_port = 6379
+ local res, err = red:connect(redis_host, redis_port)
+
+ -- Return if could not connect to Redis
+ if not res then
+ ngx.log(ngx.ERR, "connect to redis error:", err)
+ return
+ end
+
+ -- Construct Redis key
+ local prefix = "msb"
+ local keyprefix = prefix..":routing:iui:"..iuiname
+
+ local infokey=keyprefix..":info"
+ -- first of all check whether the status is 1(enabled)
+ local status = red:hget(infokey,"status")
+ if not (status=="1") then
+ ngx.log(ngx.WARN, keyprefix.."is disabled.status=", status)
+ return close_redis(red)
+ end
+
+ -- Try to get url for iuiname
+ local url, err = red:hget(infokey,"url")
+ ngx.log(ngx.WARN, "==url:", url)
+ if not url or url == ngx.null then
+ return close_redis(red)
+ end
+
+ -- Try to get ip:port for iuiname
+ local serverkey=keyprefix..":lb:server1"
+ local server, err = red:hget(serverkey,"ip")..":"..red:hget(serverkey,"port")
+ ngx.log(ngx.WARN, "==server:", server)
+ if not server or server == ngx.null then
+ return close_redis(red)
+ end
+
+
+ -- Save found key to local cache for 5 seconds
+ cache:set("server:iui:"..iuiname, server, 5)
+ cache:set("url:iui:"..iuiname, url, 5)
+
+ ngx.log(ngx.WARN, "==iui result:", server.."&&"..url)
+ ngx.var.iuiserver = server
+ ngx.var.iuiurl = url
+
+ return close_redis(red)
+end
+query_iui_info()
+rewrite_iui_url() \ No newline at end of file
diff --git a/msb-core/openresty-ext/src/assembly/resources/openresty/nginx/luaext/serviceaccess.lua b/msb-core/openresty-ext/src/assembly/resources/openresty/nginx/luaext/serviceaccess.lua
deleted file mode 100644
index 1118341..0000000
--- a/msb-core/openresty-ext/src/assembly/resources/openresty/nginx/luaext/serviceaccess.lua
+++ /dev/null
@@ -1,15 +0,0 @@
-if ngx.req.get_method() == "GET" then
- local services = {
- {serviceName="odlsdnia",apiJson="/api/odlsdnia/v1/swagger.json"},
- {serviceName="roc",apiJson="/api/roc/v1/swagger.json"},
- {serviceName="tackeria",apiJson="/api/tackeria/v1/swagger.json"},
- {serviceName="etsi",apiJson="/api/etsiia/v1/swagger.json"}
- }
- local cjson = require "cjson"
- local jsonData = cjson.encode(services)
- jsonData = string.gsub(jsonData,"\\/","/")
- ngx.print(jsonData)
-else
- ngx.log(ngx.WARN, "not a GET request.")
- ngx.exit(500)
-end \ No newline at end of file
diff --git a/msb-core/openresty-ext/src/assembly/resources/openresty/nginx/luaext/setnocacheflag.lua b/msb-core/openresty-ext/src/assembly/resources/openresty/nginx/luaext/setnocacheflag.lua
new file mode 100644
index 0000000..e8c75cd
--- /dev/null
+++ b/msb-core/openresty-ext/src/assembly/resources/openresty/nginx/luaext/setnocacheflag.lua
@@ -0,0 +1,29 @@
+--[[
+
+ Copyright 2016 2015-2016 ZTE, Inc. and others. All rights reserved.
+
+ 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.
+
+ Author: Zhaoxing Meng
+ email: meng.zhaoxing1@zte.com.cn
+
+]]
+local from, to, err = ngx.re.find(ngx.var.uri, "\\.(gif|jpg|jpeg|png|bmp|ico)$", "jo")
+--Based on the request file type to determine whether to cache
+if from then
+ --use cache
+ return 0
+else
+ --do not use cache
+ return 1
+end \ No newline at end of file
diff --git a/msb-core/openresty-ext/src/assembly/resources/openresty/nginx/sites-enabled/openomsb.conf b/msb-core/openresty-ext/src/assembly/resources/openresty/nginx/sites-enabled/openomsb.conf
new file mode 100644
index 0000000..b529d94
--- /dev/null
+++ b/msb-core/openresty-ext/src/assembly/resources/openresty/nginx/sites-enabled/openomsb.conf
@@ -0,0 +1,150 @@
+#
+# Copyright 2016 2015-2016 ZTE, Inc. and others. All rights reserved.
+#
+# 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.
+#
+# Author: Zhaoxing Meng
+# email: meng.zhaoxing1@zte.com.cn
+#
+
+server {
+ listen 80;
+ default_type text/html;
+ add_header X-Cache-Status $upstream_cache_status;
+
+ location = /openoui/microservices {
+ rewrite /openoui/microservices /openoui/microservices/index.html redirect;
+ }
+
+ location / {
+ set $server "fallback";
+ set $url "";
+ set $key "";
+
+ # Lua files
+ rewrite_by_lua_file luaext/customrouter.lua;
+
+ proxy_pass http://$server;
+ }
+ location ~ ^/api/(.*) {
+ rewrite ^/api/(.*) /openoapi/$1 last;
+ }
+ location ~ ^/iui/(.*) {
+ rewrite ^/iui/(.*) /openoui/$1 last;
+ }
+ location ~ ^/openoapi/([^/]+)(/[Vv][^/]*)?(.*) {
+ set $apiname $1;
+ set $apiversion $2;
+ set $apiserver "fallback";
+ set $apiurl "";
+
+ # Lua files
+ rewrite_by_lua_file luaext/openoapirouter.lua;
+
+ proxy_pass http://$apiserver;
+ }
+
+ location ~ ^/openoui/([^/]+)(.*) {
+ location ~* ^/iui/([^/]+)(.*)\.(?:png|jpg|jpeg|js|css|html|gif|ico|bmp|woff)$ {
+ set $iuiname $1;
+ set $iuiparam $2;
+ set $iuiserver "fallback";
+ set $iuiurl "";
+
+ # Lua files
+ rewrite_by_lua_file luaext/openouirouter.lua;
+
+ proxy_cache nginx_cache;
+ proxy_cache_key $host$uri$is_args$args;
+ proxy_cache_valid 200 304 12h ;
+ proxy_cache_valid 301 302 1m ;
+ proxy_cache_valid any 1m ;
+ expires 12h;
+
+ proxy_pass http://$iuiserver;
+ }
+ set $iuiname $1;
+ set $iuiparam $2;
+ set $iuiserver "fallback";
+ set $iuiurl "";
+
+ # Lua files
+ rewrite_by_lua_file luaext/openouirouter.lua;
+
+ proxy_pass http://$iuiserver;
+ }
+
+ location ~ ^/admin/([^/]+)(/[Vv][^/]*)?(.*) {
+ set $apiname $1;
+ set $apiversion $2;
+ set $apiserver "fallback";
+ set $adminurl "";
+
+ # Lua files
+ rewrite_by_lua_file luaext/openoadminrouter.lua;
+
+ proxy_pass http://$apiserver;
+ }
+
+ location ~ ^/apijson/([^/]+)(/[Vv][^/]*)?(.*) {
+ location ~* ^/apijson/([^/]+)(/[v][^/]*)?(.*)\.(?:png|jpg|jpeg|js|css|html|gif|ico|bmp|woff)$ {
+ set $apiname $1;
+ set $apiversion $2;
+ set $apiserver "fallback";
+ set $apijsonurl "";
+
+ # Lua files
+ rewrite_by_lua_file luaext/openoapijsonrouter.lua;
+
+ proxy_cache nginx_cache;
+ proxy_cache_key $host$uri$is_args$args;
+ proxy_cache_valid 200 304 12h ;
+ proxy_cache_valid 301 302 1m ;
+ proxy_cache_valid any 1m ;
+ expires 12h;
+
+ proxy_pass http://$apiserver;
+ }
+ set $apiname $1;
+ set $apiversion $2;
+ set $apiserver "fallback";
+ set $apijsonurl "";
+
+ # Lua files
+ rewrite_by_lua_file luaext/openoapijsonrouter.lua;
+
+ proxy_pass http://$apiserver;
+ }
+
+ location ~* \.(?:png|jpg|jpeg|js|css|html|gif|ico|bmp|woff)$ {
+ set $server "fallback";
+ set $url "";
+ set $key "";
+
+ # Lua files
+ rewrite_by_lua_file luaext/customrouter.lua;
+
+ proxy_cache nginx_cache;
+ proxy_cache_key $host$uri$is_args$args;
+ proxy_cache_valid 200 304 12h ;
+ proxy_cache_valid 301 302 1m ;
+ proxy_cache_valid any 1m ;
+ expires 12h;
+
+ proxy_pass http://$server;
+ }
+
+ location = /favicon.ico {
+ log_not_found off;
+ }
+} \ No newline at end of file
diff --git a/msb-core/openresty-ext/src/assembly/resources/openresty/reload.sh b/msb-core/openresty-ext/src/assembly/resources/openresty/reload.sh
index 240b4b0..644f057 100644
--- a/msb-core/openresty-ext/src/assembly/resources/openresty/reload.sh
+++ b/msb-core/openresty-ext/src/assembly/resources/openresty/reload.sh
@@ -1,12 +1,12 @@
#!/bin/sh
#
-# Copyright (C) 2016 ZTE, Inc. and others. All rights reserved. (ZTE)
+# Copyright 2016 2015-2016 ZTE, Inc. and others. All rights reserved.
#
# 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
+# 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,
@@ -14,6 +14,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
+# Author: Zhaoxing Meng
+# email: meng.zhaoxing1@zte.com.cn
+#
DIRNAME=`dirname $0`
HOME=`cd $DIRNAME/nginx; pwd`
diff --git a/msb-core/openresty-ext/src/assembly/resources/openresty/run.bat b/msb-core/openresty-ext/src/assembly/resources/openresty/run.bat
index 151cad7..17302ce 100644
--- a/msb-core/openresty-ext/src/assembly/resources/openresty/run.bat
+++ b/msb-core/openresty-ext/src/assembly/resources/openresty/run.bat
@@ -1,52 +1,55 @@
-@REM
-@REM Copyright (C) 2016 ZTE, Inc. and others. All rights reserved. (ZTE)
-@REM
-@REM Licensed under the Apache License, Version 2.0 (the "License");
-@REM you may not use this file except in compliance with the License.
-@REM You may obtain a copy of the License at
-@REM
-@REM http://www.apache.org/licenses/LICENSE-2.0
-@REM
-@REM Unless required by applicable law or agreed to in writing, software
-@REM distributed under the License is distributed on an "AS IS" BASIS,
-@REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-@REM See the License for the specific language governing permissions and
-@REM limitations under the License.
-@REM
-
-@echo off
-title openresty-server
-@if not "%ECHO%" == "" echo %ECHO%
-@if "%OS%" == "Windows_NT" setlocal
-
-set DIRNAME=.
-
-if "%OS%" == "Windows_NT" set DIRNAME=%~dp0%
-
-set ARGS=
-:loop
-if [%1] == [] goto endloop
- set ARGS=%ARGS% %1
- shift
- goto loop
-:endloop
-
-set HOME=%DIRNAME%nginx
-set _NGINXCMD=%HOME%\nginx.exe
-
-echo =========== openresty config info ============================================
-echo HOME=%HOME%
-echo _NGINXCMD=%_NGINXCMD%
-echo ===============================================================================
-
-cd /d "%HOME%"
-echo @WORK_DIR@%HOME%
-echo @C_CMD@ "%_NGINXCMD%"
-%_NGINXCMD%
-IF ERRORLEVEL 1 goto showerror
-exit
-:showerror
-echo WARNING: Error occurred during startup or Server abnormally stopped by way of killing the process,Please check!
-echo After checking, press any key to close
-pause
+@REM
+@REM Copyright 2016 2015-2016 ZTE, Inc. and others. All rights reserved.
+@REM
+@REM Licensed under the Apache License, Version 2.0 (the "License");
+@REM you may not use this file except in compliance with the License.
+@REM You may obtain a copy of the License at
+@REM
+@REM http://www.apache.org/licenses/LICENSE-2.0
+@REM
+@REM Unless required by applicable law or agreed to in writing, software
+@REM distributed under the License is distributed on an "AS IS" BASIS,
+@REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+@REM See the License for the specific language governing permissions and
+@REM limitations under the License.
+@REM
+@REM Author: Zhaoxing Meng
+@REM email: meng.zhaoxing1@zte.com.cn
+@REM
+
+@echo off
+title openresty-server
+@if not "%ECHO%" == "" echo %ECHO%
+@if "%OS%" == "Windows_NT" setlocal
+
+set DIRNAME=.
+
+if "%OS%" == "Windows_NT" set DIRNAME=%~dp0%
+
+set ARGS=
+:loop
+if [%1] == [] goto endloop
+ set ARGS=%ARGS% %1
+ shift
+ goto loop
+:endloop
+
+set HOME=%DIRNAME%nginx
+set _NGINXCMD=%HOME%\nginx.exe
+
+echo =========== openresty config info ============================================
+echo HOME=%HOME%
+echo _NGINXCMD=%_NGINXCMD%
+echo ===============================================================================
+
+cd /d "%HOME%"
+echo @WORK_DIR@%HOME%
+echo @C_CMD@ "%_NGINXCMD%"
+%_NGINXCMD%
+IF ERRORLEVEL 1 goto showerror
+exit
+:showerror
+echo WARNING: Error occurred during startup or Server abnormally stopped by way of killing the process,Please check!
+echo After checking, press any key to close
+pause
exit \ No newline at end of file
diff --git a/msb-core/openresty-ext/src/assembly/resources/openresty/run.sh b/msb-core/openresty-ext/src/assembly/resources/openresty/run.sh
index 7ac3128..5c7dbc8 100644
--- a/msb-core/openresty-ext/src/assembly/resources/openresty/run.sh
+++ b/msb-core/openresty-ext/src/assembly/resources/openresty/run.sh
@@ -1,12 +1,12 @@
#!/bin/sh
#
-# Copyright (C) 2016 ZTE, Inc. and others. All rights reserved. (ZTE)
+# Copyright 2016 2015-2016 ZTE, Inc. and others. All rights reserved.
#
# 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
+# 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,
@@ -14,6 +14,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
+# Author: Zhaoxing Meng
+# email: meng.zhaoxing1@zte.com.cn
+#
DIRNAME=`dirname $0`
HOME=`cd $DIRNAME/nginx; pwd`
diff --git a/msb-core/openresty-ext/src/assembly/resources/openresty/run4docker.sh b/msb-core/openresty-ext/src/assembly/resources/openresty/run4docker.sh
deleted file mode 100644
index 329dabc..0000000
--- a/msb-core/openresty-ext/src/assembly/resources/openresty/run4docker.sh
+++ /dev/null
@@ -1,39 +0,0 @@
-#!/bin/sh
-#
-# 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.
-#
-DIRNAME=`dirname $0`
-HOME=`cd $DIRNAME/nginx; pwd`
-_NGINXCMD="$HOME/sbin/nginx"
-
-echo =========== create symbolic link for libluajit-5.1.so.2 ========================================
-LUAJIT_HOME=`cd $DIRNAME/luajit; pwd`
-LUAJIT_FILENAME="$LUAJIT_HOME/lib/libluajit-5.1.so.2"
-LN_TARGET_FILE='/lib/libluajit-5.1.so.2'
-LN_TARGET_FILE64='/lib64/libluajit-5.1.so.2'
-ln -s -f $LUAJIT_FILENAME $LN_TARGET_FILE
-ln -s -f $LUAJIT_FILENAME $LN_TARGET_FILE64
-echo ===============================================================================
-
-echo =========== openresty config info =============================================
-echo HOME=$HOME
-echo _NGINXCMD=$_NGINXCMD
-echo ===============================================================================
-cd $HOME; pwd
-
-echo @WORK_DIR@ $HOME
-echo @C_CMD@ $_NGINXCMD -p $HOME/
-$_NGINXCMD -p $HOME/ -g "daemon off;"
-
diff --git a/msb-core/openresty-ext/src/assembly/resources/openresty/stop.bat b/msb-core/openresty-ext/src/assembly/resources/openresty/stop.bat
index e5ea581..9fa6522 100644
--- a/msb-core/openresty-ext/src/assembly/resources/openresty/stop.bat
+++ b/msb-core/openresty-ext/src/assembly/resources/openresty/stop.bat
@@ -1,51 +1,54 @@
-@REM
-@REM Copyright (C) 2016 ZTE, Inc. and others. All rights reserved. (ZTE)
-@REM
-@REM Licensed under the Apache License, Version 2.0 (the "License");
-@REM you may not use this file except in compliance with the License.
-@REM You may obtain a copy of the License at
-@REM
-@REM http://www.apache.org/licenses/LICENSE-2.0
-@REM
-@REM Unless required by applicable law or agreed to in writing, software
-@REM distributed under the License is distributed on an "AS IS" BASIS,
-@REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-@REM See the License for the specific language governing permissions and
-@REM limitations under the License.
-@REM
-
-@echo off
-title close openresty-server
-@if not "%ECHO%" == "" echo %ECHO%
-@if "%OS%" == "Windows_NT" setlocal
-
-set DIRNAME=.
-
-if "%OS%" == "Windows_NT" set DIRNAME=%~dp0%
-
-set ARGS=
-:loop
-if [%1] == [] goto endloop
- set ARGS=%ARGS% %1
- shift
- goto loop
-:endloop
-
-set HOME=%DIRNAME%nginx
-set _NGINXCMD=%HOME%\nginx.exe
-
-
-echo =========== openresty config info ============================================
-echo HOME=%HOME%
-echo _NGINXCMD=%_NGINXCMD%
-echo ===============================================================================
-
-
-cd /d "%HOME%"
-echo @WORK_DIR@%HOME%
-echo @C_CMD@ "%_NGINXCMD% -s stop"
-
-%_NGINXCMD% -s stop
-echo closing signal has been sent,stopping in background,WAIT...
-timeout /t 5 /nobreak > nul
-exit
+@REM
+@REM Copyright 2016 2015-2016 ZTE, Inc. and others. All rights reserved.
+@REM
+@REM Licensed under the Apache License, Version 2.0 (the "License");
+@REM you may not use this file except in compliance with the License.
+@REM You may obtain a copy of the License at
+@REM
+@REM http://www.apache.org/licenses/LICENSE-2.0
+@REM
+@REM Unless required by applicable law or agreed to in writing, software
+@REM distributed under the License is distributed on an "AS IS" BASIS,
+@REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+@REM See the License for the specific language governing permissions and
+@REM limitations under the License.
+@REM
+@REM Author: Zhaoxing Meng
+@REM email: meng.zhaoxing1@zte.com.cn
+@REM
+
+@echo off
+title close openresty-server
+@if not "%ECHO%" == "" echo %ECHO%
+@if "%OS%" == "Windows_NT" setlocal
+
+set DIRNAME=.
+
+if "%OS%" == "Windows_NT" set DIRNAME=%~dp0%
+
+set ARGS=
+:loop
+if [%1] == [] goto endloop
+ set ARGS=%ARGS% %1
+ shift
+ goto loop
+:endloop
+
+set HOME=%DIRNAME%nginx
+set _NGINXCMD=%HOME%\nginx.exe
+
+
+echo =========== openresty config info ============================================
+echo HOME=%HOME%
+echo _NGINXCMD=%_NGINXCMD%
+echo ===============================================================================
+
+
+cd /d "%HOME%"
+echo @WORK_DIR@%HOME%
+echo @C_CMD@ "%_NGINXCMD% -s stop"
+
+%_NGINXCMD% -s stop
+echo closing signal has been sent,stopping in background,WAIT...
+timeout /t 5 /nobreak > nul
+exit
diff --git a/msb-core/openresty-ext/src/assembly/resources/openresty/stop.sh b/msb-core/openresty-ext/src/assembly/resources/openresty/stop.sh
index 343bff4..c5d0f19 100644
--- a/msb-core/openresty-ext/src/assembly/resources/openresty/stop.sh
+++ b/msb-core/openresty-ext/src/assembly/resources/openresty/stop.sh
@@ -1,12 +1,12 @@
#!/bin/bash
#
-# Copyright (C) 2016 ZTE, Inc. and others. All rights reserved. (ZTE)
+# Copyright 2016 2015-2016 ZTE, Inc. and others. All rights reserved.
#
# 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
+# 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,
@@ -14,6 +14,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
+# Author: Zhaoxing Meng
+# email: meng.zhaoxing1@zte.com.cn
+#
+
DIRNAME=`dirname $0`
HOME=`cd $DIRNAME/nginx; pwd`
_NGINXCMD="$HOME/sbin/nginx"