4.3. 使用自定义 SSL 证书配置 Capsule 服务器,以便在没有 Puppet 的情况下进行负载平衡

下面的部分论述了如何配置使用自定义 SSL 证书进行负载平衡的胶囊服务器,而无需 Puppet。

4.3.1. 为 Capsule 服务器创建自定义 SSL 证书

此流程概述了如何为证书签名请求创建配置文件,并将负载均衡器和 Capsule 服务器作为 Subject Alternative Names (SAN)包含。在您要为负载均衡配置的每个 Capsule 服务器上完成这个步骤。

流程

  1. 要存储所有源证书文件,请创建一个只能被 root 用户访问的目录:

    # mkdir /root/capsule_cert
  2. 创建为证书签名请求(CSR)签名的私钥。

    请注意,私钥必须未加密。如果您使用密码保护的私钥,请删除私钥密码。

    如果您已有此胶囊服务器的私钥,请跳过这一步。

    # openssl genrsa -out /root/capsule_cert/capsule_cert_key.pem 4096
  3. 为 CSR 创建 /root/capsule_cert/openssl.cnf 配置文件并包含以下内容:

    [ req ]
    req_extensions = v3_req
    distinguished_name = req_distinguished_name
    x509_extensions = usr_cert
    prompt = no
    
    [ req_distinguished_name ]
    commonName = capsule.example.com 1
    
    [ v3_req ]
    basicConstraints = CA:FALSE
    keyUsage = digitalSignature, nonRepudiation, keyEncipherment, dataEncipherment
    extendedKeyUsage = serverAuth, clientAuth, codeSigning, emailProtection
    subjectAltName = @alt_names
    
    [alt_names] 2
    DNS.1 = loadbalancer.example.com
    DNS.2 = capsule.example.com
    1
    证书的通用名称必须与 Capsule 服务器的 FQDN 匹配。在您为负载平衡配置的每个胶囊服务器上运行 命令时,确保更改此设置。您还可以设置通配符值 *。如果设置通配符值,您必须在使用 katello-certs-check 命令时添加 -t capsule 选项。
    2
    [alt_names] 下,将负载均衡器的 FQDN 包含为 DNS.1,并将胶囊服务器的 FQDN 作为 DNS.2
  4. 可选: 如果要向 CSR 添加可辨识名称(DN)详情,请在 [ req_distinguished_name ] 部分添加以下信息:

    [req_distinguished_name]
    CN = capsule.example.com
    countryName =My_Country_Name 1
    stateOrProvinceName = My_State_Or_Province_Name 2
    localityName = My_Locality_Name 3
    organizationName = My_Organization_Or_Company_Name
    organizationalUnitName = My_Organizational_Unit_Name 4
    1
    两个字母代码
    2
    全名
    3
    全名(例如:New York)
    4
    负责证书的部门(示例:IT 部门)
  5. 生成 CSR:

    # openssl req -new \
    -key /root/capsule_cert/capsule_cert_key.pem \ 1
    -config /root/capsule_cert/openssl.cnf \ 2
    -out /root/capsule_cert/capsule_cert_csr.pem 3
    1
    私钥的路径
    2
    配置文件的路径
    3
    要生成的 CSR 的路径
  6. 将证书签名请求发送到证书颁发机构(CA)。同一 CA 必须为 Satellite 服务器和 Capsule 服务器签名证书。

    提交请求时,指定证书的寿命。发送证书请求的方法会有所不同,因此请查阅 CA 查看首选方法。为了响应请求,您可以在单独的文件中接收 CA 捆绑包和签名证书。

  7. 将您从证书颁发机构接收的证书颁发机构和胶囊服务器证书文件复制到您的 Satellite 服务器。
  8. 在 Satellite 服务器上,验证 Capsule 服务器证书输入文件:

    # katello-certs-check \
    -c /root/capsule_cert/capsule_cert.pem \ 1
    -k /root/capsule_cert/capsule_cert_key.pem \ 2
    -b /root/capsule_cert/ca_cert_bundle.pem 3
    1
    由您的证书颁发机构提供的 Capsule 服务器证书文件
    2
    用于为证书签名的 Capsule 服务器私钥
    3
    由您的证书颁发机构提供的证书颁发机构捆绑包

    如果将 commonName= 设置为通配符值,您必须将 -t Capsule 选项添加到 katello-certs-check 命令中。

    保留示例 Capsule -certs-generate 命令的副本,该命令由 katello-certs-check 命令输出,以便为此胶囊服务器创建证书归档文件。

4.3.2. 使用自定义 SSL 证书配置 Capsule 服务器,以便在没有 Puppet 的情况下进行负载平衡

下面的部分论述了如何配置使用自定义 SSL 证书进行负载平衡的胶囊服务器,而无需 Puppet。在您要为负载均衡配置的每个 Capsule 服务器上完成这个步骤。

流程

  1. 将以下选项附加到从 katello -certs-check 命令的输出中获取的 Capsule-certs-generate 命令中:

    --foreman-proxy-cname loadbalancer.example.com
  2. 在 Satellite 服务器上,输入 Capsule -certs-generate 命令来生成 Capsule 证书:

    # capsule-certs-generate \
    --certs-tar /root/capsule_cert/capsule.tar \
    --foreman-proxy-cname loadbalancer.example.com \
    --foreman-proxy-fqdn capsule.example.com \
    --server-ca-cert /root/capsule_cert/ca_cert_bundle.pem \
    --server-cert /root/capsule_cert/capsule.pem \
    --server-key /root/capsule_cert/capsule.pem

    从输出保留示例 satellite-installer 命令的副本,用于安装 Capsule 服务器证书。

  3. 将证书存档文件从 Satellite 服务器复制到 Capsule 服务器:

    # scp /root/capsule.example.com-certs.tar root@capsule.example.com:capsule.example.com-certs.tar
  4. 将以下选项附加到您从 Capsule- certs-generate 命令的输出中获取的 satellite- installer 命令中:

    --certs-cname "loadbalancer.example.com" \
    --enable-foreman-proxy-plugin-remote-execution-script
  5. 在 Capsule 服务器上,输入 satellite-installer 命令:

    # satellite-installer --scenario capsule \
    --certs-cname "loadbalancer.example.com" \
    --certs-tar-file "capsule.example.com-certs.tar" \
    --enable-foreman-proxy-plugin-remote-execution-script \
    --foreman-proxy-foreman-base-url "https://satellite.example.com" \
    --foreman-proxy-oauth-consumer-key "oauth key" \
    --foreman-proxy-oauth-consumer-secret "oauth secret" \
    --foreman-proxy-register-in-foreman "true" \
    --foreman-proxy-trusted-hosts "satellite.example.com" \
    --foreman-proxy-trusted-hosts "capsule.example.com"