How can I do a 301 redirect towards an URL ending in a slash with Nginx?

Big thanks to Richard's Smith comment. It let me fix the configuration file. Now the proxy_pass action in the file looks like:

location /pihole/ {
  proxy_set_header Host $host;
  proxy_set_header X-Real-IP $remote_addr;
  proxy_pass http://127.0.0.1:31480/;
  proxy_redirect http://servername.xyz/admin/ http://servername.xyz/pihole/admin/;
}

After including the proxy_redirect directive, things start working again.