Welcome! Log In Create A New Profile

Advanced

Re: Nginx does not serve avif

All files from this thread

File Name File Size   Posted by Date  
Bildschirmfoto 2022-10-07 um 11.42.46.png 42 KB open | download Martin Wolfert 10/07/2022 Read message
Bildschirmfoto 2022-10-07 um 11.42.46.png 42 KB open | download Martin Wolfert 10/07/2022 Read message
Francis Daly
October 06, 2022 05:46PM
On Thu, Oct 06, 2022 at 02:30:08PM +0200, Martin Wolfert wrote:

Hi there,

> In "/var/www/htdocs/blog.lichttraeumer.de/wp-content/uploads/2022/05" i have
> located .jpg, .webp and .avif files:

Thanks for the details.

Both ideas seem to work for me, when testing with curl:

===
$ cat /etc/nginx/conf.d/test-avif.conf
server {
listen 127.0.0.5:80;
root /tmp/t3;

set $img_suffix "";
if ($http_accept ~* "webp") {
set $img_suffix ".webp";
}
if ($http_accept ~* "avif") {
set $img_suffix ".avif";
}
location ~ \.(jpg|png)$ {
try_files $uri$img_suffix $uri $uri/ =404;
}
}
$ mkdir /tmp/t3
$ echo one.png > /tmp/t3/one.png
$ echo one.png.avif > /tmp/t3/one.png.avif

$ curl http://127.0.0.5/one.png
one.png
$ curl -H Accept:webp http://127.0.0.5/one.png
one.png
$ curl -H Accept:avif http://127.0.0.5/one.png
one.png.avif

===
$ cat /etc/nginx/conf.d/test-avif-map.conf
map $http_accept $webp_suffix {
"~image/webp" "$uri.webp";
}
map $http_accept $avif_suffix {
"~image/avif" "$uri.avif";
}

server {
listen 127.0.0.6:80;
root /tmp/t4;

location ~ \.(jpg|jpeg)$ {
try_files $avif_suffix $webp_suffix $uri =404;
}
}
$ mkdir /tmp/t4
$ echo one.jpg > /tmp/t4/one.jpg
$ echo one.jpg.webp > /tmp/t4/one.jpg.webp
$ echo one.jpg.avif > /tmp/t4/one.jpg.avif
$ echo two.jpg.webp > /tmp/t4/two.jpg.webp

$ curl http://127.0.0.6/one.jpg
one.jpg
$ curl -H Accept:image/avif http://127.0.0.6/one.jpg
one.jpg.avif
$ curl -H Accept:image/webp http://127.0.0.6/one.jpg
one.jpg.webp
$ curl -H Accept:image/other http://127.0.0.6/one.jpg
one.jpg
$ curl -H Accept:image/avif,image/webp http://127.0.0.6/one.jpg
one.jpg.avif
$ curl -H Accept:image/avif,image/webp http://127.0.0.6/two.jpg
two.jpg.webp
$

===

Do they work for you, when testing with curl?

If not -- why not / what is different between your test config and my test config?

And if so -- what is different between the curl request and the Firefox request?

Thanks,

f
--
Francis Daly francis@daoine.org
_______________________________________________
nginx mailing list -- nginx@nginx.org
To unsubscribe send an email to nginx-leave@nginx.org
Subject Author Posted

Nginx does not serve avif

Martin Wolfert September 28, 2022 04:52AM

Re: Nginx does not serve avif

Francis Daly September 28, 2022 05:20PM

Re: Nginx does not serve avif

Martin Wolfert October 06, 2022 08:32AM

Re: Nginx does not serve avif

Francis Daly October 06, 2022 05:46PM

Re: Nginx does not serve avif Attachments

Martin Wolfert October 07, 2022 06:06AM

Re: Nginx does not serve avif Attachments

Martin Wolfert October 07, 2022 08:02AM

Re: Nginx does not serve avif

Francis Daly October 07, 2022 08:16AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 147
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready