forked from alcorexchange/alcor-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
nginx.conf
280 lines (227 loc) · 7.96 KB
/
nginx.conf
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
proxy_cache_path /data/nginx/cache/alcor levels=1:2 keys_zone=alcor:1m max_size=1g inactive=60m use_temp_path=off;
#geo $limited {
# default 1;
# # Backend api ssr calls
# 127.0.0.1 0;
#}
#
#map $limited $limit {
# 1 $binary_remote_addr;
# 0 "";
#}
geo $whitelist {
default 1;
1.1.1.1 0;
127.0.0.1 0;
}
map $whitelist $limit {
0 "";
1 $binary_remote_addr;
}
# DDOS MODE
#limit_conn_zone $binary_remote_addr zone=addr:100m;
#limit_req_zone $limit zone=ip:100m rate=10r/s;
limit_conn_zone $binary_remote_addr zone=addr:10m;
limit_req_zone $limit zone=ip:10m rate=50r/s;
# DDOS
#limit_req_zone $limit zone=ip:100m rate=50r/s;
limit_conn_status 429;
limit_req_status 429;
map $sent_http_content_type $expires {
"text/html" epoch;
"text/html; charset=utf-8" epoch;
default off;
}
upstream websocket1 {
server localhost:7011;
}
server {
listen 80;
listen [::]:80 default;
#include snippets/self-signed.conf;
#include snippets/ssl-params.conf;
server_name .alcor.exchange;
limit_conn addr 100;
#client_body_timeout 5s;
#client_header_timeout 5s;
gzip on;
gzip_types text/plain application/xml text/css application/javascript;
gzip_min_length 1000;
location /cmccmccmc {
return 200 'Avral just submited request to CoinMarketCap for DEX review. for [email protected] email';
add_header Content-Type text/plain;
}
location /backups {
alias /var/www/backups;
autoindex on;
}
location /api {
#limit_req zone=ip burst=500 nodelay;
limit_req zone=ip burst=1000;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_read_timeout 1m;
proxy_connect_timeout 1m;
proxy_pass http://127.0.0.1:7001/api;
# PROXY CACHE
proxy_cache alcor;
proxy_cache_methods GET;
proxy_cache_key "$scheme|$host|$request_uri|$request_body";
proxy_cache_valid any 1s;
proxy_cache_use_stale updating;
# kill cache
add_header Last-Modified $date_gmt;
add_header Cache-Control 'no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0';
if_modified_since off;
expires off;
etag off;
# CORS
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
}
location /api/v2 {
#limit_req zone=ip burst=500 nodelay;
limit_req zone=ip burst=1000;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_read_timeout 1m;
proxy_connect_timeout 1m;
proxy_pass http://127.0.0.1:7003/api/v2;
# PROXY CACHE
proxy_cache alcor;
proxy_cache_methods GET;
proxy_cache_key "$scheme|$host|$request_uri|$request_body";
proxy_cache_valid any 1s;
proxy_cache_use_stale updating;
# kill cache
add_header Last-Modified $date_gmt;
add_header Cache-Control 'no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0';
if_modified_since off;
expires off;
etag off;
# CORS
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
}
location ~* \.io {
#limit_req zone=ip burst=5 nodelay;
limit_req zone=ip burst=5;
limit_conn addr 500;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_set_header Host $host;
proxy_pass http://localhost:7031;
}
location / {
limit_req zone=ip burst=2000;
#limit_req zone=ip burst=100 nodelay; ## DDOS
limit_except GET {
deny all;
}
proxy_cache_bypass $http_upgrade;
proxy_cache_key "$host$request_uri";
proxy_cache alcor;
proxy_cache_revalidate on;
proxy_cache_valid 200 2m;
proxy_cache_min_uses 3;
proxy_cache_use_stale error timeout updating http_500 http_502
http_503 http_504;
proxy_cache_background_update on;
proxy_cache_lock on;
expires $expires;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_connect_timeout 1m;
proxy_pass http://localhost:7000;
}
}
server {
listen 80;
server_name dev.alcor.exchange;
#include /etc/nginx/cloudflare-allow.conf;
#deny all;
client_body_timeout 5s;
client_header_timeout 5s;
gzip on;
gzip_types text/plain application/xml text/css application/javascript;
gzip_min_length 1000;
location /api {
#limit_req zone=ip burst=500 nodelay;
limit_req zone=ip burst=500;
limit_conn addr 100;
proxy_redirect off;
proxy_set_header Host wax.alcor.exchange;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_read_timeout 1m;
proxy_connect_timeout 1m;
proxy_pass http://127.0.0.1:7001/api;
# PROXY CACHE
proxy_cache alcor;
proxy_cache_methods GET;
proxy_cache_key "$scheme|$host|$request_uri|$request_body";
proxy_cache_valid any 1s;
proxy_cache_use_stale updating;
# kill cache
add_header Last-Modified $date_gmt;
add_header Cache-Control 'no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0';
if_modified_since off;
expires off;
etag off;
# CORS
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
}
location ~* \.io {
limit_req zone=ip burst=5 nodelay;
limit_conn addr 500;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_set_header Host $host;
proxy_pass http://localhost:7031;
}
location / {
limit_req zone=ip burst=2000 nodelay;
limit_conn addr 100;
limit_except GET {
deny all;
}
proxy_cache_bypass $http_upgrade;
proxy_cache_key "$host$request_uri";
proxy_cache alcor;
proxy_cache_revalidate on;
proxy_cache_valid 200 2m;
proxy_cache_min_uses 3;
proxy_cache_use_stale error timeout updating http_500 http_502
http_503 http_504;
proxy_cache_background_update on;
proxy_cache_lock on;
expires $expires;
proxy_redirect off;
proxy_set_header Host 'wax.alcor.exchange';
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_connect_timeout 1m;
proxy_pass http://localhost:8899;
}
}
server {
listen 80;
server_name resizer.alcor.exchange;
location / {
proxy_pass http://localhost:3030;
}
}