Redirect missing images in a specific directory
Do this:
location /img {
try_files $uri /img/default.jpg;
}
That will not redirect the request to default.jpg, but instead the file contents of their request will be served with the default.jpg contents instead.
More info here: http://nginx.org/en/docs/http/ngx_http_core_module.html#try_files
Redirecting would be pretty messy and would need to make use of the if directive. You can do that too though. More info here: http://nginx.org/en/docs/http/ngx_http_rewrite_module.html#if