Skip to content

Commit ab4da75

Browse files
Add documentation for redirecting 443 SSL traffic to any container port
What does this extra example show? How to forward HTTPS 443 traffic to a container's port 8080. At first glance, this may look like a redundant documentation entry. After all, we just showed SSL termination right above this example. We're cluttering the docs! Let me directly address this: - This literally took me 3 straight days to figure out how to do. I arrived at a custom 120 line CloudFormation yaml file before I realized I could do it this way. - There is not a single mention of the `x-aws-protocol` flag on this entire page. This adds a very helpful use case. - The jump to overriding a network load balancer and learning the `x-aws-protocol` flag, plus learning the correct `x-aws-cloudformation` overlay, plus understanding the difference between all the load balancer sub objects (TargetGroup, Listener, LoadBalancer) and knowing which fields to override is non-trivial. - Many web frameworks actively discourage running your server on port 80. It requires root user (sudo) permissions to bind to port 80. You could even argue the port 80 example above this one is encouraging bad practices (see this Digital Ocean explanation https://www.digitalocean.com/community/tutorials/how-to-use-pm2-to-setup-a-node-js-production-environment-on-an-ubuntu-vps#give-safe-user-permission-to-use-port-80 ) I think forwarding HTTPS traffic to a non-privileged container `443:8080` is a VERY common use case, and well worth the extra example here in the docs.
1 parent 686ee98 commit ab4da75

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

cloud/ecs-integration.md

+22
Original file line numberDiff line numberDiff line change
@@ -496,6 +496,28 @@ x-aws-cloudformation:
496496
Port: 443
497497
```
498498

499+
#### Setting SSL termination by Load Balancer (non-privileged ports)
500+
501+
If you don't want to expose privileged ports on your container, but you still want to receive 443 traffic, you can use the `x-aws-protocol` flag to create an application load balancer, and an overlay can then direct HTTPS traffic to your container. This example forwards port 443 traffic to port 8080.
502+
503+
```yaml
504+
services:
505+
webapp:
506+
image: acme/webapp
507+
ports:
508+
- target: 8080
509+
x-aws-protocol: http # enable an application load balancer
510+
511+
x-aws-cloudformation:
512+
Resources:
513+
WebappTCP8080Listener:
514+
Properties:
515+
Certificates:
516+
- CertificateArn: "arn:aws:acm:certificate/123abc"
517+
Protocol: HTTPS
518+
Port: 443
519+
```
520+
499521
## Using existing AWS network resources
500522

501523
By default, the Docker Compose CLI creates an ECS cluster for your Compose application, a Security Group per network in your Compose file on your AWS account’s default VPC, and a LoadBalancer to route traffic to your services.

0 commit comments

Comments
 (0)