msb protocol synch change
[msb/apigateway.git] / msb-core / eag-openresty-ext / src / assembly / resources / openresty / nginx / sites-enabled / openomsb.conf
1 #
2 # Copyright 2016 2015-2016 ZTE, Inc. and others. All rights reserved.
3 #
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
7 #
8 #     http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15 #
16 #     Author: Zhaoxing Meng
17 #     email: meng.zhaoxing1@zte.com.cn
18 #
19
20 server {
21    listen 8181;
22    default_type text/html;
23    add_header X-Cache-Status $upstream_cache_status;
24    
25         location = / {
26       rewrite ^ /openoui/common/login.html redirect;
27    }
28    
29    location = /openoui/microservices {
30       rewrite /openoui/microservices /openoui/microservices/index.html redirect;
31    }
32   
33    location / {
34           set $server "fallback";
35                   set $url "";
36                   set $key "";
37                   
38                   # Lua files
39           rewrite_by_lua_file luaext/customrouter.lua;
40                   access_by_lua_file luaext/execute_auth.lua;
41                   
42                   proxy_pass http://$server;
43    }
44     location ~ ^/api/(.*) {
45                 rewrite ^/api/(.*) /openoapi/$1 last;
46     }
47     location ~ ^/iui/(.*) {
48                 rewrite ^/iui/(.*) /openoui/$1 last;
49         }
50         
51         location ^~ /openoapi/driver_ {
52                   set $backend "";
53                   # Lua files
54           access_by_lua_block {
55                         local driver_manager   =  require('plugins.driver_manager')
56                         driver_manager.access()
57                  }
58                  proxy_pass http://$backend;
59     }
60    location ~ ^/openoapi/([^/]+)(/[Vv][^/]*)?(.*) {
61                 
62                 #Send requests to Driver Mgr. if 'X_Driver_Parameter' header found in the request
63                 if ($http_X_Driver_Parameter) {
64                         rewrite_by_lua_block {
65                         local driver_manager   =  require('plugins.driver_manager')
66                         driver_manager.access()
67                         }
68                 }
69                 
70           set $apiname $1;
71                   set $apiversion $2;
72           set $apiserver "fallback";
73                   set $apiurl "";
74
75           # Lua files
76            rewrite_by_lua_file luaext/openoapirouter.lua;
77            access_by_lua_file luaext/execute_auth.lua;
78                   
79            proxy_pass http://$apiserver;
80    }
81
82    location ~ ^/openoui/([^/]+)(.*) {
83           location ~* ^/iui/([^/]+)(.*)\.(?:png|jpg|jpeg|js|css|html|gif|ico|bmp|woff)$ {
84                   set $iuiname $1;
85                           set $iuiparam $2;
86                   set $iuiserver "fallback";
87                           set $iuiurl "";
88                   
89                           # Lua files
90                                   rewrite_by_lua_file luaext/openouirouter.lua;
91                                   access_by_lua_file luaext/execute_auth.lua;
92
93                                   proxy_cache nginx_cache;
94                                   proxy_cache_key $host$uri$is_args$args;
95                                   proxy_cache_valid 200 304 12h ;
96                                   proxy_cache_valid 301 302 1m ;
97                                   proxy_cache_valid any 1m ;
98                                   expires 12h;
99                                   
100                                   proxy_pass http://$iuiserver;           
101                   }  
102                   set $iuiname $1;
103                   set $iuiparam $2;
104           set $iuiserver "fallback";
105                   set $iuiurl "";
106
107           # Lua files
108           rewrite_by_lua_file luaext/openouirouter.lua;
109                   access_by_lua_file luaext/execute_auth.lua;
110                   
111                   proxy_pass http://$iuiserver;
112    }
113
114    location ~ ^/admin/([^/]+)(/[Vv][^/]*)?(.*) {
115           set $apiname $1;
116               set $apiversion $2;
117           set $apiserver "fallback";
118                   set $adminurl "";
119                   
120                   # Lua files
121           rewrite_by_lua_file luaext/openoadminrouter.lua;
122                   access_by_lua_file luaext/execute_auth.lua;
123                   
124                   proxy_pass http://$apiserver;
125    }
126    
127    location ~ ^/apijson/([^/]+)(/[Vv][^/]*)?(.*) {
128           location ~* ^/apijson/([^/]+)(/[v][^/]*)?(.*)\.(?:png|jpg|jpeg|js|css|html|gif|ico|bmp|woff)$ {
129                   set $apiname $1;
130                           set $apiversion $2;
131                   set $apiserver "fallback";
132                           set $apijsonurl "";             
133                                   
134                           # Lua files
135                                   rewrite_by_lua_file luaext/openoapijsonrouter.lua;
136                                   access_by_lua_file luaext/execute_auth.lua;
137
138                                   proxy_cache nginx_cache;
139                                   proxy_cache_key $host$uri$is_args$args;
140                                   proxy_cache_valid 200 304 12h ;
141                                   proxy_cache_valid 301 302 1m ;
142                                   proxy_cache_valid any 1m ;
143                                   expires 12h;
144                                   
145                                   proxy_pass http://$apiserver;           
146                   }   
147           set $apiname $1;
148               set $apiversion $2;
149           set $apiserver "fallback";
150                   set $apijsonurl "";
151                   
152                   # Lua files
153           rewrite_by_lua_file luaext/openoapijsonrouter.lua;
154                   access_by_lua_file luaext/execute_auth.lua;
155                   
156                   proxy_pass http://$apiserver;
157    }
158
159    location ~* \.(?:png|jpg|jpeg|js|css|html|gif|ico|bmp|woff)$ {
160            set $server "fallback";
161                    set $url "";
162            set $key "";
163                   
164                    # Lua files
165                    rewrite_by_lua_file luaext/customrouter.lua;
166                    access_by_lua_file luaext/execute_auth.lua;
167
168                    proxy_cache nginx_cache;
169                    proxy_cache_key $host$uri$is_args$args;
170                    proxy_cache_valid 200 304 12h ;
171                    proxy_cache_valid 301 302 1m ;
172                    proxy_cache_valid any 1m ;
173                    expires 12h;
174                                   
175                    proxy_pass http://$server;             
176    }
177          
178    location = /favicon.ico {
179         log_not_found off;
180    }
181 }