0

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:

  1. Create cert .crt and key .key files.
  2. Edit the file /etc/apache2/sites-available/default-ssl.conf by changing ServerName to 1.2.3.4, then changing SSLCertificateFile and SSLCertificateKeyFile to the cert and key files in step 1.
  3. Edit the file /etc/apache2/sites-available/000-default.conf in the block <VirtualHost *:80> to have the same ServerName as the IP, then replicate that block but with different port as <VirtualHost *:443>
  4. Allow Apache profile in the firewall with this command sudo ufw allow 'Apache Full'
  5. Enable ssl mod with sudo a2enmod ssl, then enable the config with sudo a2ensite default-ssl.conf
  6. 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)

hydradon
  • 101
  • 1
  • 2
  • Does `ServerName` in the certificate that you created match the one in conf file? – mazaneicha May 30 '20 at 15:36
  • @mazaneicha yes, I put in the same IP address of the google vm – hydradon May 30 '20 at 16:51
  • @Pandurang I added `SSLEngine On` in `000-default.conf` and the server couldn't even start. But removing that line then it works again. Please put a proper answer with steps to do, which files to edit. Thanks – hydradon May 31 '20 at 18:19

0 Answers0