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 個月前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南