期限切れの SSL 証明書を持つドメインを Apache を使用して新しいドメインにリダイレクトする方法

期限切れの SSL 証明書を持つドメインを Apache を使用して新しいドメインにリダイレクトする方法

昔はhttps://example.com. そして、私は使いたいと思ったhttps://myotherexample.com代わりにexample.comを使います。そこでサーバーを設定し、DNSをそのサーバーに向けると、すべてうまくいきました。次にリダイレクトしたいのはhttps://example.comhttps://myotherexample.comそのため、古いアドレスのユーザーは新しいサイトにアクセスし続けることになります。これは、ポート 80 を新しいドメインにリダイレクトする場合は問題なく機能しますが、ポート 443 (SSL ポート) をリダイレクトしようとすると、Apache は古いドメインの有効な SSL 証明書を必要とするようです (そのアドレスでサイトの安全なバージョンを提供していないにもかかわらず)。古いドメインの SSL 証明書の有効期限が切れており、保護するものが何もないので、このようなリダイレクトを実行するにはどうすればよいのか疑問に思っています。

example.com の設定:


<VirtualHost *:80>


        ServerAdmin webmaster@localhost
        DocumentRoot /sites/example.com/html
        ServerName example.com
        ServerAlias www.example.com
        Redirect / https://myotherexample.com/


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

新しいドメインにリダイレクトするために必要な SSL バージョンは次のとおりです。

<VirtualHost *:443>
        # The ServerName directive sets the request scheme, hostname and port that
        # the server uses to identify itself. This is used when creating
        # redirection URLs. In the context of virtual hosts, the ServerName
        # specifies what hostname must appear in the request's Host: header to
        # match this virtual host. For the default virtual host (this file) this
        # value is not decisive as it is used as a last resort host regardless.
        # However, you must set it for any further virtual host explicitly.
        #ServerName www.example.com

        ServerAdmin webmaster@localhost
        DocumentRoot /sites/example.com/html
        ServerName example.com
        ServerAlias www.example.com
        Redirect / https://myotherexample.com/

        <Directory /sites/example.com/html>
                Options FollowSymlinks
                AllowOverride All
                Require all granted
        </Directory>

        SSLEngine on
        SSLCertificateKeyFile /etc/apache2/ssl/example.com.key
        # this ssl is expired now
        SSLCertificateFile /etc/apache2/ssl/example.com.crt
        SSLCertificateChainFile /etc/apache2/ssl/example.com.IntermediateCA.crt

</VirtualHost>

明らかに間違った方法で取り組んでいますが、古いドメインでアクティブな SSL 証明書を保持せずに、Apache を使用して SSL ドメイン (ドメインの https バージョン) を新しいドメインにリダイレクトする方法はありますか? 本当にありがとうございます!

答え1

これは予想通りの動作です。誰かがDNSを乗っ取って301リダイレクトを設定したと想像してください。https://letsencrypt.org/無料の証明書を取得し、古いドメインにアクセスできなくなるまでクライアントをリダイレクトします。

答え2

私はマットの返信に賛成しましたが、もっと明確に述べたいと思います。

リダイレクトは HTTP の一種で、応答ステータス コード (3XX) と特定のヘッダー (Location) のセットとして実装されます。これは通常の HTTP トランザクションです。HTTPS での HTTP は、TLS 接続の確立が成功した後にのみ可能となり、TLS には有効な証明書が必要です。したがって、有効な証明書がない => TLS なし => HTTPS なし => リダイレクトは不可能となります。

期限切れの証明書は無効であるため、証明書が置き換えられるまで、リダイレクトを含め、HTTP 関連の操作は一切実行できません。

関連情報