Skip to content

Commit 37fce5f

Browse files
committed
proxy cache configuration from prod
1 parent e28b213 commit 37fce5f

File tree

3 files changed

+39
-18
lines changed

3 files changed

+39
-18
lines changed

docker/include/proxy_cache.conf

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
proxy_cache mycache;
2+
3+
proxy_cache_valid 200 302 15m;
4+
proxy_cache_valid 404 1m;
5+
6+
# GET and HEAD are cached by default
7+
proxy_cache_methods GET HEAD;
8+
9+
# Do not convert HEAD into GET
10+
proxy_cache_convert_head off;
11+
12+
# Since head conversion is disabled, the request_method is included in the proxy_cache_key
13+
proxy_cache_key "$scheme$proxy_host$request_method$request_uri$is_args$args";
14+
15+
# Lock the cache so that only one request can populate it at a time
16+
proxy_cache_lock on;
17+
proxy_cache_revalidate on;
18+
19+
# Set back a nice HTTP Header to indicate what the cache status was
20+
add_header X-Proxy-Cache $upstream_cache_status;
21+

docker/include/proxy_pass.conf

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
11
proxy_pass http://x2s3;
22
proxy_redirect off;
3-
43
proxy_http_version 1.1;
54
proxy_set_header "Connection" "";
65

7-
proxy_cache mycache;
8-
add_header X-Proxy-Cache $upstream_cache_status;
9-
106
proxy_set_header Host $http_host;
117
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
128
proxy_set_header X-Forwarded-Proto $scheme;

docker/nginx.conf

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,39 +9,43 @@ events {
99
}
1010

1111
http {
12-
#
13-
# Uncomment the lines below to enable response caching
14-
#
15-
#proxy_cache_path /var/cache/nginx keys_zone=mycache:10m max_size=50g levels=1:2 inactive=1h;
16-
#proxy_cache_valid 200 302 15m;
17-
#proxy_cache_valid 404 1m;
18-
#map $http_cache_control $cache_bypass {
19-
# no-cache 1;
20-
#}
21-
#proxy_cache_bypass $cache_bypass;
12+
proxy_cache_path /var/cache/nginx keys_zone=mycache:512m max_size=100g levels=1:2 inactive=1h
13+
loader_sleep=10ms manager_files=4000 manager_threshold=200m manager_sleep=100ms;
14+
map $http_cache_control $cache_bypass {
15+
no-cache 1;
16+
}
17+
proxy_cache_bypass $cache_bypass;
18+
# Don’t create a temp file if body > 100 MB
19+
proxy_max_temp_file_size 100m;
2220

2321
# Only return Nginx in server header
2422
server_tokens off;
2523

2624
server {
27-
server_name _;
25+
server_name s3.janelia.org;
2826
listen 443 ssl default_server;
2927
listen [::]:443 ssl;
3028
http2 on;
3129

3230
# SSL config
33-
ssl_certificate /certs/cert.crt;
34-
ssl_certificate_key /certs/cert.key;
31+
ssl_certificate /certs/wildcard.janelia.org/cert.crt;
32+
ssl_certificate_key /certs/wildcard.janelia.org/cert.key;
3533
include /etc/nginx/conf/ssl.conf;
3634

35+
location = / {
36+
include /etc/nginx/conf/proxy_cache.conf;
37+
include /etc/nginx/conf/proxy_pass.conf;
38+
}
39+
3740
location / {
41+
include /etc/nginx/conf/proxy_cache.conf;
3842
include /etc/nginx/conf/proxy_pass.conf;
3943
}
4044
}
4145

4246
upstream x2s3 {
4347
zone upstreams 64K;
4448
server x2s3:8000;
45-
keepalive 2;
49+
keepalive 3;
4650
}
4751
}

0 commit comments

Comments
 (0)