Return default placeholder image when image file on server not found

What is the right way to convert this from .htaccess to nginx.conf…

##Return default placeholder image when image file on server not found
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-f
RewriteRule .(gif|jpe?g|png) /image404.php [NC,L]

Posted at Nginx Forum:
https://forum.nginx.org/read.php?2,267211,267211#msg-267211

Found the answer on IRC #Freenode #nginx by catbeard

location ~ .(png|jp?g|gif)$ {
error_page 404 /404.png;
}

http://serverfault.com/a/481612

Posted at Nginx Forum:
https://forum.nginx.org/read.php?2,267211,267213#msg-267213

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs