Apply Rewrite Rules on Nginx

Hi I want to configure the AAM Protected Media Files plugin to protected uploaded files. Only the first step is to add a rewrite rule on the server. As WPMUDEv is using Nginx server and not apache I wondering if and where I can add a rewrite rule?

I need to add

location ~* ^/wp-content/uploads/ {
rewrite (?i)^(/wp-content/uploads/.*)$ /index.php?aam-media=$1 last;
return 307;
}

link to instruction.

Any help or suggestions would be much appreciated.