-
Notifications
You must be signed in to change notification settings - Fork 2
/
default.conf
69 lines (57 loc) · 1.33 KB
/
default.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
proxy_cache_path /var/cache/nginx/cache levels=1:2 keys_zone=resized:64m max_size=20000m inactive=1d;
server {
listen ${PORT};
access_log /var/log/nginx/proxy.log;
location / {
proxy_pass "http://127.0.0.1:9001";
proxy_cache resized;
proxy_cache_valid 200 302 24h;
proxy_cache_valid 404 1m;
# expire time for browser
expires 1d;
}
}
limit_req_zone "1" zone=2persec:32k rate=2r/s;
server {
listen 9001;
allow 127.0.0.1;
deny all;
limit_req zone=2persec burst=10;
access_log /var/log/nginx/resizer.log;
server_name ${NGINX_HOST};
resolver 8.8.8.8 8.8.4.4;
location ~ /(.*)/original {
internal;
proxy_pass ${IMAGE_HOST}/$path;
}
location ~ /(.*)/resize {
internal;
proxy_pass ${IMAGE_HOST}/$path;
image_filter resize $width $height;
image_filter_jpeg_quality $quality;
image_filter_buffer 100M;
error_page 415 = @empty;
}
location @empty {
empty_gif;
}
location ~ /(.*)$ {
set $path $1;
if ($args = "") {
rewrite ^ /(.*)/original last;
}
set $width "-";
set $height "-";
set $quality 100;
if ($arg_w ~ ([0-9]+)) {
set $width $1;
}
if ($arg_h ~ ([0-9]+)) {
set $height $1;
}
if ($arg_q ~ (100|[1-9][0-9]|[1-9])) {
set $quality $1;
}
rewrite ^ /(.*)/resize last;
}
}