简体   繁体   English

AWS ELB重定向到另一个域

[英]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. 我有一个网站建立像https://example.co ,并希望从请求https://example.com重定向到.CO版本。 I'm using AWS EC2 for hosting. 我正在使用AWS EC2进行托管。 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). 最初的想法是为example.com设置一个附加的ELB,并将其转发给我们的后端实例,这将负责重定向(在nginx中)。

You can use a DNS CNAME record to point example.com to example.co . 您可以使用DNS CNAME记录将example.com指向example.co This will then use the SSL certificate for example.co regardless of which domain users use: 然后,无论使用哪个域用户,都将使用example.co的SSL证书:

  • Configure an Elastic Load Balancer with an SSL certificate for example.co 使用SSL证书为example.co配置Elastic Load Balancer
  • Configure both example.co and example.com as Hosted Zones in Amazon Route 53 : example.coexample.com都配置为Amazon Route 53中的托管区域:
    • For example.co , use an A record with Alias=YES to point to the Elastic Load Balancer 例如example.co ,使用Alias=YESA记录指向Elastic Load Balancer
    • For example.com , use a CNAME record to redirect to example.co 例如example.com ,使用CNAME记录重定向到example.co

This way, HTTPS requests to both domains should point to the same ELB be sent to the same servers. 这样,对两个域的HTTPS请求应指向相同的ELB,并将其发送到相同的服务器。

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. 我认为最经济有效的方法是仅使用一个ELB和一个SSL证书,然后将两个域都指向该ELB。 Your understanding that an ELB can only host one SSL certificate is correct (once certificate per listener/port). 您对ELB只能托管一个SSL证书的理解是正确的(每个侦听器/端口一次证书)。

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. 但是,确实存在多域SSL证书:您可以获得一个SSL证书,该证书可以同时用于example.com和example.co。 This way, you can have one ELB that accepts https traffic for both domains. 这样,您可以有一个ELB接受两个域的https流量。

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. 您可以在ELB后面的实例上的Web服务器上进行设置。 Configure virtual hosts for example.com and example.co, and make the virtual host for example.com serve redirects to example.co. 配置example.com和example.co的虚拟主机,并使example.com服务的虚拟主机重定向到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. 因此,实际上这与您的最初计划非常接近,除了使用多域SSL证书时只需要一个ELB。

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). 多域证书通常比常规证书贵一些,但远低于附加ELB的费用(如果我没有记错的话,起价为每月35美元)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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