-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathnginx.conf
54 lines (44 loc) · 1.28 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
#
# Taken and modified From https://github.com/igrigorik/webp-detect
#
http {
include mime.types;
default_type application/octet-stream;
#
# < regular Nginx configuration here >
#
# For a hands-on explanation of using Accept negotiation, see:
# http://www.igvita.com/2013/05/01/deploying-webp-via-accept-content-negotiation/
# For an explanation of how to use maps for that, see:
# http://www.lazutkin.com/blog/2014/02/23/serve-files-with-nginx-conditionally/
map $http_accept $img_suffix {
"~*webp" ".webp";
"~*jxr" ".jxr";
}
map $msie $cache_control {
"1" "private";
}
map $msie $vary_header {
default "Accept";
"1" "";
}
server {
listen 8081;
server_name localhost;
location ~* \.(?:png|jpe?g|gif|webp|jxr)$ {
# set response headers specially treating MSIE
add_header Vary $vary_header;
add_header Cache-Control $cache_control;
# now serve our images
try_files $uri$img_suffix $uri =404;
}
#other options are:
#location / {
# # set response headers specially treating MSIE
# add_header Vary $vary_header;
# add_header Cache-Control $cache_control;
# # now serve our images
# try_files $uri$img_suffix $uri =404;
#}
}
}