Redirect requests for missing wordpress uploads to another server using NGINX

When working on a copy of a live WordPress website it can be handy not to have to duplicate the uploaded files in wp-content/uploads, whilst still allowing the creation of new uploads during testing and development without affecting the production website.

The configuration below can be added inside a server{} block inside an NGINX configuration file to redirect any requests for files in wp-content/uploads that don’t exist back to the live server, www.example.com.

This solution was based on the information at http://wordpress.stackexchange.com/a/215189 and https://www.nginx.com/blog/creating-nginx-rewrite-rules/ .