44 lines
1.1 KiB
Plaintext
44 lines
1.1 KiB
Plaintext
map $http_accept $webp_suffix {
|
|
default "";
|
|
"~*webp" ".webp";
|
|
}
|
|
|
|
server {
|
|
listen 80;
|
|
listen [::]:80;
|
|
server_name localhost;
|
|
|
|
location ~* ^/.+\.(jpg|jpeg|png|gif)$ {
|
|
root /usr/share/nginx/html;
|
|
# BEGIN Browser Caching of WebP
|
|
expires 180d;
|
|
add_header Pragma "public";
|
|
add_header Cache-Control "public";
|
|
# END Browser Caching of WebP
|
|
|
|
add_header Vary Accept;
|
|
try_files $uri$webp_suffix $uri =404;
|
|
}
|
|
|
|
location / {
|
|
root /usr/share/nginx/html;
|
|
index index.html index.htm;
|
|
}
|
|
|
|
error_page 404 500 502 503 504 /404.html;
|
|
location = /404.html {
|
|
root /usr/share/nginx/html;
|
|
}
|
|
# Browser Caching
|
|
location ~* \.(css|js|ico|gif|jpeg|jpg|webp|png|svg|eot|otf|woff|woff2|ttf|ogg)$ {
|
|
expires 180d;
|
|
add_header Pragma "public";
|
|
add_header Cache-Control "public";
|
|
}
|
|
|
|
gzip on;
|
|
gzip_comp_level 4;
|
|
gzip_types text/html text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
|
|
|
|
}
|