location /wp-content/uploads/pmpro-invoices/ { 
if ($query_string !~ "access=4b93539cc4429ecc9f5eeb397249fea8"){ return 403;
}

        location ~* \.(zip|gz|tar|rar|doc|docx|xls|xlsx|xlsm|pdf|mp4|m4v|mp3|ts|key|m3u8)$ {
                # Setup lock variables
                set $mplk_uri "/wp-content/plugins/memberpress/lock.php";
                set $mplk_file "/var/www/html/wp-content/uploads/mepr/rules/${cookie_mplk}";

                # don't lock the lock uri
                if ($uri ~* "^/(wp-admin|wp-includes|wp-content/plugins|wp-content/themes)") { break; }

                # redirect if the lock file's a dir or doesn't exist
                if (-d $mplk_file) { rewrite ^ $mplk_uri last; }
                if (!-e $mplk_file) { rewrite ^ $mplk_uri last; }
        }