diff options
Diffstat (limited to 'openresty-ext/src/assembly/resources/openresty/nginx/msb-enabled')
8 files changed, 370 insertions, 0 deletions
diff --git a/openresty-ext/src/assembly/resources/openresty/nginx/msb-enabled/location-default/msblocations.conf b/openresty-ext/src/assembly/resources/openresty/nginx/msb-enabled/location-default/msblocations.conf new file mode 100644 index 0000000..745c290 --- /dev/null +++ b/openresty-ext/src/assembly/resources/openresty/nginx/msb-enabled/location-default/msblocations.conf @@ -0,0 +1,218 @@ +# +# 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. +# + + default_type text/html; + + # the flag identify whether to check doing internal redirect or not + set $websocket_internal_redirect "on"; + set $http_protocol "http"; + + + location = /iui/microservices { + try_files $uri @addslash; + } + + location @addslash { + return 302 $scheme://$http_host$uri/; + } + + #error_page 410 = @commonnotfound; + + location @commonnotfound { + set $svc_type "custom"; + set $svc_name ""; + set $svc_url ""; + set $backend "defaultbackend"; + + #rewrite by the lua file + rewrite_by_lua_file luaext/rewrite/customrewrite.lua; + access_by_lua_block { + msb.access() + } + header_filter_by_lua_block { + msb.header_filter() + } + #log by the lua file + log_by_lua_file luaext/log/logger.lua; + + proxy_pass $http_protocol://$backend; + proxy_redirect $http_protocol://$host:$server_port$svc_url $http_protocol://$host:$server_port$svc_name; + } + + location @customwebsocket { + set $websocket_internal_redirect "off"; + #set header for websocket + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "Upgrade"; + + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header Host $host:$server_port; + + #rewrite by the lua file + rewrite_by_lua_file luaext/rewrite/customrewrite.lua; + access_by_lua_block { + msb.access() + } + header_filter_by_lua_block { + msb.header_filter() + } + #log by the lua file + log_by_lua_file luaext/log/logger.lua; + + proxy_pass $http_protocol://$backend; + } + + location @commonwebsocket { + set $websocket_internal_redirect "off"; + #set header for websocket + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "Upgrade"; + + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header Host $host:$server_port; + + #rewrite by the lua file + rewrite_by_lua_file luaext/rewrite/commonrewrite.lua; + access_by_lua_block { + msb.access() + } + header_filter_by_lua_block { + msb.header_filter() + } + #log by the lua file + log_by_lua_file luaext/log/logger.lua; + + proxy_pass $http_protocol://$backend; + } + + location / { + set $svc_type "custom"; + set $svc_name ""; + set $svc_url ""; + set $backend "defaultbackend"; + + #rewrite by the lua file + rewrite_by_lua_file luaext/rewrite/customrewrite.lua; + access_by_lua_block { + msb.access() + } + header_filter_by_lua_block { + msb.header_filter() + } + #log by the lua file + log_by_lua_file luaext/log/logger.lua; + + proxy_pass $http_protocol://$backend; + proxy_redirect $http_protocol://$host:$server_port$svc_url $http_protocol://$host:$server_port$svc_name; + } + + location ~ ^/(api|admin|apijson)(/[Vv]\d+(?:\.\d+)*)?/([^/]+)(/[Vv]\d+(?:\.\d+)*)?(.*) { + set $svc_type $1; + set $svc_name $3; + set $svc_version1 $2; + set $svc_version2 $4; + set $req_res $5; + set $backend "defaultbackend"; + + #rewrite by the lua file + rewrite_by_lua_file luaext/rewrite/commonrewrite.lua; + access_by_lua_block { + msb.access() + } + header_filter_by_lua_block { + msb.header_filter() + } + #log by the lua file + log_by_lua_file luaext/log/logger.lua; + + proxy_pass $http_protocol://$backend; + } + + location ~* ^/iui/([^/]+)(.*)\.(png|jpg|jpeg|gif|ico|bmp|woff)$ { + set $svc_type "iui"; + set $svc_name $1; + set $req_res $2.$3; + set $backend "defaultbackend"; + + #rewrite by the lua file + rewrite_by_lua_file luaext/rewrite/commonrewrite.lua; + access_by_lua_block { + msb.access() + } + header_filter_by_lua_block { + msb.header_filter() + } + #log by the lua file + log_by_lua_file luaext/log/logger.lua; + + proxy_cache nginx_cache; + add_header X-Cache-Status $upstream_cache_status; + proxy_pass $http_protocol://$backend; + } + + location ~ ^/iui/([^/]+)(.*) { + set $svc_type "iui"; + set $svc_name $1; + set $req_res $2; + set $backend "defaultbackend"; + + #rewrite by the lua file + rewrite_by_lua_file luaext/rewrite/commonrewrite.lua; + access_by_lua_block { + msb.access() + } + header_filter_by_lua_block { + msb.header_filter() + } + #log by the lua file + log_by_lua_file luaext/log/logger.lua; + + proxy_pass $http_protocol://$backend; + } + + include ../msb-enabled/location-ext/*.conf; + include ../msb-enabled/location-ext-mount/*.conf; + + location ~* \.(?:png|jpg|jpeg|gif|ico|bmp|woff)$ { + set $svc_type "custom"; + set $svc_name ""; + set $svc_url ""; + set $backend "defaultbackend"; + + #rewrite by the lua file + rewrite_by_lua_file luaext/rewrite/customrewrite.lua; + access_by_lua_block { + msb.access() + } + header_filter_by_lua_block { + msb.header_filter() + } + #log by the lua file + log_by_lua_file luaext/log/logger.lua; + + proxy_cache nginx_cache; + add_header X-Cache-Status $upstream_cache_status; + proxy_pass $http_protocol://$backend; + proxy_redirect http://$host:$server_port$svc_url http://$host:$server_port$svc_name; + } + + location = /favicon.ico { + log_not_found off; + }
\ No newline at end of file diff --git a/openresty-ext/src/assembly/resources/openresty/nginx/msb-enabled/location-ext-mount/README.md b/openresty-ext/src/assembly/resources/openresty/nginx/msb-enabled/location-ext-mount/README.md new file mode 100644 index 0000000..ce00b06 --- /dev/null +++ b/openresty-ext/src/assembly/resources/openresty/nginx/msb-enabled/location-ext-mount/README.md @@ -0,0 +1,4 @@ +README +=============== +Similar to the location-ext directory,but it's just a placeholder folder. +The folder may always be empty and you attach an external folder found outside the container or the virtual machine at the directory.
\ No newline at end of file diff --git a/openresty-ext/src/assembly/resources/openresty/nginx/msb-enabled/location-ext/README.md b/openresty-ext/src/assembly/resources/openresty/nginx/msb-enabled/location-ext/README.md new file mode 100644 index 0000000..58310a7 --- /dev/null +++ b/openresty-ext/src/assembly/resources/openresty/nginx/msb-enabled/location-ext/README.md @@ -0,0 +1,11 @@ +README +=============== + +The directory to store configuration files that extends locations of the default listening server(e.g 10080). +The config file must be a *.conf file. For example: +#testlocation.conf +~~~ +location = /test { + echo "test ok"; +} +~~~
\ No newline at end of file diff --git a/openresty-ext/src/assembly/resources/openresty/nginx/msb-enabled/location-ext/cert.conf b/openresty-ext/src/assembly/resources/openresty/nginx/msb-enabled/location-ext/cert.conf new file mode 100644 index 0000000..3d84943 --- /dev/null +++ b/openresty-ext/src/assembly/resources/openresty/nginx/msb-enabled/location-ext/cert.conf @@ -0,0 +1,19 @@ +# +# 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. +# + +location /cert { + root html ; +}
\ 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 new file mode 100644 index 0000000..edd9ed9 --- /dev/null +++ b/openresty-ext/src/assembly/resources/openresty/nginx/msb-enabled/location-ext/defaultpage.conf @@ -0,0 +1,9 @@ +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/nginx/msb-enabled/location-ext/homepage.conf b/openresty-ext/src/assembly/resources/openresty/nginx/msb-enabled/location-ext/homepage.conf new file mode 100644 index 0000000..543691a --- /dev/null +++ b/openresty-ext/src/assembly/resources/openresty/nginx/msb-enabled/location-ext/homepage.conf @@ -0,0 +1,20 @@ +# +# 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. +# + +location = /msb { + #rewrite ^ /iui/microservices/default.html redirect; + return 302 $scheme://$http_host/iui/microservices/default.html; +}
\ No newline at end of file diff --git a/openresty-ext/src/assembly/resources/openresty/nginx/msb-enabled/msb.conf b/openresty-ext/src/assembly/resources/openresty/nginx/msb-enabled/msb.conf new file mode 100644 index 0000000..8e854bb --- /dev/null +++ b/openresty-ext/src/assembly/resources/openresty/nginx/msb-enabled/msb.conf @@ -0,0 +1,67 @@ +# +# 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. +# + +#the maximum allowed size of the client request body,current 10G +client_max_body_size 10240m; +client_body_buffer_size 128k; + +#set conf for proxy pass +proxy_connect_timeout 5s; +proxy_read_timeout 1200s; +proxy_send_timeout 1200s; +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_buffers 4 16k; +proxy_http_version 1.1; +proxy_set_header Connection ""; + +#set the nginx_cache parameter +proxy_cache_path temp/proxy_cache levels=1:2 keys_zone=nginx_cache:100m inactive=1d max_size=1g; +proxy_cache_key $host$uri$is_args$args; +proxy_cache_revalidate on; +proxy_cache_min_uses 3; +proxy_cache_use_stale error timeout updating http_500 http_502 http_503 http_504; +proxy_cache_lock on; + +proxy_next_upstream error timeout; +proxy_next_upstream_tries 5; + +# Lua settings +lua_package_path "$prefix/../lualib/?.lua;$prefix/luaext/?.lua;;"; +lua_package_cpath "$prefix/../lualib/?.so;;"; +#lua_shared_dict rr_cache 1M; +#lua_shared_dict rr_locks 100k; + +lua_shared_dict svc_cache 5M; +lua_shared_dict locks 200k; + +lua_code_cache on; + +# Basic reverse proxy server processor +upstream defaultbackend { + server 0.0.0.1; + balancer_by_lua_file luaext/loadbalance/balancer.lua; + keepalive 300; +} +init_by_lua_block { + msb = require('msb') + msb.load_plugins() +} +server { + listen 80; + include ../msb-enabled/location-default/msblocations.conf; +}
\ No newline at end of file diff --git a/openresty-ext/src/assembly/resources/openresty/nginx/msb-enabled/msbhttps.conf b/openresty-ext/src/assembly/resources/openresty/nginx/msb-enabled/msbhttps.conf new file mode 100644 index 0000000..430c05d --- /dev/null +++ b/openresty-ext/src/assembly/resources/openresty/nginx/msb-enabled/msbhttps.conf @@ -0,0 +1,22 @@ +# +# 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. +# +server { + listen 443 ssl; + ssl_certificate ../ssl/cert/cert.crt; + ssl_certificate_key ../ssl/cert/cert.key; + ssl_dhparam ../ssl/dh-pubkey/dhparams.pem; + include ../msb-enabled/location-default/msblocations.conf; +}
\ No newline at end of file |