좋아, 그래서 나는 이전에 SSL / HTTPS에 대한 경험이 없었으며, 표준 HTTP 만 다루었습니다. 최근에 SSL이 필요한 사이트에서 작업을 시작했습니다. 물론, 나는 나가서 시작하는 방법을 연구했습니다. SSL 인증서를 성공적으로 설치하는 단계에 도달했습니다. 녹색 자물쇠가 나타나고 서버가 포트 443에서 HTTPS 요청에 응답합니다. 내가 가진 문제는 내가 무엇을하든 HTTPS / 그러나 SSL은 포트 80 / HTTP에서 정상적으로 나타납니다 (HTTP를 HTTPS로 리디렉션 할 때까지).
간단히 말해서 HTTPS 사이트에 절대적으로 액세스 할 수는 있지만 페이지가 전송되지 않고 모든 요청에 대해 404가 전송됩니다.
/etc/apache2/sites-available/[name].conf
<VirtualHost *:80>
ServerName [serverName]
RewriteEngine On
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=302]
</VirtualHost>
<VirtualHost *:443>
ServerName [serverName]
ServerAdmin [email]
DocumentRoot [docRoot]
# I know the following SSL cert stuff is correct
SSLEngine On
SSLCertificateFile [...]/[domain].crt
SSLCertificateKeyFile [...]/[certificate].key
SSLCertificateChainFile [...]/[theotherone].crt
ErrorLog ${APACHE_LOG_DIR}/[custom]_error.log
CustomLog ${APACHE_LOG_DIR}/[custom]_access.log combined
<Directory "[docRoot]">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
</VirtualHost>
보고 싶은 것이 있거나 다른 세부 사항이 있는지 확실하지 않지만 알려주세요.
편집하다:
구성 파일에서 일부 검색을 한 후 HTTPS에 연결할 때 서버가 기본 구성 (/ var / www /)에서 문서 루트를 사용하지만이 기본 구성은 a2ensite에서 사용하도록 설정되지 않았습니다. 이것을 일으키는 구성이 어디에 있는지 알 수없는 것 같습니다.
답변
모든 http 요청을 https로 리디렉션해야합니까? 그게 당신이 여기서하려고하는 것 같습니다.
conf에서 다음 줄을 제거하여 시작하는 것이 좋습니다.
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=302]
구문이 잘못되었을 수 있습니다. 그런 다음 각 http : // 및 https : // 프로토콜에서 다시 연결하십시오.
답변
내가 어떻게 알아 냈는지 정확하게 기억할 수는 없지만 제안하는 곳을 우연히 발견했습니다.
<VirtualHost _default_:443>
대신에:
<VirtualHost *:443>
이를 대체 한 이후 SSL이 완벽하게 작동했습니다.
답변
다음과 같이 파일을 편집하십시오.
이것이 여전히 필요한 경우 리디렉션을 추가하면 매우 기본적인 conf입니다.
이것이 작동하지 않으면 ssl.conf를 보여주십시오
NameVirtualHost *:80
NameVirtualHost *:443
<VirtualHost *:80>
<Directory "[docRoot]">
AllowOverride All
</Directory>
DocumentRoot [docRoot]
ServerName [serverName]
</VirtualHost>
<VirtualHost *:443>
SSLEngine on
SSLCertificateFile [...]/[domain].crt
SSLCertificateKeyFile [...]/[certificate].key
SSLCertificateChainFile [...]/[theotherone].crt
<Directory "[docRoot]">
AllowOverride All
</Directory>
DocumentRoot [docRoot]
ServerName [serverName]
</VirtualHost>