Apache 配置

Apache 配置

我已经从 namecheap.com 购买了 SSL 证书。我正尝试将其安装在运行 Ubuntu 14.04 和 Apache 的服务器上。我使用以下教程来设置 Apachehttps://www.digitalocean.com/community/tutorials/how-to-set-up-apache-virtual-hosts-on-ubuntu-14-04-lts。服务器有一个仅在 HTTP 上运行的预先存在的站点。

该网站使用两个子域名 admin.example.com 和 api.example.com,因此我购买了通配符证书。

我已经根据证书颁发机构安装了证书,并修改了 Apache 配置 example.com.conf 以添加 SSL 虚拟主机,但我仍然希望非 HTTPS 页面能够正常工作,因此我保留了现有的端口 80 配置并在下面添加了新的虚拟主机主机配置。

我重新启动了 Apache 并尝试通过 https 查看页面,但 Firefox 给出了以下错误代码(Error code: ssl_error_rx_record_too_long)

我尝试了这篇文章中提到的修复方法,但没有成功https://www.digicert.com/ssl-support/apache-fix-common-ssl-errors.htm#SSLRecordLength

我还检查了防火墙是否打开了 443 端口。

Apache 配置

<VirtualHost *:80>
    ServerAdmin [email protected]
    ServerName example.com
    ServerAlias www.example.com api.example.com admin.example.com

    DocumentRoot /var/www/example.com/public/

    <Directory "/var/www/example.com/public/">
            Options Indexes FollowSymLinks
            AllowOverride None
            Order deny,allow
            Allow from all
            Satisfy all

            IndexIgnore */*
            RewriteEngine on
            # if a directory or a file exists, use it directly
            RewriteCond %{REQUEST_FILENAME} !-f
            RewriteCond %{REQUEST_FILENAME} !-d

            # otherwise forward it to index.php
            RewriteRule . index.php
    </Directory>

    # Possible values include: debug, info, notice, warn, error, crit,
    # alert, emerg.
    LogLevel warn

    #ErrorLog "/var/www/example.com/protected/runtime/apache-error.log"
    #CustomLog "/var/www/example.com/protected/runtime/access.log" common

</VirtualHost>

<VirtualHost *:433>

#SSL certificate
        SSLEngine On
        SSLCertificateFile /etc/apache2/ssl/STAR.example.com.crt
        SSLCertificateKeyFile /etc/apache2/ssl/*.example.com.key
        SSLCACertificateFile /etc/apache2/ssl/STAR.example.com.ca-bundle.crt

    ServerAdmin [email protected]
    ServerName example.com
    ServerAlias www.example.com api.example.com admin.example.com

    DocumentRoot /var/www/example.com/public/

    <Directory "/var/www/example.com/public/">
            Options Indexes FollowSymLinks
            AllowOverride None
            Order deny,allow
            Allow from all
            Satisfy all

            IndexIgnore */*
            RewriteEngine on
            # if a directory or a file exists, use it directly
            RewriteCond %{REQUEST_FILENAME} !-f
            RewriteCond %{REQUEST_FILENAME} !-d

            # otherwise forward it to index.php
            RewriteRule . index.php
    </Directory>

    # Possible values include: debug, info, notice, warn, error, crit,
    # alert, emerg.
    LogLevel warn

    ErrorLog "/var/www/example.com/protected/runtime/apache-error.log"
    CustomLog "/var/www/example.com/protected/runtime/access.log" combined

</VirtualHost>

Apache 详细信息

$ apache2 -v
Server version: Apache/2.4.7 (Ubuntu)
Server built:   Jul 22 2014 14:36:38

答案1

那么你的问题如下:

<VirtualHost *:433>

将其改为 443。

相关内容