blob: b5891f8e20bf5a733140c6881a14044763330f7b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
#
# Copyright (C) 2018 ZTE, Inc. and others. All rights reserved. (ZTE)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
server {
listen 8000;
default_type text/html;
set $http_protocol "http";
location / {
set $svc_type "";
set $svc_name "";
set $svc_version1 "";
set $svc_version2 "";
set $req_res "";
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()
-- 80 is the publish port in the msb, COS is the system_tag. These two parameters are required
msb.external_route("80","COS")
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 @websocket {
#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.external_route("80","COS")
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 @commonnotfound {
return 502;
}
location = /favicon.ico {
log_not_found off;
}
}
|