Google Cloud Platform: Cannot get https (SSL) work

2019-04-09 12:47发布

I'm using Apache/2.2.22 (Debian) on Google Compute Engine with a Wordpress Install (click-to-deploy).

I'm trying to setup an SSL certificate (https) for the Wordpress install. I've created a static IP, a private key, a CSR and have uploaded SSL & intermediate crt files (from freeSSL.com) to etc/apache2/ssl (with the private key) and given this folder root:root permission.

I've followed https://www.digitalocean.com/community/tutorials/how-to-create-a-ssl-certificate-on-apache-for-debian-7 and updated default-ssl config file as instructed (updating pathnames to .crt and .key files, ServerName and ServerAdmin).

I ran a configtest (got syntax OK), enabled default-ssl and rebooted apache. When I visit https://domain or https://ip-address, I get a "This Webpage is Unavailable" error (ERR_CONNECTION_CLOSED). The wordpress install still loads ok on http.

The SSL checker at https://www.digicert.com/help/ gives me a "no certificates found" error, although the certificates are there.

2条回答
聊天终结者
2楼-- · 2019-04-09 13:28

Here's what worked for me;

First attempt to enable HTTPS with the checkbox in the Compute | Compute Engine | VM Instances config settings. Should this fail with an error message you can add a firewall rule directly...

On the Compute | Compute Engine | Networks page, select the 'default' network. Then under 'Firewall rules' click 'Add a new rule'. Use the following settings;

Name: allow-https
IP Range: 0.0.0.0/0
Allowed Protocol/Ports: tcp:443
Target tags: http-server

All of the above is assuming that you have exhausted all the other apache configuration options (ports.conf, Virtual Hosts etc).

查看更多
再贱就再见
3楼-- · 2019-04-09 13:32

Here is the solution :

Install VM – WordPress (Solution provided by Google cloud servers), my OS is Debian 7 or Built in Google Wordpress.

Dot forgot to allow firewall at Google cloud console

 Allow HTTP traffic
 Allow HTTPS traffic

Install Open SSH Key and access SSH (maybe using Putty)

Connect/login ssh (using Putty) or other terminal

Change user (SSL terminal)

$ sudo su

now edit by vi/nano

 # nano /etc/apache2/sites-available/default-ssl.conf

add this lines

<Directory /var/www/html/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>

Also all certificate details, which you might need to purchase form provider

SSLCertificateFile /etc/a..../...../..../gulfstatesoftware_com.crt SSLCertificateKeyFile /etc/a..../...../..../gulfstatesoftware_com.key SSLCertificateChainFile /etc/a..../...../..../gulfstatesoftware_com.ca-bundle

and # key which doesn't required.

Save and exit.

Run this commands in terminal :

sudo a2ensite default-ssl
service apache2 reload
sudo a2enmod ssl
service apache2 reload
sudo service apache2 restart

You might wants to fix Permalink : (www.example.com/my-blog-url), thats also in wordpress.conf file.

  1. edit # nano /etc/apache2/sites-available/wordpress.conf Change : AllowOverride All
  2. add .htaccess to /var/www/html

    <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule>

查看更多
登录 后发表回答