我有一个由Google Compute Engine托管的网页,安装了Apache 2.4。我可以按http://1.2.3.4/
确定访问该页面。现在我要启用SSL。我遵循了两个相似的教程here和here。总结一下我所做的:
.crt
和密钥.key
文件。/etc/apache2/sites-available/default-ssl.conf
更改为ServerName
,然后在步骤1中将1.2.3.4
和SSLCertificateFile
更改为证书和密钥文件来编辑文件SSLCertificateKeyFile
。/etc/apache2/sites-available/000-default.conf
中的文件<VirtualHost *:80>
以使其具有与IP相同的ServerName
,然后复制该块,但使用与<VirtualHost *:443>
不同的端口sudo ufw allow 'Apache Full'
允许在防火墙中使用Apache配置文件>sudo a2enmod ssl
启用ssl mod,然后使用sudo a2ensite default-ssl.conf
启用配置sudo service apache2 restart
在Chrome中,当我访问https://1.2.3.4/
或https://1.2.3.4:443/
时,显示为:
此网站无法提供安全的连接
1.2.3.4发送了无效的响应。
尝试运行Windows网络诊断程序。
ERR_SSL_PROTOCOL_ERROR
这是我的
000-default.conf
文件的内容:
<VirtualHost *:80> ServerName 1.2.3.4 ServerAdmin webmaster@localhost DocumentRoot /home/usename/mypage ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined </VirtualHost> <VirtualHost *:443> ServerName 1.2.3.4 ServerAdmin webmaster@localhost DocumentRoot /home/usename/mypage ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined </VirtualHost>
访问
http
链接仍然可以(我没有将HTTP流量重定向到HTTPS)。如何使https工作? (我的Google Compute Engine是Ubuntu 18.04.3)
我有一个由Google Compute Engine托管的网页,安装了Apache 2.4。我可以通过例如http://1.2.3.4/ ok访问该页面。现在我要启用SSL。我遵循了两个类似的...
您需要在VirtualHost(000-default.conf)中添加SSLEngine On
。此伪指令可切换SSL / TLS协议引擎的用法。默认情况下,主服务器和所有已配置的虚拟主机均禁用SSL / TLS协议引擎。