api.ufo.conf
2.48 KB
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
server {
listen 80;
## for proxy
proxy_http_version 1.1;
proxy_set_header Connection "";
server_name 2.yohobuy.com ufoapi.yohoops.org;
access_log /Data/logs/nginx/ufo_access.log fenxi;
error_log /Data/logs/nginx/ufo_error.log;
set $real_ip "";
set $request_api_method "-";
set $request_udid "-";
set $request_uid "-";
set_by_lua_file $real_ip conf/setup.lua;
log_by_lua_file conf/lua/set_log_params.lua;
# set_by_lua_file $real_ip conf/setup.lua;
# access_by_lua_file 'conf/lua/limit_api_flow.lua';
#################### reject http HEAD & status check / .ico quest #########
# HEAD REQUEST RETURN 405
if ( $request_method = HEAD ) {
return 200;
}
# redirect to https
set $rewite 0;
if ($http_x_client_proto = 'http') {
set $rewite 1;
}
if ($http_x_forwarded_proto = 'http') {
set $rewite 1;
}
if ($request_method ~* POST) {
set $rewite 0;
}
# nginx status check
location = /status_check {
default_type text/html;
return 200 'server is ok!';
}
# cdn check
location = /test.html {
return 200;
}
location = /favicon.ico {
log_not_found off;
access_log off;
}
#################### begin match 2.yohobuy.com #########################
# location / {
# rewrite_by_lua_file conf/redirect.lua;
# }
#################### end match 2.yohobuy.com #########################
location / {
limit_req zone=limit_ufo burst=50;
proxy_redirect off;
proxy_pass http://ufogateway/ufo-gateway/;
proxy_set_header X-Real-IP $real_ip;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Accept-Encoding "gzip";
proxy_http_version 1.1;
proxy_set_header Connection "";
proxy_set_header Host $host;
}
# forward to node app
location ^~ /mapp/ {
#redirect to 301 if get
if ($rewite = 1) {
return 301 https://$host$request_uri ;
}
proxy_redirect off;
proxy_pass http://ufomapp/mapp/;
proxy_set_header Host "2.yohobuy.com";
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Accept-Encoding "gzip";
}
location ~* .(txt)$ {
root /Data/local/openresty-1.9.15.1/nginx/html;
}
}