# # 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. # 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; 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"; access_by_lua_block { ngx.log(ngx.INFO, ngx.var.request_id..":receive the request") msb.filter_websocket_req() msb.route() msb.access() if ngx.ctx.use_ownupstream then stats.forward_backend() end } header_filter_by_lua_block { stats.receive_response() msb.header_filter() stats.return_response() } #log by the lua file log_by_lua_file luaext/log/logger.lua; proxy_pass $http_protocol://$backend; #proxy_redirect $http_protocol://$host:$server_port$svc_url $http_protocol://$host:$server_port$svc_name; } location @websocket { set $stats_new_req "false"; #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; access_by_lua_block { ngx.log(ngx.INFO, ngx.var.request_id..":receive the request") msb.route() msb.access() if ngx.ctx.use_ownupstream then stats.forward_backend() end } header_filter_by_lua_block { stats.receive_response() msb.header_filter() stats.return_response() } #log by the lua file log_by_lua_file luaext/log/logger.lua; proxy_pass $http_protocol://$backend; } location / { set $svc_type "custom"; set $svc_name ""; set $svc_url ""; set $backend "defaultbackend"; access_by_lua_block { ngx.log(ngx.INFO, ngx.var.request_id..":receive the request") stats.accept_new_request() msb.filter_websocket_req() msb.route() msb.access() if ngx.ctx.use_ownupstream then stats.forward_backend() end } header_filter_by_lua_block { stats.receive_response() msb.header_filter() stats.return_response() } #log by the lua file log_by_lua_file luaext/log/logger.lua; proxy_pass $http_protocol://$backend; #proxy_redirect $http_protocol://$host:$server_port$svc_url $http_protocol://$host:$server_port$svc_name; } 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"; access_by_lua_block { ngx.log(ngx.INFO, ngx.var.request_id..":receive the request") stats.accept_new_request() msb.filter_websocket_req() msb.route() msb.access() if ngx.ctx.use_ownupstream then stats.forward_backend() end } header_filter_by_lua_block { stats.receive_response() msb.header_filter() stats.return_response() } #log by the lua file log_by_lua_file luaext/log/logger.lua; proxy_pass $http_protocol://$backend; } 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"; access_by_lua_block { ngx.log(ngx.INFO, ngx.var.request_id..":receive the request") stats.accept_new_request() msb.filter_websocket_req() msb.route() msb.access() if ngx.ctx.use_ownupstream then stats.forward_backend() end } header_filter_by_lua_block { stats.receive_response() msb.header_filter() stats.return_response() } #log by the lua file log_by_lua_file luaext/log/logger.lua; proxy_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"; access_by_lua_block { ngx.log(ngx.INFO, ngx.var.request_id..":receive the request") stats.accept_new_request() msb.filter_websocket_req() msb.route() msb.access() if ngx.ctx.use_ownupstream then stats.forward_backend() end } header_filter_by_lua_block { stats.receive_response() msb.header_filter() stats.return_response() } #log by the lua file log_by_lua_file luaext/log/logger.lua; proxy_pass $http_protocol://$backend; } 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"; access_by_lua_block { ngx.log(ngx.INFO, ngx.var.request_id..":receive the request") stats.accept_new_request() msb.filter_websocket_req() msb.route() msb.access() if ngx.ctx.use_ownupstream then stats.forward_backend() end } header_filter_by_lua_block { stats.receive_response() msb.header_filter() stats.return_response() } #log by the lua file log_by_lua_file luaext/log/logger.lua; proxy_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; }