Adicionado várias linhas podem ser.
map $http_accept $webp_suffix { "~*webp" ".webp"; }
types {
# ensure the nginx supports the mime type
image/webp webp;
}
location ~* \.(?:ico|cur|gif|svg|svgz|png|jpe?g)(\?.+)?$ {
try_files $uri$webp_suffix $uri =404;
}
O seguinte é o conf nginx completo:
upstream nodejs {
server 127.0.0.1:8081;
keepalive 256;
}
map $http_accept $webp_suffix { "~*webp" ".webp"; }
types {
image/webp webp;
}
server {
listen 8080;
if ($time_iso8601 ~ "^(\d{4})-(\d{2})-(\d{2})T(\d{2})") {
set $year $1;
set $month $2;
set $day $3;
set $hour $4;
}
access_log /var/log/nginx/healthd/application.log.$year-$month-$day-$hour healthd;
access_log /var/log/nginx/access.log main;
location / {
proxy_pass http://nodejs;
proxy_set_header Connection "";
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
location ~* \.(?:ico|cur|gif|svg|svgz|png|jpe?g)(\?.+)?$ {
try_files $uri$webp_suffix $uri =404;
}
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;
}