-
Notifications
You must be signed in to change notification settings - Fork 0
/
nginx.conf.template
67 lines (53 loc) · 2.06 KB
/
nginx.conf.template
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
events { }
http {
include mime.types;
default_type application/octet-stream;
gzip on;
gzip_vary on;
gzip_proxied any;
gzip_comp_level 1;
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
gzip_buffers 16 8k;
gzip_min_length 5k;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
sendfile on;
keepalive_timeout 65;
limit_req_zone $binary_remote_addr zone=mylimit:10m rate=10r/s;
upstream backend {
server server:8000;
# server server:8000 max_fails=3 fail_timeout=10s;
# server server-bk:8000 backup;
}
server {
listen 80;
#server_name ormonitor.darwinia.network;
location / {
root /usr/share/nginx/html;
index index.html;
try_files $uri $uri/ /index.html;
}
location /static/ {
expires 5d;
add_header Cache-Control "public, no-transform";
alias /usr/share/nginx/html/static/;
}
location /api {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
limit_req zone=mylimit burst=20 nodelay;
proxy_pass http://backend/api;
add_header 'Access-Control-Allow-Origin' 'ormonitor.darwinia.network';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range';
add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range';
if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Max-Age' 1728000;
add_header 'Content-Type' 'text/plain; charset=utf-8';
add_header 'Content-Length' 0;
return 204;
}
}
}
}