A regex location can quietly win over a plain prefix location, and that matters most for upload folders.
location ^~ /uploads/ { root /var/www; }
location ~* \.php$ { fastcgi_pass unix:/run/php/php-fpm.sock; }
nginx picks the longest matching prefix location first. If that prefix carries ^~, regex locations are skipped. Without it, ~* \.php$ still gets a request for /uploads/shell.php and passes it to PHP. Order of checks: = exact match, then the longest prefix, then regexes in file order, then the stored prefix. Test with a request to a file in the folder and see which block answers.
Further reading: ngx_http_core_module: location
Going deeper: ๐ Guide: AdGuard Home + Tailscale (Secure Split-Horizon DNS)