
RHEL 6에 Apache를 설치했습니다. 모든 것이 잘 작동합니다. 사용하기 위해 수행해야 하는 모든 변경 및 구성 https://localhost:443/.
"Listen 80"을 443으로 변경하면 SSL 연결 오류가 발생합니다.
"오류 107(net::ERR_SSL_PROTOCOL_ERROR): SSL 프로토콜 오류."
답변1
을 사용하는 경우 apache2
다음을 수행해야 합니다.
1 단계:OpenSSL을 사용하여 사이트 보안에 사용되는 키를 생성하세요. 이러한 키는 보안 사이트에 대한 트래픽을 암호화하고 해독할 때 사용됩니다.
$ openssl genrsa -out mydomain.key 1024
이 명령은 1024비트 개인 키를 생성하여 mydomain.key 파일에 저장합니다.
2 단계:자신의 인증서를 생성하십시오.
$ openssl req -new -key mydomain.key -x509 -out mydomain.crt
3단계:개인 키는 디렉터리에 /etc/apache2/ssl.key/
, 인증서는 디렉터리에 보관하세요 /etc/apache2/ssl.crt/
.
메모:디렉토리 ssl.key
는 루트만 읽을 수 있어야 합니다.
4단계:httpd.conf
이제 에서 파일을 편집해야 합니다 /etc/apache2
.
이제 이 파일에는 다음과 같은 콘텐츠가 포함되어야 합니다.
NameVirtualHost *:80
NameVirtualHost *:443
Listen 443
<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot /srv/www/htdocs/mydomain
ServerName www.mydomain.com
ServerAlias mydomain.com
</VirtualHost>
<VirtualHost *:443>
ServerAdmin [email protected]
DocumentRoot /srv/www/htdocs/mydomain-secure
ServerName mail.mydomain.com
SSLEngine on
SSLCertificateFile /etc/apache2/ssl.crt/mydomain.crt
SSLCertificateKeyFile /etc/apache2/ssl.key/mydomain.key
</VirtualHost>
<Directory /srv/www/htdocs/mydomain-secure>
SSLRequireSSL
</Directory>
<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot /srv/www/htdocs/mydomain
ServerName mail.mydomain.com
RedirectMatch permanent (/.*) https://mail.mydomain.com$1
</VirtualHost>
답변2
in Listen 80
으로 변경하지 마세요 . SSL은 에서 구성됩니다 . RHEL 6에서는 SSL이 활성화되어 있으며 기본적으로 자체 서명된 인증서를 통해 수신됩니다.443
/etc/httpd/conf/httpd.conf
/etc/httpd/conf.d/ssl.conf
SSL을 사용하여 탐색만 하면 기본 사이트로 이동할 수 있습니다 https://localhost
(URL 끝에 포트를 추가할 필요는 없습니다).
모든 HTTP 요청을 HTTPS로 전달하려면(귀하가 달성하려는 목표라고 생각됩니다) 영구 리디렉션을 추가하거나 Apache 모듈을 사용할 수 있습니다 mod_rewrite
.
가장 쉽고 안전한 방법은 영구 리디렉션을 설정하는 것입니다. 명명된 가상 호스트를 활성화하고 Redirect
.NET의 VirtualHost에 지시어를 추가합니다 /etc/httpd/conf/httpd.conf
.
NameVirtualHost *:80
<VirtualHost *:80>
ServerName localhost
Redirect permanent / https://localhost
</VirtualHost>
를 사용하면 mod_rewrite
명명된 가상 호스트도 생성할 수 있습니다. 이는 권장되는 방법은 아니지만 작동합니다.
NameVirtualHost *:80
<VirtualHost *:80>
# Enable the Rewrite engine
RewriteEngine On
# Make sure the connection is not already HTTPS
RewriteCond %{HTTPS} !=on
# This rewrites the URL and forwards to https
RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]
</VirtualHost>
SSL을 끄려면 이 줄을 주석 처리 /etc/httpd/conf.d/ssl.conf
하고 Apache를 다시 시작하세요.
LoadModule ssl_module modules/mod_ssl.so
Listen 443