简体   繁体   中英

Secure Connection Failed for website https://example.com but works fine for http://example.com

I have apache2 running. I also ran:

sudo a2enmod ssl

I cannot load my website using https, but it is fine with regular http. In Firefox:

SSL_ERROR_RX_RECORD_TOO_LONG 

In Chrome:

ERR_SSL_PROTOCOL_ERROR

netstat -lp:

Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 *:ssh                   *:*                     LISTEN      168/sshd
tcp6       0      0 [::]:http               [::]:*                  LISTEN      2021/apache2
tcp6       0      0 [::]:ssh                [::]:*                  LISTEN      168/sshd
tcp6       0      0 [::]:https              [::]:*                  LISTEN      2021/apache2
Active UNIX domain sockets (only servers)
Proto RefCnt Flags       Type       State         I-Node   PID/Program name    Path
unix  2      [ ACC ]     STREAM     LISTENING     139167163 1/init              /run/systemd/private
unix  2      [ ACC ]     SEQPACKET  LISTENING     139167175 1/init              /run/udev/control
unix  2      [ ACC ]     STREAM     LISTENING     139167182 1/init              /run/systemd/journal/stdout

/etc/apache2/sites-available/000-default.conf

<VirtualHost *:80>
        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/html/example-dot-com/build

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

        Redirect permanent / https://example.com/

</VirtualHost>

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet

/etc/apache2/sites-available/default-ssl.conf:

<IfModule mod_ssl.c>
        <VirtualHost _default_:443>
                ServerAdmin webmaster@localhost

                DocumentRoot /var/www/html/example-dot-com/build

                ErrorLog ${APACHE_LOG_DIR}/error.log
                CustomLog ${APACHE_LOG_DIR}/access.log combined

                SSLEngine on

                SSLCertificateFile /var/www/website_ssl_files/example.com.crt
                SSLCertificateKeyFile /var/www/website_ssl_files/example.com.key
                SSLCertificateChainFile /var/www/website_ssl_files/example.com-starfield.crt

                <FilesMatch "\.(cgi|shtml|phtml|php)$">
                                SSLOptions +StdEnvVars
                </FilesMatch>
                <Directory /usr/lib/cgi-bin>
                                SSLOptions +StdEnvVars
                </Directory>

        </VirtualHost>
</IfModule>

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet

apachectl -S:

VirtualHost configuration:
*:80                   server.example.com (/etc/apache2/sites-enabled/000-default.conf:1)
ServerRoot: "/etc/apache2"
Main DocumentRoot: "/var/www/html"
Main ErrorLog: "/var/log/apache2/error.log"
Mutex ssl-cache: using_defaults
Mutex default: dir="/var/lock/apache2" mechanism=fcntl
Mutex watchdog-callback: using_defaults
Mutex ssl-stapling-refresh: using_defaults
Mutex ssl-stapling: using_defaults
PidFile: "/var/run/apache2/apache2.pid"
Define: DUMP_VHOSTS
Define: DUMP_RUN_CFG
User: name="www-data" id=33
Group: name="www-data" id=33

netstat -lntp:

Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      168/sshd
tcp6       0      0 :::80                   :::*                    LISTEN      2446/apache2
tcp6       0      0 :::22                   :::*                    LISTEN      168/sshd
tcp6       0      0 :::443                  :::*                    LISTEN      2446/apache2
tcp6       0      0 :::443                  :::*                    LISTEN      2446/apache2
tcp6       0      0 :::443                  :::*                    LISTEN      2446/apache2

I am running a Linux VSP using Ubuntu 16.04 Server version: Apache/2.4.18 (Ubuntu)

I followed this site: https://www.linode.com/docs/security/ssl/ssl-apache2-debian-ubuntu/#configure-apache-to-use-the-ssl-certificate

I created the following file, /etc/apache2/sites-available/example.com.conf :

<IfModule mod_ssl.c>
        <VirtualHost *:443>
                SSLEngine On

                SSLCertificateFile /var/www/website_ssl_files/example.com.crt
                SSLCertificateKeyFile /var/www/website_ssl_files/example.com.key
                SSLCertificateChainFile /var/www/website_ssl_files/example.com-starfield.crt

                ServerAdmin person@example.com
                ServerName myserver.example.com
                ServerAlias example.com
                        DocumentRoot /var/www/html/example-dot-com/build
                ErrorLog ${APACHE_LOG_DIR}/error.log
                CustomLog ${APACHE_LOG_DIR}/access.log combined
        </VirtualHost>
</IfModule>

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM