I'm attempting to build an Nginx conf file to communicate to another container via proxy_pass however within Docker compose the way to communicate is via a hostname that matches the target container but in AWS Fargate the way to communicate is on the loopback address. I'm wondering how I build this configuration that can work in both a Docker compose environment and a Fargate environment without having to have two separate Nginx conf files.
Docker compose nginx.conf
fastcgi_pass php:9000;
Fargate nginx.conf
fastcgi_pass 127.0.0.1:9000;
Is there a way that I can nicely handle configurations for both environments without needing two different images or builds?