I have a webpage hosted from a Google Compute Engine, with Apache 2.4 installed. I can access the page at, for example, http://1.2.3.4/
ok. Now I want to enable SSL. I have followed two similar tutorials here and here. To summarize what I did:
- Create cert
.crt
and key.key
files. - Edit the file
/etc/apache2/sites-available/default-ssl.conf
by changingServerName
to1.2.3.4
, then changingSSLCertificateFile
andSSLCertificateKeyFile
to the cert and key files in step 1. - Edit the file
/etc/apache2/sites-available/000-default.conf
in the block<VirtualHost *:80>
to have the sameServerName
as the IP, then replicate that block but with different port as<VirtualHost *:443>
- Allow Apache profile in the firewall with this command
sudo ufw allow 'Apache Full'
- Enable ssl mod with
sudo a2enmod ssl
, then enable the config withsudo a2ensite default-ssl.conf
- Restart the server
sudo service apache2 restart
In Chrome, when I access https://1.2.3.4/
or https://1.2.3.4:443/
, it shows something like:
This site can’t provide a secure connection
1.2.3.4 sent an invalid response.
Try running Windows Network Diagnostics.
ERR_SSL_PROTOCOL_ERROR
Here is the content of my 000-default.conf
file:
<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>
Accessing the http
link is still ok (I did not redirect the HTTP traffic to HTTPS). How do I make https work? (My Google Compute Engine is Ubuntu 18.04.3)