Connect nginx container with other container

In the ee v3 i had a “image proxy container” ( to autogenerate thumbnails, and make a proxy_pass with ‘location /thumb {…}’.

How is it possible make this now in the v4? if i create the proxy_pass to ‘localhost’ how it’s in the container don’t work, and i don’t like expose the image proxy port to internet.