forked from harvard-lil/wacz-exhibitor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnginx.conf
101 lines (87 loc) · 3.36 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
#
# Default NGINX configuration file for wacz-exhibitor.
#
# Inspiration:
# - https://www.nginx.com/blog/smart-efficient-byte-range-caching-nginx/
# - https://kevincox.ca/2021/06/04/http-range-caching/
# - https://github.com/KyleAMathews/docker-nginx/blob/master/nginx.conf
#
proxy_cache_path /var/cache/nginx keys_zone=rangecache:10m inactive=60m;
server {
listen 8080;
listen [::]:8080;
root /usr/share/nginx/html/;
# Range request caching setup (slice-by-slice approach)
slice 1m;
proxy_cache_key $host$uri$is_args$args$slice_range;
proxy_set_header Range $slice_range;
proxy_http_version 1.1;
proxy_cache_valid 200 206 1h;
proxy_cache rangecache;
# Gzip compression setup
gzip on;
gzip_http_version 1.0; # Minimum HTTP version for gzip compression
gzip_comp_level 5;
gzip_min_length 256;
gzip_proxied any;
gzip_vary on;
gzip_types
application/javascript
application/json
text/css
text/plain;
# text/html is always compressed by HttpGzipModule
# Serves contents of "/embed" as "/"
location / {
root /usr/share/nginx/html/embed;
# Intended CSP Policy:
# "Everything's allowed within the <iframe>, as long as it's same-origin."
add_header Content-Security-Policy "default-src 'self' data: 'unsafe-inline' 'unsafe-hashes' 'unsafe-eval';";
}
# Exception to the above rule: "/replay-web-page" folder.
location /replay-web-page/ {
try_files $uri $uri/ =404;
}
#
# Access to "warc", "warc.gz", "wacz" files:
# - Serve local file from "/archives/" if available.
# - Otherwise, try to proxy it from a remote server.
#
location ~ \.warc {
types { } default_type "application/warc";
try_files /archives/$uri /archives/$uri/ @remote_warc_archive;
# try_files /archives/$uri /archives/$uri/ =404;
# EDIT: Comment out the first line and comment in the second line if you do not wish to proxy a remote server.
}
location ~ \.warc.gz {
gzip_static on;
types { } default_type "application/x-gzip";
try_files /archives/$uri /archives/$uri/ @remote_warc_gz_archive;
# try_files /archives/$uri /archives/$uri/ =404;
# EDIT: Comment out the first line and comment in the second line if you do not wish to proxy a remote server.
}
location ~ \.wacz {
types { } default_type "application/wacz";
try_files /archives/$uri /archives/$uri/ @remote_wacz_archive;
# try_files /archives/$uri /archives/$uri/ =404;
# EDIT: Comment out the first line and comment in the second line if you do not wish to proxy a remote server.
}
# EDIT: Delete this block if you do not wish to proxy a remote server.
location @remote_warc_archive {
proxy_pass https://example.com; # NOTE: Replace with address of remote server.
proxy_hide_header Content-Type;
add_header Content-Type "application/warc";
}
# EDIT: Delete this block if you do not wish to proxy a remote server.
location @remote_warc_gz_archive {
proxy_pass https://example.com; # NOTE: Replace with address of remote server.
proxy_hide_header Content-Type;
add_header Content-Type "application/x-gzip";
}
# EDIT: Delete this block if you do not wish to proxy a remote server.
location @remote_wacz_archive {
proxy_pass https://example.com; # NOTE: Replace with address of remote server.
proxy_hide_header Content-Type;
add_header Content-Type "application/wacz";
}
}