Establish connectivity between Nginx and a web application in ECS

0

Howdy,

I am trying to host a basic web application on ECS. I have a cluster set up for my web front end (nginx) and another cluster for my backend application (ctfd). I am attempting to have nginx act as a reverse proxy and forward HTTP traffic to my ctfd container which is listening on port 8000. Both applications are configured to use the same namespace which I've called "ctfd-api-dns". Both containers are hosted on fargate with the network mode set to avsvpc.

When I run my nginx task, it fails with the error:

nginx: [emerg] host not found in upstream "ctfd:8000" in /etc/nginx/nginx.conf:13

This error seems to indicate nginx is unable to resolve the address or reach the ctfd container running under the ctfd task.

Here is the nginx configuration being used by the nginx task running in the nginx cluster.

https://pastebin.com/raw/xzgkH2Nq

How can I establish connectivity between these two containers so that nginx acts as a reverse proxy for ctfd?

Cheers

Chair
已提问 1 个月前583 查看次数
1 回答
1
已接受的回答

Hello,

The connection between the Nginx container and the app should be using localhost:port instead of "container name" and port.

The blog post NGINX reverse proxy sidecar for a web container hosted with Amazon ECS and AWS Fargate explains this with more details.

Hope this helps!

profile pictureAWS
已回答 1 个月前

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则