Redirect port to subdir

What you’re asking about is not redirects, but proxying. Very different concepts.

A redirect in the context of web/HTTP is a specific kind of HTTP response which contains a Location header which tells the client to try again but at a different URL.

That said, there’s often issues with proxying to upstream services that aren’t designed to work under subpaths. It’s generally much easier to use subdomains for each service instead, like sub.example.com instead of example.com/sub.

See this article which explains in detail: