Route53 aws: GEO routing with custom path CloudFront - amazon-web-services

I have to configure a DNS table to route traffic in different paths of a CloudFront distribution.
example:
www.mydomain.com, policy geo ITALY, CNAME d1111111.cloudfront.net/IT/index.html
www.mydomain.com, policy geo IRELAND, CNAME d1111111.cloudfront.net/IE/index.html
Route 53 does not consider /it/index.html.
Other solutions?

A path is relevant to the HTTP protocol. DNS is a separate protocol and is only concerned with DNS to IP conversions.
The use of geo routing is not entirely correct in this case. GEO routing is intended to route a client to the closest datacenter, not present different content. This already happens with cloudfront anyway.
Instead you should handle this within your by either doing an IP lookup or using the browser locale. Sometimes the detection is wrong and a user should have the ability to manually change the auto detection. If the user changes thier locale, it should persist for the entire session.

Related

How to point a domain *subdirectory* (not subdomain) to AWS EC2 Instance

I have two EC2 Instances on AWS.
I can point my main domain name (sample.com)to one instance in Route 53.
but how can I point another domain (sample.com/blog) to another EC2 Instance?
For this behaviour you cannot use just Route 53 as subfolders are not part of DNS resolution.
There are many solutions you could use but the most common for a website are using either CloudFront or an ALB to use path based routing.
CloudFront
With this solution you would put CloudFront in front of your domain (Route 53 will route to a CloudFront distribution.
A forwarded location is known as an origin, therefore you would create an origin for each of the target hosts.
The routing mechanism within CloudFront would be the behaviour, with a default behaviour used to forward to your default host.
You would then create an additional behaviour based on the path pattern of the domain that you would want to be routed to the other origin (e.g. /blog*).
More information about this option is available in the Can I use a single CloudFront web distribution to serve content from multiple origins using multiple behaviors? document.
Application Load Balancer
With this option your Route 53 record would forward to an ALB.
You would create a target group for each EC2 instance, and then register this hosts within the target group.
Within the listener in the ALB you would forward all traffic by default to one fo your target groups, then add an additional rule to the listener based on path patterns to forward to the other target group when appropriate.
More information is available within the Advanced Request Routing for AWS Application Load Balancers blog post.

Path Mapping on Route 53 domain name?

I am trying to do a path mapping on a route 53 recordset to the CloudFront instead of a domain name and i have no clue on where to locate the option or even if its possible?
I created a S3 bucket with static hosting enabled, routed it through CloudFront and mapped it to route 53.
What i didnt have trouble doing was,
www.test.com (route 53) -> xxx.cloudfront.net -> s3 bucket(origin)
But i want to be able to do this,
www.test.com/api (route 53) -> xxx.cloudfront.net -> s3 bucket(origin)
is there an option hidden somewhere i am missing to map paths?
PS: I couldn't find any related question asked on the stack, if there is please point me towards it.
Route 53 is specifically for DNS configuration, whilst it allows you to resolve hostnames to IP addresses it does not have route based routing. This would be a layer 7 feature once the hostname has been resolved.
If you want path based routing within your CloudFront distribution you have the option to create multiple behaviours specifying an origin per each behaviour. The behaviour requires you to set a path mapping that when matched will use that origin.
For more information take a look at the Can I use a single CloudFront web distribution to serve content from multiple origins using multiple behaviors? article.

Enforcing geo targeting in AWS

I have my site set up running WordPress on EC2, with the domain set up with Route 53 and CloudFront.
Currently, all non-Australian visitors are set up to be blocked from the site with CloudFront restriction.
I need to set it up so that non-Australian visitors get directed to the .com domain.
Any insight on how to achieve this in AWS?
Amazon Route 53 can provide geolocation routing where DNS names are resolved differently based upon the location of the DNS request.
For example, you can configure Route 53 so that a DNS request coming from Australia is sent to a CloudFront distribution, while other ('default') requests are sent to a different location (eg a CNAME record pointing to a different .com domain). CloudFront can then do an extra level of enforcement to prevent users from bypassing the DNS location check (as you currently have it configured).
Thus, it is actually Amazon Route 53 that will decide where to send the traffic, prior to hitting Amazon CloudFront.

AWS Cloudfront and Route53

How does cloudfront work with Route53 routing policies?
So as I understand it CF is supposed to route requests to the nearest server, which is in effect the Route53 latency policy. So if you have an R53 hosted zone entry for your CF domain name is this done by default if you leave the routing policy as simple or do you neec to explicitly set this yourself? And if you chose another policy type (failover, geo-location etc) would that overwrite it?
You leave it as simple.
You don't have access to the necessary information to actually configure it yourself -- CloudFront returns an appropriate DNS response based on the location of the requester, from a single, simple DNS record. The functionality and configuration is managed transparently by the logic that powers the cloudfront.net domain, you set it and forget it, because there are no user-serviceable parts inside.
This is true whether you use an A-record Alias or a CNAME.
Any other configuration would not really make sense, because talking of failover or geolocation imply that you'd want to send traffic somewhere other than where CloudFront's algorithm would send it.
Now... there are cases when, behind CloudFront, you might want to use some of Route 53's snazzier options. Let's say you had app servers in multiple regions serving exactly the same content. Latency-based routing for the origin hostname (the one where CloudFront sends cache misses) would allow CloudFront to magically send requests to the app server closest to the CloudFront edge that serves each individual request. This would be unrelated to the routing from the browser to the edge, though.

DNS CNAME & MX wildcard

I'm using all infrastructure on AWS and I need:
mydomain.com A ALIAS {S3-bucket- > } s3-website-eu-west-1.amazonaws.com.
www.mydomain.com CNAME mydomain.com
-> website on Amazon S3
*.mydomain.com CNAME {beanstalk} -> myserver-app.elasticbeanstalk.com
-> all other subdomains redirect to the Amazon Beanstalk app
*.mydomain.com MX ->
10 XXYY.in1.mandrillapp.com.
20 XXYY.in2.mandrillapp.com.
-> all emails goes to mandrillapp.
How is possible to do it?
As it's written it doesn't work because of CNAME vs. MX wildcards.
I can't use all names because subdomains will be generated dynamically.
Thank you a lot!!
David
As you have found, you can't have a CNAME and any other type of record at the same level of the DNS hierarchy. Route 53 Alias records, which you're using for your bare domain and for www were created to work around this limitation in the design of DNS, and don't have the same incompatibility issue... but the target of an Alias record can only be one of four things, at the moment: a CloudFront distribution, an Elastic Load Balancer, an S3 bucket of the same name as the hostname in the A record, or another record of the same type in the same hosted zone.
The last two won't help you, but either of the first two could.
If your beanstalk application already has an ELB, you can find that name under Load Balancers in the EC2 console, and you should be able to just use that as your Alias target for the * wildcard A-record Alias for your domain. Or, you could add a load balancer to your beanstalk app, for this purpose.
Alternately, you can create a CloudFront distribution, and configure myapp.elasticbeanstalk.com as the "custom origin" server for the distribition. Configure what CloudFront calls an "alternate domain name (CNAME)" in the distribution for *.example.com -- and, incidentally, disregard the fact that the CloudFront console calls it a "CNAME." They can also be used as Alias targets. Configure the distribution to forward the incoming Host: header to the origin, as well as any other headers you want to forward. Then, you should be able to create your wildcard Alias A record, pointing to the CloudFront distribution, which will forward requests to the beanstalk app.
The problem you're having is an issue with the rules of DNS, which forbid a CNAME record where another record exists.
If a CNAME RR is present at a node, no other data should be
present; this ensures that the data for a canonical name and its aliases
cannot be different. This rule also insures that a cached CNAME can be
used without checking with an authoritative server for other RR types.
Is there are particular reason that you want to have a wildcard MX record? I can't see any situation where it provides a benefit, yet many where it would be a very bad idea! (particularly it makes any host on the network a viable target to send spam from, as any host on that can resolve to the domain has permission to send.
If you explicitly name your MX records you can have a CNAME wildcard (actually I might need to check that! but I do believe so)