-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathnginx.conf
122 lines (101 loc) · 2.96 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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
include snippets/upstream.conf;
proxy_cache_path /tmp levels=1 keys_zone=resized:1m max_size=256m;
limit_req_zone "1" zone=imageserver:10m rate=100r/s;
#
# Default server
#
server {
listen 80 default_server;
server_name _;
root /app/www;
include snippets/favicon.conf;
include snippets/redirect.conf;
include snippets/deny.conf;
include snippets/php.conf;
include snippets/root.conf;
# Rewrite
rewrite ^/(?:\d+)/((?:(?:resize|crop)-(?:\d+)(?:x\d+)?/)?(?:asset|gui|ext)/(?:.+)\.(?:[a-z0-9]+))$ /$1 last;
# Responsive image proxy
location ~ ^/(?:resize|crop)-(?:\d+)(?:x\d+)?/(?:asset|gui|ext)/(?:.+)\.(?:gif|jpg|png|webp)$ {
proxy_pass http://127.0.0.1:9001;
proxy_cache resized;
proxy_cache_use_stale error timeout invalid_header updating;
proxy_cache_valid 180m;
}
# Asset
location ~ ^/asset/((?:.+)\.(?:[a-z0-9]+))$ {
alias /data/$1;
}
# GUI
location /gui/ {
root /app;
}
# Extension GUI
location /ext/ {
alias /opt/gui/;
}
include /opt/*.conf;
}
#
# Responsive image server
#
server {
listen 9001;
allow 127.0.0.1;
deny all;
limit_req zone=imageserver burst=100 nodelay;
image_filter_buffer 10M;
image_filter_jpeg_quality 95;
image_filter_webp_quality 95;
# Asset
location ~ ^/resize-(\d+)/asset/((?:.+)\.(?:gif|jpg|png|webp))$ {
alias /data/$2;
image_filter resize $1 -;
}
location ~ ^/resize-(\d+)x(\d+)/asset/((?:.+)\.(?:gif|jpg|png|webp))$ {
alias /data/$3;
image_filter resize $1 $2;
}
location ~ ^/crop-(\d+)/asset/((?:.+)\.(?:gif|jpg|png|webp))$ {
alias /data/$2;
image_filter crop $1 -;
}
location ~ ^/crop-(\d+)x(\d+)/asset/((?:.+)\.(?:gif|jpg|png|webp))$ {
alias /data/$3;
image_filter crop $1 $2;
}
# GUI
location ~ ^/resize-(\d+)/gui/((?:.+)\.(?:gif|jpg|png|webp))$ {
alias /app/gui/$2;
image_filter resize $1 -;
}
location ~ ^/resize-(\d+)x(\d+)/gui/((?:.+)\.(?:gif|jpg|png|webp))$ {
alias /app/gui/$3;
image_filter resize $1 $2;
}
location ~ ^/crop-(\d+)/gui/((?:.+)\.(?:gif|jpg|png|webp))$ {
alias /app/gui/$2;
image_filter crop $1 -;
}
location ~ ^/crop-(\d+)x(\d+)/gui/((?:.+)\.(?:gif|jpg|png|webp))$ {
alias /app/gui/$3;
image_filter crop $1 $2;
}
# Extension GUI
location ~ ^/resize-(\d+)/ext/((?:.+)\.(?:gif|jpg|png|webp))$ {
alias /opt/gui/$2;
image_filter resize $1 -;
}
location ~ ^/resize-(\d+)x(\d+)/ext/((?:.+)\.(?:gif|jpg|png|webp))$ {
alias /opt/gui/$3;
image_filter resize $1 $2;
}
location ~ ^/crop-(\d+)/ext/((?:.+)\.(?:gif|jpg|png|webp))$ {
alias /opt/gui/$2;
image_filter crop $1 -;
}
location ~ ^/crop-(\d+)x(\d+)/ext/((?:.+)\.(?:gif|jpg|png|webp))$ {
alias /opt/gui/$3;
image_filter crop $1 $2;
}
}