How does Nginx reverse proxy multiple ports to different directories on the same port?

  docker, question

How to configure Nginx’s reverse proxy to proxy multiple ports to different directories on the same port?

I have applications A, B and C, which run on ports 8001, 8002 and 8003 respectively.
The server does not have a domain name configured, so the access address isip:8001ip:8002Andip:8003.
Now I want to use Nginx to implement, only open an 80 port, and then access different services through different directories.
I expect the access address to becomeip:80/aip:80/bAndip:80/c. And all resource requests under this application are based on this path.
such asip:80/aYou can jump toip:80/a/loginInstead ofip:80/login, pay attention to the directory.
My /etc/nginx/conf.d/default.conf is as follows:

server {
 listen       80;
 server_name  localhost;
 location /a {
 location /b {
 location /c {

According to my above configuration, enterip:80/aI did see a successful agentip:8001The application, only look at the home page, everything is normal.
But a jumpip:80/a/user/**Such a multi-level directory fails and becomesip:80/user/**.
I have also tried to use official documents, regular configuration of location or rewrite, but I cannot achieve the desired effect.
Thank you for your advice.

I’ve tried, no, unless there is a domain name.