-
Notifications
You must be signed in to change notification settings - Fork 0
/
nginx.conf
52 lines (41 loc) · 1.54 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
user www-data;
worker_processes auto;
pid /run/nginx.pid;
events {
worker_connections 768;
# multi_accept on;
}
http {
gzip off;
# need to setup external DNS resolver
resolver 8.8.8.8;
resolver_timeout 5s;
# configure cache directory with 750G and holding old objects for max 30 days
proxy_cache_path /var/cache/nginx levels=1:2 keys_zone=default:75m max_size=100m inactive=30d;
server {
listen public_ip:8080 default_server;
keepalive_timeout 3600;
location / {
proxy_http_version 1.1;
# Make sure we're proxying along the correct headers
proxy_set_header Host [bucket_name].s3.eu-west-2.amazonaws.com;
# Make sure we're using Keep-Alives with S3
proxy_set_header Connection '';
# Configure out caches
proxy_cache default;
# Cache all 200 OK's for 30 days
proxy_cache_valid 200 30d;
# Use stale cache file in all errors from upstream if we can
proxy_cache_use_stale error timeout invalid_header updating http_500 http_502 http_503 http_504;
# Lock the cache so that only one request can populate it at a time
proxy_cache_lock on;
# Set back a nice HTTP Header to indicate what the cache status was
add_header X-Cache-Status $upstream_cache_status always;
# Set this to a variable instead of using an `upstream`
# to coerce nginx into resolving as DNS instead of caching
# it once on process boot and never updating.
set $s3_host '[bucket_name].s3.eu-west-2.amazonaws.com';
proxy_pass https://$s3_host;
}
}
}