The server has multiple different docker containers. How can I modify the Nginx configuration so that it can be forwarded to a specified IP according to the specified URL?

  docker, question

The server has multiple different docker containers. How can I modify the Nginx configuration so that it can be forwarded to a specified IP according to the specified URL?
Under normal circumstances, the IP accessed is random. How can he access the specified container IP according to the conditions by modifying the configuration file?

location /url1 {
 Proxy_pass http:// ip of container 1: port of container 1;
 }
 location /url2 {
 Proxy_pass http:// ip of container 2: port of container 2;
 }

Because of the limited conditions you have given, we can only speculate on the above solutions at present.