I\'ve got a pretty specific problem here, we\'ve got a system that we already have and maintain, the system involves using subdomains to route people to specific apps.
Create a Cloudfront distribution
Add all the Alternate CNAMEs records in the cloudfront distribution
Alternate CNAMEs
Add a custom origin as the EC2 server.
Set behaviours as per your requirements.
Configure nginx virtualhosts in the server to route to specific folders.