Link to home
Start Free TrialLog in
Avatar of Robert Granlund
Robert GranlundFlag for United States of America

asked on

Trouble forwarding traffic from a AWS Site to another

I am not familiar with AWS as I thought I ws.  I am having an issue forwarding 2 domains.  Same domain just one with www and the other without.  I edited the A record set to the endpoint.  Something is not working though.  The www does it correct and the non www does not forward.  I also have been looking for a solution but everything is about forwarding to AWS not forwarding away from AWS to a different domain.  I want the domain that is hosted on AWS the traffic to be forwarded to a non AWS hosted site.  Help?
Avatar of David Johnson, CD
David Johnson, CD
Flag of Canada image

you don't do it via forwarding at all.  I"m guessing at your dns provider you have
a example.com 123.123.123.123 <replace 123's with the ip address of your non www website which has no redirects configured i.e. convert non-www to www
and a cname
www that points to example.aws.com
if you are using route53 to host your dns records I'd recommend that you don't use something like cloudflare instead.
Avatar of Robert Granlund

ASKER

Thank you for the response.  The site hosted on AWS has 2 sites, www.MYSITE.com and MYSITE.com.  Both need to forward to MY_NEW_SITE.com.  Are you saying to do it via the DNS?  

The one Site www.MYSITE.com forwards just fine.  However the non-www (snas subdomain) does not forward.  Any further suggestions? I am not as familiare with the AWS setup as I thought I would be and I am a little stuck.
Route53 will not route outside of AWS
Thank you again.  How do I route outside of AWS?  I can not seem to find a tutorial.
ASKER CERTIFIED SOLUTION
Avatar of David Johnson, CD
David Johnson, CD
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
DNS alone will not help you, and you don't have to use Cloudflare or anything out of AWS.

Your problem is quite common. A company gets rebranded with a new name, or is merged with another company, and the old website should be gracefully retired, while keeping SEO and links.

You want the old links to MYSITE.com  / www.MYSITE.com  to still function, and just redirect the browsers to the new domain using HTTP 301/302 status codes.

The setup on Route53:
MYSITE.com  has an A record pointing to a web server, for example 123.123.123.123  (on AWS)
www.MYSITE.com  has a CNAME pointing to MYSITE.com, or another A record.  (on AWS)
MY_NEW_SITE.com  has an A record pointing to 234.234.234.234  (out of AWS)

Option 1: Setup the MYSITE.com  web servers for redirection.
I assume that you have Apache/Nginx/IIS servers down below.
Each one can be set up to redirect traffic to other domains. Say which one you have, and EE experts will gladly help you with the setup.

Option 2: Use Cloudfront and S3
You set up a S3 bucket and a Cloudfront distribution according to these instructions.

Option 3: Use Cloudfront and a Lambda@Edge function
The difference between this solution and the previous one is that your Lambda code can make redirection decisions based on any part of the request, including URL, headers, cookies, or origin IP.
A skeleton template for redirection is found here.

Option 4: Move MYSITE.com to another DNS
I did say that you don't have to move, but you can if it makes sense.
Some DNS providers have the ability to provide a redirection service.
Cloudflare does it with page rules, you may need a paid account.
DNS providers like DnsMadeEasy, NS1, and UItraDNS, have HTTP redirection services. None of them support HTTPS, so if you have HTTPS links you can't use them.

Option 5: Use a redirection commercial service
Depending on your needs and budget, consider using a service such as easyredir.com
This will be easiest, and possibly the most cost effective.
Domain forwarding is more correctly called URL redirection.

This is handled at the HTTP/HTTPS level, not DNS.

Best to talk with whoever setup your Webserver, as each type of Webserver has it's own config file syntax.

Better to do all this at your Webserver level (rather than some other layer of tech), so each time you change hosting, your entire Webserver config travels with your site, so all requests work independent of hosting or other layers of tech.
@Shalom Carmel Thank you for this detailed information.  I have had to go through the process a few times to get it right but I almost have it. It takes a while for the cloudFront distribution to process.  It seems overly complicated but now that I have done it a few times, I think I get it.  However, it is fickle about entering the domain name. meaning, if I go to MYSITE.com it returns MYSITE.com/index.html  I still have not figured that out.  Also, It seems to have cached in Firefox.  Is there a way to clear the cache for the site / CloudFront?
If you chose to use the Cloudfront + S3 redirection, then you have to change your DNS,  pointing MYSITE.com and www.MYSITE.com to the Cloudfront distribution. Did you do that?