AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题 / 895346
Accepted
mlclm
mlclm
Asked: 2018-02-03 04:57:36 +0800 CST2018-02-03 04:57:36 +0800 CST 2018-02-03 04:57:36 +0800 CST

在 apache2 服务器上正确实现 SSL 证书?

  • 772

情况:

我从 namecheap/Comodo 购买了一个多域(它包括 3 个域:主域,例如:maindomain.com和另外两个域:sitea.com和siteb.com)。

到目前为止,我想看看是否只能首先为主站点正确设置证书。

在线阅读不同的教程后,我认为为了在 3 个网站上成功使用 SSL 证书,可能需要编辑的文件列表如下:

/etc/apache2/sites-available/maindomain.com.conf
/etc/apache2/apache2.conf 
/etc/apache2/ports.conf

已下载证书的文件列表:

115155984.ca-bundle
115155984.crt

(请注意文件 115155984.ca-bundle 没有任何扩展名)

现在,看起来该站点maindomain.com似乎指向服务器 IP 地址( 155.133.130.203 )。我不确定为什么。我已maindomain.com.conf在目录中的文件内容下方发布sites-available。有几点可能会改变证书的正确实施。

我的问题如下:

  • 1) 我有一个没有 crt 扩展名的 ca-bundle 文件:我必须手动添加 crt 扩展名吗?
  • 2) 我下载的文件没有得到任何 pem 文件:PEM 文件会在某个时候生成吗?
  • 3) 我的 /etc/hosts 文件是否正确?我添加了多行以确保至少有一个可以解决问题。我敢肯定它包含很多不必要的行。我把它贴在下面。
  • 4)我的证书文件不是名为 maindomain.com.crt 而是有一个随机数,这有关系吗?
  • 5)我在这个过程中早些时候生成的密钥文件没有域扩展名 .com ,它的命名如下: maindomain.key 如果我记得它是与之前的 csr 文件同时生成的(做了那个步骤前一段时间)

/etc/apache2/sites-available/maindomain.com.conf 文件

以下是 sites-available 目录中 maindomain.com.conf 文件的内容:

    <VirtualHost *:80>
            # The ServerName directive sets the request scheme, hostname and port that
            # the server uses to identify itself. This is used when creating
            # redirection URLs. In the context of virtual hosts, the ServerName
            # specifies what hostname must appear in the request's Host: header to
            # match this virtual host. For the default virtual host (this file) this
            # value is not decisive as it is used as a last resort host regardless.
            # However, you must set it for any further virtual host explicitly.
            #ServerName www.example.com

            ServerAdmin webmaster@localhost
            DocumentRoot /var/www/html

            # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
            # error, crit, alert, emerg.
            # It is also possible to configure the loglevel for particular
            # modules, e.g.
            #LogLevel info ssl:warn

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

            # For most configuration files from conf-available/, which are
            # enabled or disabled at a global level, it is possible to
            # include a line for only one particular virtual host. For example the
            # following line enables the CGI configuration for this host only
            # after it has been globally disabled with "a2disconf".
            #Include conf-available/serve-cgi-bin.conf
    </VirtualHost>

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

    <IfModule mod_ssl.c>
        <VirtualHost 155.133.130.203:443>
                ServerAdmin [email protected]
                ServerName maindomain.com
                ServerAlias www.maindomain.com
                DocumentRoot /var/www/html/maindomain.com/
                ErrorLog ${APACHE_LOG_DIR}/error.log
                CustomLog ${APACHE_LOG_DIR}/access.log combined

                SSLEngine on

                SSLCertificateFile /etc/ssl/certs/115155984.crt

                SSLCertificateKeyFile /etc/ssl/private/maindomain.key

                SSLCACertificateFile /etc/ssl/certs/115155984.ca-bundle.crt

                SSLVerifyClient None

                <Directory />
                          Options FollowSymLinks
                          AllowOverride None
                </Directory>
                <Directory /var/www/html/maindomain.com/>
                          Options Indexes FollowSymLinks MultiViews
                          AllowOverride All
                          Order allow,deny
                          allow from all
                </Directory>
        </VirtualHost>
    </IfModule>

/etc/host 文件中的不必要信息

这是我在 /etc/ 中的主机文件的内容。在 PHPMailer 可以从站点发送电子邮件之前,我必须尝试一些不同的事情,因此很可能有很多不必要的行。

    127.0.0.1       localhost
    ::1             localhost ip6-localhost ip6-loopback
    ff02::1         ip6-allnodes
    ff02::2         ip6-allrouters

    155.133.130.203 servername01.maindomain.com
    155.133.130.203 servername01.maindomain.com server01.sitea.com
    127.0.0.1 server01 server01.sitea.com sitea.com
    127.0.0.1 server01 server01.maindomain.com maindomain.com
    155.133.130.203 test.maindomain.com
    155.133.130.203 maindomain.com
    155.133.130.203 sitea.com
linux
  • 1 1 个回答
  • 40 Views

1 个回答

  • Voted
  1. Best Answer
    garethTheRed
    2018-02-03T05:26:55+08:002018-02-03T05:26:55+08:00

    1) 我有一个没有 crt 扩展名的 ca-bundle 文件:我必须手动添加 crt 扩展名吗?

    文件扩展名无关紧要 - 除非您是 Microsoft。对于 Apache,文件扩展名只是较长文件名的一部分,其中包含一个点。

    2) 我下载的文件没有得到任何 pem 文件:PEM 文件会在某个时候生成吗?

    查看您收到的文件的内容(带有cat或) - 如果它们以(或类似)less开头,它们就是 PEM。-----BEGIN CERTIFICATE-----如果它们是二进制文件,则它们不是 PEM。openssl x509 -inform DER -in <file_in_der_format> -out <filename_for_pem_file>您可以使用;转换为 PEM

    3) 我的 /etc/hosts 文件是否正确?我添加了多行以确保至少有一个可以解决问题。我敢肯定它包含很多不必要的行。我把它贴在下面。

    它会起作用,尽管你已经复制了一些。将 IP 地址放在一行上,然后是应该解析为该 IP 的所有名称;

    4)我的证书文件不是名为 maindomain.com.crt 而是有一个随机数,这有关系吗?

    不,它没有。您需要配置 Apache 以查找您的证书和私钥。只要 conf 文件中的条目与文件名和路径匹配,它就可以工作;

    5)我在这个过程中早些时候生成的密钥文件没有域扩展名 .com ,它的命名如下: maindomain.key 如果我记得它是与之前的 csr 文件同时生成的(做了那个步骤前一段时间)

    参见上面 4) 的答案。

    • 3

相关问题

  • Linux 主机到主机迁移

  • 如何在 Linux 机器上找到有关硬件的详细信息?

  • 如何在 Linux 下监控每个进程的网络 I/O 使用情况?

  • 在 RHEL4 上修改 CUPS 中的现有打印机设置

  • 为本地网络中的名称解析添加自定义 dns 条目

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve