Can multiple public URLbe part of one AWS CloudFront & WAF service?

3 web public URL needs to be allowed for external users to access a Windows Server (EC2 instance) with multiple IIS folders.

3 URL example:

https://prod.contoso.com

https://stag.contoso.com

https://test.contoso.com

Currently, we have 1 CloudFront & WAF service running in AWS that allows for one of the URL i.e. https://prod.contoso.com (out of 3) to connect with the EC2 Instance.

However, not sure If I can use the same CloudFront & WAF services for other 2 Public URL?


Related discussions:

Are all 3 sites run on the same server? If so, it could work, otherwise, you’d need to inject an ALB in between cloudfront and the ec2 instance to handle some of the existing logic that cloudfront can’t do alone.

If they’re all on the same server, Add the additional CNAMEs to your cloudfront distribution for stage and test and ensure they’re on your ACM cert as well. In IIS, have the different websites configured to listen on the appropriate host header for the different sites. Update your DNS records to point to the cloudfront distribution and In theory, that should be all that’s required to get it flow properly.

If you wanted to have them on different servers, you’d need to add an ALB into the mix and do host based routing rules to the different target groups for each of the instances. You could still do it all with the single cloudfront distribution, with the same changes applying above for the most part.

nted to have them on different servers, you’d need to add an ALB into the mix an

u/jamsan920

First of all thanks for your response and your suggestion are indeed guiding me.

To answer:

Are all 3 sites run on the same server? - Yes

So one CloudFront & WAF for all 3 Public URL is possible.

I`m planning to have the flow in the following way:

User----> Internet----> CloudFront---->Route 53----> ELB ----> VM(web server)

Internal User Access:

User----> ALB ----> VM(web server)

Hope its fine.

Yes that’ll work pretty much as described. The only clarification is that route 53 will sit a layer above cloudfront, as that’s what will be responsible for directing users to cloudfront.

In terms of internal user access, how do you plan on changing the flow to go straight to the ALB? Will you have an internal DNS pointing to the address of the load balancer or some other method?

u/jamsan920

I`ve configured the required services and flow looks as shown below:

User----> Internet----> Route53---->CloudFront----> ELB ----> VM(web server)

However, cannot browse the Webpage on 443 from my machine.

getting error: 404

( for testing: my machine IP address is allowed on port 80 and 443 on the EC2 - sec group)

Checking the Load Balancer settings, found under target group under the Tab name: Target

Following message appears:

" None of these Availability Zones contains a healthy target. Requests are being routed to all targets. "

Any clue or directions to look upon.

Already verified the security group for the EC2 and port 80, 443 is allowed.

Generally, each layer will need to be accessible by the upper layer there connecting to it. For example, cloudfront will need to be able to connect to your ELB over 80/443. Your ELB will need to connect to your EC2 instance over 80/443.

Let’s start with cloudfront to the ELB. Cloudfront requires that origins by publicly accessible to connect to them, so have you:

  • deployed your load balancer in public subnets, as an internet load balancer?
  • opened up the security group attached to the load balancer to 80/443 to the world (0.0.0.0/0)? This part is 100% required as you could potentially white list cloudfront address space, but opening it wide open is easier for troubleshooting purposes.

Now let’s move into the ELB to EC2 instance. The security group attached to your EC2 instances, are you allowing 80/443 to the load balancer? The easiest way to accomplish that is allowing the traffic from the security group of the ELB itself, but you could also optionally allow it to the entire subnet where the load balancers are deployed.

Once you confirm those 2 pieces, it should start flowing nicely. Based on your health checks failing, you’re definitely not allowing the ELB —> EC2 connection, but possibly more may be misconfigured as well.

u/jamsan920

Thanks for the detailed explanation.

Appreciate your support and guidance.

Found on the EC2 - Windows Instance (IIS Hostheader didnt had port 80)

Can access the Website.

However, interesting is it WEBDAV request (Port 443) is not working.

Website (Port 443) is working.

I`m not sure if CLoudFront allows WEBDAV request.

Researching on it.