I have to recommend using a subdomain for that app instead of trying to proxy it under a subpath. On most linux distributions, *.localhost will also resolve to 127.0.0.1, so you could use rstudio.localhost to differentiate it from other apps.
If the app has a “base path” configuration or equivalent, you might use that to avoid needing to do additional manipulations. If it doesn’t, then it’ll always be a struggle to fix all the paths it responds with (including CSS/JS paths in HTML, redirects, etc).
My apologies, I should have been more clear about my environment and constraints. I’m dev’ing locally, but it’s for servers on an intranet. Our cert management is a somewhat tedious process so I’m attempting to use basepath/subfolder/subpath instead of subdomains because we’re trying a variety of ide’s. so far rstudio server is the only one that doesn’t use relative redirects or a basepath configuration.
I was finally able to get redirects to work by fixing my header_down as below. It attempts to strip the protocol, hostname, port, and initial slash from the location header and replace it with a relative ./
This fix won’t work with content, just a redirect. I also don’t know how robust this regex is, so it may need additional tweaking.
As a followup note. For apps that are expected to work with nginx’s proxy_pass directive for subpaths/folders (like rstudio server), manipulating location and refresh headers should be all that’s required as their docs indicate that’s all proxy_pass does. The key is to get the right header manipulation regex.