
그래서 예전에 제가 사용했던https://example.com. 그런 다음 사용하기로 결정했습니다.https://myotherexample.comexample.com 대신. 그래서 서버를 설정하고 해당 서버에 DNS를 지정했는데 모든 것이 훌륭했습니다. 이제 리디렉션하고 싶었습니다.https://example.com에게https://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
나는 Matt의 답변에 찬성표를 던졌지만 더 명확하게 말하고 싶습니다.
리디렉션은 응답 상태 코드(3XX)와 특정 헤더(위치) 집합으로 구현되는 HTTP 항목입니다. 이는 일반적인 HTTP 트랜잭션입니다. HTTPS의 HTTP는 TLS 연결이 성공적으로 설정된 후에만 가능하며 TLS에는 유효한 인증서가 필요합니다. 따라서 유효한 인증서 없음 => TLS 없음 => HTTPS 없음 => 리디렉션이 불가능합니다.
만료된 인증서는 유효하지 않으므로 인증서가 교체될 때까지 리디렉션을 포함하여 HTTP와 같은 작업을 수행할 수 없습니다.