Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Building a secure HTTPs web server with Fargate + ACM + ALB

I am trying for the simplest deploy to get an https web server up and running in Fargate.

I have used Amazon Certificate Manager to create a public certificate.

I have an Application Load Balancer that is talking to the Fargate container on two ports: 80 for http and 443 for https

This is the problem: when I run my webserver on port 80 (http) and connect via the ALB, it works fine (not secure, but it serves up the html).

When I run my webserver on port 443 with TLS enabled, it does not connect via the ALB.

Another point is that when running my webserver with TLS enabled on port 443, I do not have the certificate or certificate key, and so am confused how to get that from Amazon.

Another question I have is: does it make sense for me to say that the ELB will communicate with the client over HTTPS but that the ELB can communicate with the container via HTTP? Is this secure?

Thank you for any help, my networking knowledge is very rusty.

like image 324
TheBottleSeller Avatar asked Aug 30 '18 04:08

TheBottleSeller


1 Answers

does it make sense for me to say that the ELB will communicate with the client over HTTPS but that the ELB can communicate with the container via HTTP?

Yes. You should make sure your web server is accepting traffic from the ALB on port 80. This is done at the application level, on the web server, and with your target group, which is what the ALB will use to determine how it routes traffic to your web server. This is way it typically works:

client --(443)--> ALB --(80)--> web server

Some things to check:

  • Target group is configured to send traffic to your FG web server on port 80
  • Target group health check is configured to check port 80
  • FG task security group has ingress from ALB on port 80
  • Web server is configured to listen on port 80

Sidenote: You can configure your target group to send traffic to the target (web server in Fargate) on 443, but as you said, without the proper certificate setup in the container, you won't be able to properly terminate SSL and it just wouldn't work. You would need to upload your own cert to ACM for this to work, which sends you down a security rabbit hole, namely how to avoid baking your private key into your Docker image.

like image 84
bluescores Avatar answered Sep 24 '22 02:09

bluescores