-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathnginx.conf
executable file
·212 lines (174 loc) · 7.91 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
map $arg_matchType $dq_limit {
"domain" $uri;
default "";
}
limit_req_zone $dq_limit zone=by_dq_uri:10m rate=30r/m;
limit_req_zone $binary_remote_addr zone=by_ip:1m rate=10r/m;
limit_req_zone $http_x_forwarded_for zone=by_remote_ip:10m rate=6r/m;
limit_req_status 429;
server {
listen 80;
proxy_read_timeout 600;
# NGINX merging // to / routinely causes problems for us, so lets switch it off:
merge_slashes off;
# rewrites to be processed before locations -----------------------------------
rewrite /act/userguide https://github.com/ukwa/w3act/wiki/W3ACT-User-Guide;
# Digital monuments and memory http://xclacksoverhead.org/
add_header X-Clacks-Overhead "GNU Terry Pratchett";
# Add header for tracing where issues occur:
add_header Via $hostname always;
# Use server-relative redirects so we don't have to keep fixing-up the http/https scheme/proto:
absolute_redirect off;
# Do not buffer responses so streaming can function:
proxy_buffering off;
proxy_http_version 1.1;
# proxies -----------------------------------------------------------
location /wayback/ {
rewrite ^/wayback/(.*) /$1 break;
limit_req zone=by_dq_uri burst=20 delay=10;
include uwsgi_params;
uwsgi_param UWSGI_SCHEME $http_x_forwarded_proto;
#uwsgi_param HOST $host;
uwsgi_param SCRIPT_NAME /wayback;
uwsgi_pass pywb:8081;
uwsgi_force_ranges on;
uwsgi_buffers 16 256k;
uwsgi_buffer_size 256k;
uwsgi_busy_buffers_size 512k;
uwsgi_request_buffering off;
uwsgi_buffering off;
}
location /mementos {
proxy_pass http://mementos:9000;
}
location /mementos/search {
limit_req zone=by_remote_ip burst=10;
# A hack to stop it re-writing double-slashes in the URI!
if ($request_uri ~* "/mementos/search/(.*)$") {
proxy_pass http://mementos:9000/mementos/search/$1;
}
proxy_pass http://mementos:9000;
}
location /shine {
proxy_pass http://shine:9000;
}
#location /interject {
# proxy_pass http://interject:9000/interject;
#}
location /api {
# Map the old API URLs:
rewrite ^/api$ /api/docs permanent;
rewrite ^/api/query/lookup$ /api/mementos/cdx permanent;
rewrite ^/api/query/resolve/(.+)$ /api/mementos/resolve/$1 permanent;
rewrite ^/api/query/warc/(.+)$ /api/mementos/warc/$1 permanent;
rewrite ^/api/iiif/helper/(.+)$ /api/mementos/screenshot/$1 permanent;
rewrite ^/api/stats/crawl/recent-activity$ /api/crawls/fc/recent-activity permanent;
# X-Forward arameters are set by the edge proxy:
#proxy_set_header X-Forwarded-Path /api/;
proxy_set_header Host $host;
# Don't re-write double-slashes etc:
if ($request_uri ~* "/api/(.*)") {
proxy_pass http://api:8000/$1;
}
proxy_pass http://api:8000;
}
# rewrites -----------------------------------
# collection shortcuts
rewrite ^/avianflu(.*)$ /en/ukwa/collection/2446 permanent;
rewrite ^/col/c8275.html /en/ukwa/collection/2446 permanent;
rewrite ^/ukwa/collection/116179/page/1(.*)$ /en/ukwa/collection/2446 permanent;
rewrite ^/edinburgh?transport(.*)$ /en/ukwa/collection/2379 permanent;
rewrite ^/col/c8075.html /en/ukwa/collection/2379 permanent;
rewrite ^/ElectionUK05(.*)$ /en/ukwa/collection/2453 permanent;
rewrite ^/col/c8100.html /en/ukwa/collection/2453 permanent;
rewrite ^/ukwa/collection/99035/page/1(.*)$ /en/ukwa/collection/2453 permanent;
rewrite ^/G805(.*)$ /en/ukwa/collection/2398 permanent;
rewrite ^/col/c8150.html /en/ukwa/collection/2398 permanent;
rewrite ^/illness(.*)$ /en/ukwa/collection/2443 permanent;
rewrite ^/col/c8200.html /en/ukwa/collection/2443 permanent;
rewrite ^/latinamericauk(.*)$ /en/ukwa/collection/2384 permanent;
rewrite ^/col/c8225.html /en/ukwa/collection/2384 permanent;
rewrite ^/ukwa/collection/119539/page/1(.*)$ /en/ukwa/collection/2384 permanent;
rewrite ^/londonJuly05(.*)$ /en/ukwa/collection/2439 permanent;
rewrite ^/col/c8125.html /en/ukwa/collection/2439 permanent;
rewrite ^/ukwa/collection/100757/page/1(.*)$ /en/ukwa/collection/2439 permanent;
rewrite ^/col/$ /en/ukwa/collection permanent;
rewrite ^/col/countryside(.*)$ /en/ukwa/collection/2429 permanent;
rewrite ^/col/c8301.html /en/ukwa/collection/2429 permanent;
rewrite ^/ukwa/collection/110213/page/1(.*)$ /en/ukwa/collection/2429 permanent;
rewrite ^/col/tsunami(.*)$ /en/ukwa/collection/2435 permanent;
rewrite ^/col/c8050.html /en/ukwa/collection/2435 permanent;
rewrite ^/ukwa/collection/99326/page/1(.*)$ /en/ukwa/collection/2435 permanent;
rewrite ^/quaker(.*)$ /en/ukwa/collection/2436 permanent;
rewrite ^/women(.*)$ /en/ukwa/collection/2447 permanent;
rewrite ^/col/c8175.html /en/ukwa/collection/2447 permanent;
rewrite ^/ukwa/collection/98537/page/1(.*)$ /en/ukwa/collection/2447 permanent;
rewrite ^/ukwa/collection/dummy/page/1(.*)$ /en/ukwa/collection/2450 permanent;
rewrite ^/ukwa/collection/28180520/page/1(.*)$ /en/ukwa/collection/2450 permanent;
rewrite ^/nominate /en/ukwa/info/nominate permanent;
rewrite ^/cy/nominate /cy/ukwa/info/nominate permanent;
# Add redirects for true homepage:
rewrite ^/$ /en/ukwa/ permanent;
rewrite ^/en/$ /en/ukwa/ permanent;
rewrite ^/cy/$ /cy/ukwa/ permanent;
rewrite ^/gd/$ /gd/ukwa/ permanent;
# Add other redirects for the new site/FastAPI:
rewrite ^(/en|/cy|/gd|)/ukwa/collection/$ $1/ukwa/category/ permanent;
# Add redirects for true homepage:
rewrite ^/en/$ /en/ukwa/ permanent;
rewrite ^/cy/$ /cy/ukwa/ permanent;
rewrite ^/gd/$ /gd/ukwa/ permanent;
# Add other redirects for the new site/FastAPI:
rewrite ^(/en|/cy|/gd|)/ukwa/collection/$ $1/ukwa/category/ permanent;
# internal
# rewrite ^/wayback/memento/timegate/(.+)$ /wayback/archive/$1 permanent;
# rewrite ^/waybacktg/ore/(.*)$ /wayback/list/$1 permanent;
# Endpoint for Resolve API service used by Document Harvester:
rewrite ^/access/resolve/(.*)$ /api/query/resolve/$1 permanent;
# external
rewrite ^/blog(.*)$ http://britishlibrary.typepad.co.uk/webarchive permanent;
rewrite ^/smashfest.*$ http://goo.gl/forms/o35mRmzwLl permanent;
rewrite ^/video(.*)$ https://www.youtube.com/channel/UCJukhTSw8VRj-VNTpBcqWkw/videos permanent;
# Hook in the dataset volume:
location /datasets {
root /var/www/html;
disable_symlinks off;
autoindex on;
}
# Setup error pages:
# This seems to be ignored, and are handled by the default action (@ukwaui), but need review anyway, so commenting out for now.
#error_page 404 /en/404.html;
#error_page 500 /en/500.html;
# Patch in static robots.txt etc.
location / {
root /usr/share/nginx/html;
try_files $uri $uri/ @ukwaui;
# 500 image randomiser:
location /img/500 {
random_index on;
add_header Cache-Control "public, max-age=60, s-maxage=60";
}
# 404 image randomiser:
location /img/404 {
random_index on;
add_header Cache-Control "public, max-age=60, s-maxage=60";
}
# This interferes with proxy-pass...
#location /cy/ {
# error_page 404 /cy/404.html;
# error_page 500 /cy/500.html;
#}
#location /gd/ {
# error_page 404 /gd/404.html;
# error_page 500 /gd/500.html;
#}
}
# default action - always last ---------------
location @ukwaui {
proxy_pass http://ukwa-ui:8080;
proxy_set_header Host $host;
proxy_connect_timeout 300s;
proxy_read_timeout 300s;
proxy_send_timeout 300s;
}
}