Found it! It must look like this, putting =404 as last location in
try_files:
location ~ ^/img/[^\.]*$ {
try_files $uri.png $uri.jpg $uri.gif $uri =404;
error_page 404 /img/missing;
}
That would be useful information to put in the try_files wiki...
Posted at Nginx Forum: http://forum.nginx.org/read.php?2,194965,195019#msg-195019