简体   繁体   中英

AWS ELB Redirect to another Domain

I have a site set up like https://example.co and want requests from https://example.com redirected to the .co version. I'm using AWS EC2 for hosting. What is the most cost efficient way to do this? Initial thought was to set up an additional ELB for the example.com and have it forward to our backend instances, which would take care of the redirect (in nginx).

You can use a DNS CNAME record to point example.com to example.co . This will then use the SSL certificate for example.co regardless of which domain users use:

  • Configure an Elastic Load Balancer with an SSL certificate for example.co
  • Configure both example.co and example.com as Hosted Zones in Amazon Route 53 :
    • For example.co , use an A record with Alias=YES to point to the Elastic Load Balancer
    • For example.com , use a CNAME record to redirect to example.co

This way, HTTPS requests to both domains should point to the same ELB be sent to the same servers.

I think the most cost effective way would be to only use one ELB and once SSL certificate, and point both domains to that ELB. Your understanding that an ELB can only host one SSL certificate is correct (once certificate per listener/port).

However, multi-domain SSL certificates do exist: you can get one SSL certificate that has can be used both for example.com and example.co. This way, you can have one ELB that accepts https traffic for both domains.

The second setup is to get the redirects to work. You can set that up at the web server on the instance(s) behind the ELB. Configure virtual hosts for example.com and example.co, and make the virtual host for example.com serve redirects to example.co.

So actually that's pretty close to your initial plan, with the exception that you only need to have one ELB when you use a multi-domain SSL certificate.

A multi-domain certificate is usually a bit more expensive than a regular certificate, but well below the costs of an additional ELB (which starts at something like $35 per month, if i recall correctly).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM