Rewrites vs. location, etc

From what it appears,

rewrite foo bar last;

Gets processed before any location blocks.

i.e. a request for


with a rewrite of rewrite ^/foo/(.*) /$1 last;

will wind up making it /bar, so the location needs to be

location /bar {


I am having issues with an app that needs a bunch of rewrites, some
pretty generic, and intercepting the request for just one URI path and
passing it on to either a location block that has its own
root/etc/etc, or I am even trying to proxy_pass it to port 81 with
another nginx server {} listening on it so it’s a fully isolated