I created a stack based on ECS Fargate.
I have Network Load Balancer that passes traffic to my Nginx deployed as Fargate.
Next of that, I have some services like backend API. In Nginx config, I created rules for path, etc.
Communication between services is based on cloudMap (all services are registered in cloudmap in the same namespace).
Everything is working until ... !
... service restart task or I make deployment new version, then new task has different IP.
In that case, Nginx starts returning the error No live upstreams while connecting to upstream
. When I reload Nginx in tasks: --container nginx --command "/usr/sbin/nginx -s reload" --interactive
it works again.
I found some suggestions to use upstream and setup resolver with a short valid time. I did that, but it doesn't resolve my problem.
resolver 10.3.0.2 valid=1s;
upstream upstreamApi {
least_conn;
server apiService.test-stack:8080;
}
location ~ ^/api {
proxy_pass http://upstreamApi;
}
P.S. I can't use ALB