-
Notifications
You must be signed in to change notification settings - Fork 7
/
nginx-image-filter.conf
94 lines (68 loc) · 1.92 KB
/
nginx-image-filter.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
server {
listen 80 default_server;
root /var/www/html;
index index.html index.htm index.nginx-debian.html;
server_name _;
location ~ ^/img/(?<width>100|200|300|400|-)x(?<height>100|200|300|-)/(?<file>.+)$ {
proxy_pass http://localhost:8090;
proxy_cache thumbs;
proxy_cache_lock on;
proxy_cache_valid 200 24h;
proxy_cache_valid 404 415 1m;
}
location / {
try_files $uri $uri/ =404;
}
}
server {
listen 8090 default_server;
root /var/www/html;
server_name _;
location ~ ^/img/(?<width>\d+)x(?<height>\d+|-)/(?<file>.+)$ {
image_filter resize $width $height;
image_filter_jpeg_quality 85;
image_filter_webp_quality 85;
alias /var/www/html/img/$file;
error_page 415 = /empty;
}
location / {
try_files $uri $uri/ =404;
}
location = /empty {
empty_gif;
}
}
server {
listen 80 default_server;
root /var/www/html;
index index.html index.htm index.nginx-debian.html;
server_name _;
proxy_cache_path /var/nginx/cache levels=1:2 keys_zone=thumbs:10m inactive=24h max_size=1G;
location ~ ^/img/(?<width>\d+)x(?<height>\d+|-)/(?<file>.+)$ {
proxy_pass http://localhost:8090;
proxy_cache thumbs;
proxy_cache_lock on;
proxy_cache_valid 200 24h;
proxy_cache_valid 404 415 1m;
}
location / {
try_files $uri $uri/ =404;
}
}
server {
listen 8090 default_server;
root /var/www/html;
server_name _;
location ~ ^/img/(?<width>\d+)x(?<height>\d+|-)/(?<file>.+)$ {
image_filter resize $width $height;
image_filter_jpeg_quality 85;
alias /var/www/html/img/$file;
error_page 415 = /empty;
}
location / {
try_files $uri $uri/ =404;
}
location = /empty {
empty_gif;
}
}