AWS – Enabling HTTPS in Docker Applications on EC2/ECS

amazon-web-servicesnode.js

This is the first project I'm deploying in AWS and I'm really struggling with how things work. Stack Overflow wasn't the right place for this question so hopefully, this one will be.

I currently have an application running on Docker in an EC2 instance, perhaps that container will be eventually run in ECS depending on what is decided. The Node API is currently running in HTTP and it is going to be consumed by both a SPA which is hosted in Firebase and only allows connections with HTTPS. Is AWS Elastic Load Balancer + AWS Certificate Manager with Public Certificate able to do the job for me in both EC2 and ECS situations? If yes, can Load Balancer point to multiple APIs and will I need more than one certificate/domain for each one? Thank you in advance for your attention.

Best Answer

Instead of ELB (Elastic Load Balancer) consider ALB (Application Load Balancer) - it is generally cheaper and more flexible.

Yes you can have a certificate from AWS Certificate Manager and terminate SSL on the ALB. The ALB can then talk to your docker container over plain HTTP (non-SSL). If you use ECS (and you should!) it can register the containers with ALB automatically.

ALB has a concept of Target Groups where you can have different content providers, e.g. different API containers, behind a single load balancer. They will differ by paths, e.g. /api1/... and /api2/..., but will share the same host name. That also means you'll get away with a single ACM certificate.

Hope that helps :)

Related Topic