好的,所以我以前没有使用 SSL/HTTPS 的经验,我只处理过标准的 HTTP。最近我开始在一个需要 SSL 的网站上工作。所以当然,我已经出去研究了如何开始。我已经到了成功安装 SSL 证书的阶段 - 出现绿色挂锁,服务器响应端口 443 上的 HTTPS 请求。我遇到的问题是,无论我做什么,我都无法使用 HTTPS/ SSL,但是它们在端口 80/HTTP 上看起来很好(直到我将 HTTP 重定向到 HTTPS)。
简而言之,我完全可以访问 HTTPS 站点,但是我的页面没有被发送,而是为每个请求发送 404。
<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 …Run Code Online (Sandbox Code Playgroud) configuration https http-status-code-404 apache-2.4 raspbian