How does one get the AWS Cloudfront subdomain from the request on the custom origin that I've created.
The only header that comes close is the Via header but it doesn't contain any useful information
It looks like:
Via: 1.1 1026589cc7887e7a0dc7827b4example.cloudfront.net (CloudFront)
Note that 1026589cc7887e7a0dc7827b4example
is not the original subdomain that I've assigned to the custom origin.
You can configure CloudFront to through pass Host header to the origin. It is described here: http://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/header-caching.html. Note that in this case it will also be included into the CloudFront's cache key, so use it if you plan to serve different content for different values of Host header.