使用 https 从 Route53 指向 DigitialOcean 的域和子域

Point domain and subdomain from Route53 to DigitialOcean using https

我在两个 digitialocean droplet 上有两个 wordpress 站点 运行。 他们都有 ssl 证书并将所有请求重定向到 https。

让我们将第一个地址称为https://my-freenom-domain-1.ml

让我们调用第二个地址https://my-freenom-domain-2.ml

我在 route53 上注册了一个域。我们将域命名为 my-domain.com.

我正在尝试将所有请求从 https://my-domain.com 映射(而不是重定向)到 https://my-freenom-domain-1.ml 以及从 https://subdomain.my-domain.comhttps://my-freenom-domain-2.ml

的所有请求

你会怎么做?

更新:

我试过的方法(没用)

  1. 正在创建一个简单的 CNAME。

主域的 CNAME (my-domain.com):

无法为主域创建 CNAME 并出现以下错误: RRSet of type CNAME with DNS name my-domain.com. is not permitted at apex in zone my-domain.com.

子域的 CNAME (subdomain.my-domain.com):

我能够为子域创建 CNAME,但请求被重定向。 所以当我去 subdomain.my-domain.com 我被重定向到 https://my-freenom-domain-2.ml

  1. 创建 S3 "redirect-bucket"

我已经尝试创建一个 S3 存储桶来重定向对子域的所有请求。 因此,名为 subdomain.my-domain.com 的存储桶会将所有重定向重定向到 https://my-freenom-domain-2.ml (https)。 然后我为 subdomain.my-domain.com 创建了一个指向 subdomain.my-domain.com.s3-website-eu-west-1.amazonaws.com 的 CNAME。 但是所有请求仍然被重定向...

您需要在 Digital Ocean droplets 上为您的新域创建一个虚拟主机,它才能工作。 所以我会做以下事情让它发挥作用 -

  • 在水滴的网络服务器上为新域创建虚拟主机, 或在网络服务器配置中添加新域作为服务器。

  • 将新域的 SSL 证书添加到旧的网络服务器,或者在 ELB 处终止 ssl。

  • 为指向旧域服务器的新域添加 DNS CNAME 或 A 记录条目。

Post 这个应该行得通。

这是基于@mdeora 的 正确答案并包含一些细节。

1.在droplet

中为域(my-domain.com)创建虚拟主机

复制默认配置:

sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/my-domain.com.conf

将 ServerName 添加到 conf:

<VirtualHost *:80>
        ServerAdmin webmaster@localhost
        ServerName my-domain.com
        DocumentRoot /var/www/html

        <Directory /var/www/html/>
            Options FollowSymLinks
            AllowOverride All
            Require all granted
        </Directory>

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

启用站点:a2ensite my-domain.com.conf

重新加载 Apache:systemctl reload apache2

2。在 droplets 服务器上安装 ssl 证书

(我是用 certbot 做的)

certbot --apache -d my-domain.com

(遵循 certbot 说明)

3。在route53

中创建一条A记录

创建一条A记录,指向droplet的ip

(4.更新wordpress设置)

如果您是 运行 wordpress 站点,请务必将管理员中的 wordpress url 设置更改为 https://my-domain.com

现在,希望一切正常。