-
Notifications
You must be signed in to change notification settings - Fork 0
/
nginx.conf
73 lines (59 loc) · 1.57 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
load_module modules/ngx_http_image_filter_module.so;
# Inspiration: https://github.com/sergejmueller/sergejmueller.github.io/wiki/Nginx:-Real-time-image-resizing-and-caching
daemon off;
error_log /dev/stdout info;
http {
proxy_cache_path /var/cache/nginx/images levels=1:2 keys_zone=resized:10m max_size=256m inactive=1h use_temp_path=off;
access_log /dev/stdout;
server {
## LISTEN
listen 80 default_server;
listen [::]:80 default_server;
## SERVER
server_name resizer;
## CACHING
location / {
proxy_cache resized;
proxy_cache_min_uses 2;
proxy_cache_lock on;
proxy_cache_valid 200 1d;
proxy_cache_valid any 1m;
proxy_cache_use_stale error timeout updating http_500 http_502 http_503 http_504;
proxy_set_body none;
proxy_redirect off;
proxy_pass http://127.0.0.1:9001;
proxy_pass_request_headers off;
add_header X-Proxy-Cache $upstream_cache_status;
}
}
server {
listen 9001;
root /var/www/html;
location ~ \.(jpg|png|gif)$ {
set $w "-";
set $h "-";
set $q "80";
set $s "100";
if ( $arg_w ) {
set $w $arg_w;
}
if ( $arg_h ) {
set $h $arg_h;
}
if ( $arg_q ) {
set $q $arg_q;
}
if ( $arg_s ) {
set $s $arg_s;
}
image_filter resize $w $h;
image_filter_jpeg_quality $q;
image_filter_buffer 10M;
image_filter_interlace on;
image_filter_sharpen $s;
}
}
}
events {
worker_connections 1024;
}