/
nginx.conf
228 lines (166 loc) · 5.32 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
#user www-data;
worker_processes 8;
pid /run/nginx.pid;
events {
worker_connections 1024;
}
http {
##
# Basic Settings
##
merge_slashes off;
sendfile off;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
# server_tokens off;
# server_names_hash_bucket_size 64;
# server_name_in_redirect off;
include mime.types;
default_type application/octet-stream;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
uwsgi_cache_path /rangecache levels=1:2 keys_zone=DEF:30m max_size=10G;
proxy_cache_path /webcache levels=1:2 keys_zone=WEB:10m max_size=20G;
proxy_cache_path /warccache levels=1:2 keys_zone=WARC:60m max_size=20G;
uwsgi_buffer_size 64k;
uwsgi_buffers 16 64k;
uwsgi_busy_buffers_size 64k;
uwsgi_request_buffering off;
uwsgi_buffering off;
client_max_body_size 0;
upstream webrec_app {
server app:8081;
}
upstream shepherd_app {
server shepherd:9020;
}
# Content Server
server {
listen 81;
location ~ ^/api/v1/behavior {
rewrite /api/v1/behavior/(.*) /$1 break;
proxy_pass http://behaviors:3030;
}
# no access to api via content host!
location ~ ^/(api|([^/]+/[^/]+/\$download$)|_upload|_client_ws) {
return 403;
}
set $upstreamp webrec_app;
include webrec.conf;
}
# API Server
server {
listen 80;
client_max_body_size 0;
gzip on;
gzip_vary on;
gzip_comp_level 5;
gzip_min_length 1024;
gzip_proxied any;
gzip_types text/plain text/css text/xml text/javascript application/javascript application/x-javascript application/json application/xml image/svg+xml;
location / {
proxy_pass http://frontend:8095;
}
location ~ ^/api/v1/behavior {
rewrite /api/v1/behavior/(.*) /$1 break;
proxy_pass http://behaviors:3030;
}
location ~ ^/api/browsers/browsers/[^/]+/icon {
rewrite /api/browsers/browsers(.*) /api/images/browser$1 break;
add_header Cache-Control "public, max-age=86400";
proxy_pass http://shepherd:9020;
}
location ~ ^/api/browsers/browsers {
rewrite /api/browsers/browsers /api/images/browser break;
proxy_pass http://shepherd:9020;
}
location ~ ^/api/browsers/api/ {
rewrite /api/browsers/(.*) /$1 break;
proxy_pass http://shepherd:9020;
}
location ~* ^/(api|_new|_client_ws|_set_session|\$record/|record/) {
include uwsgi_params;
uwsgi_pass webrec_app;
uwsgi_param UWSGI_SCHEME $thescheme;
}
location ~* ^/(_upload.*|.*/\$download)$ {
include uwsgi_params;
uwsgi_pass webrec_app;
uwsgi_read_timeout 3000s;
}
location /static/ {
expires 7d;
alias /frontend/static/dist/;
}
location /static/app/ {
alias /code/webrecorder/static/;
}
location /static/browsers {
include uwsgi_params;
rewrite /static/browsers/(.*) /static/$1 break;
#uwsgi_pass shepherd_app;
proxy_pass http://shepherd:9020;
}
error_page 502 /502.html;
location = /502.html {
root /usr/share/nginx/html;
}
}
# Local WARC Serve
server {
listen 6090;
location /data/warcs/ {
alias /data/warcs/;
}
location /data/storage/ {
alias /data/storage/;
}
}
# reverse proxy for warcserver responses
server {
listen 1211;
proxy_cache WARC;
location / {
proxy_cache_methods POST;
proxy_cache_key "$request_uri|$request_body";
proxy_cache_valid 200;
proxy_pass http://warcserver:8080;
proxy_buffer_size 128k;
proxy_buffers 100 128k;
client_max_body_size 1G;
}
}
resolver 8.8.8.8;
upstream ia {
server 172.18.0.1:2006;
#server web.archive.org:80 max_conns=10 backup;
}
# forward proxy for memento requests
server {
listen 1210;
proxy_cache WEB;
proxy_pass_request_headers on;
proxy_set_header Via Webrecorder;
proxy_cache_key $http_accept_datetime$scheme$proxy_host$uri$is_args$args;
proxy_buffer_size 128k;
proxy_buffers 100 128k;
proxy_cache_valid 200 302 301 304 307;
proxy_cache_valid 404 5m;
proxy_cache_valid any 1m;
proxy_force_ranges on;
proxy_ignore_headers Set-Cookie Vary X-Accel-Expires X-Accel-Buffering;
add_header X-Proxy-Cache $upstream_cache_status;
# to correctly handled encoded urls, use the unencoded $request_uri instead of default $url
rewrite ^ $request_uri;
location ~* ^/https?://web[.]archive[.]org/(.*) {
proxy_set_header Host web.archive.org;
proxy_pass http://ia/$1$is_args$args;
}
location ~* ^/(https?://)([^/]+)(/(.*)) {
proxy_set_header Host $2;
proxy_pass $1$2$3$is_args$args;
}
}
}