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
    • 最新
    • 标签
主页 / unix / 问题 / 784364
Accepted
JAyenGreen
JAyenGreen
Asked: 2024-10-02 11:54:11 +0800 CST2024-10-02 11:54:11 +0800 CST 2024-10-02 11:54:11 +0800 CST

为什么 apache 忽略我的 certbot 证书并将域请求发送到不同的证书?

  • 772

我相信我遇到的两个问题是相关的,但不知道从哪里开始。第一个问题是,当请求解析到我的服务器的特定域时,其在 sites-enabled 中的 conf 文件会被忽略,000-default.conf 也是如此,而是使用按字母顺序排列的第一个 conf,并显示该站点,但浏览器栏中显示的是我请求的域。

这只发生在这个域上,这导致了第二个问题。我有一个多域证书(CA),其中的所有域都按预期显示。我为这个其他域安装了 certbot 证书。当我将 openssl 与这个其他域的域名一起使用时,它会显示多域证书的内容。当我使用 SSL 检查器时,我得到了相同的结果,它指出我输入的域名不包含在证书中。

我注意到,当我在列出 *:443 和 *:80 文件之前执行 apachectl -S 时,它会列出一个以服务器 IP 地址为命名服务器的虚拟主机,并且它列出的第一个文件不是 000-default(它是 *:80 和 *:443 的第一个文件),而是按字母顺序排列的下一个文件。

有问题的域名是 halgrossman.com。

halgrossman.com.conf

<VirtualHost *:80>
    ServerName halgrossman.com
    ServerAlias www.halgrossman.com

    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html/drupal/halgrossman/web
        <Directory /var/www/html/drupal/halgrossman/web>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride All
                Order allow,deny
                allow from all
        </Directory>

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

</VirtualHost>

halgrossman.com-le-ssl.conf

<VirtualHost *:443>
    ServerName halgrossman.com
    ServerAlias www.halgrossman.com

    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html/drupal/halgrossman/web
        <Directory /var/www/html/drupal/halgrossman/web>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride All
                Order allow,deny
                allow from all
        </Directory>

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

Include /etc/letsencrypt/options-ssl-apache.conf
SSLCertificateFile /etc/letsencrypt/live/halgrossman.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/halgrossman.com/privkey.pem
</VirtualHost>

openssl 的输出

openssl s_client -connect halgrossman.com:443 -servername halgrossman.com
CONNECTED(00000003)
depth=2 C = US, ST = New Jersey, L = Jersey City, O = The USERTRUST Network, CN = USERTrust RSA Certification Authority
verify return:1
depth=1 C = GB, ST = Greater Manchester, L = Salford, O = Sectigo Limited, CN = Sectigo RSA Domain Validation Secure Server CA
verify return:1
depth=0 CN = theaccidentalcoder.com
verify return:1
---
Certificate chain
 0 s:CN = theaccidentalcoder.com
   i:C = GB, ST = Greater Manchester, L = Salford, O = Sectigo Limited, CN = Sectigo RSA Domain Validation Secure Server CA
   a:PKEY: rsaEncryption, 2048 (bit); sigalg: RSA-SHA256
   v:NotBefore: Sep  2 00:00:00 2024 GMT; NotAfter: Dec 21 23:59:59 2024 GMT
 1 s:C = GB, ST = Greater Manchester, L = Salford, O = Sectigo Limited, CN = Sectigo RSA Domain Validation Secure Server CA
   i:C = US, ST = New Jersey, L = Jersey City, O = The USERTRUST Network, CN = USERTrust RSA Certification Authority
   a:PKEY: rsaEncryption, 2048 (bit); sigalg: RSA-SHA384
   v:NotBefore: Nov  2 00:00:00 2018 GMT; NotAfter: Dec 31 23:59:59 2030 GMT
 2 s:C = US, ST = New Jersey, L = Jersey City, O = The USERTRUST Network, CN = USERTrust RSA Certification Authority
   i:C = GB, ST = Greater Manchester, L = Salford, O = Comodo CA Limited, CN = AAA Certificate Services
   a:PKEY: rsaEncryption, 4096 (bit); sigalg: RSA-SHA384
   v:NotBefore: Mar 12 00:00:00 2019 GMT; NotAfter: Dec 31 23:59:59 2028 GMT
 3 s:C = GB, ST = Greater Manchester, L = Salford, O = Comodo CA Limited, CN = AAA Certificate Services
   i:C = GB, ST = Greater Manchester, L = Salford, O = Comodo CA Limited, CN = AAA Certificate Services
   a:PKEY: rsaEncryption, 2048 (bit); sigalg: RSA-SHA1
   v:NotBefore: Jan  1 00:00:00 2004 GMT; NotAfter: Dec 31 23:59:59 2028 GMT

theaccidentalcoder.com 是多域 CA 证书上的主要域,halgrossman.com 不属于该域。

SSL 检查器的输出

halgrossman.com resolves to 45.56.118.187
    
Server Type: Apache/2.4.52 (Ubuntu)
    
The certificate should be trusted by all major web browsers (all the correct intermediate certificates are installed).
    
The certificate was issued by Sectigo.    
    
The certificate will expire in 84 days. 
    
None of the common names in the certificate match the name that was entered (halgrossman.com). You may receive an error when accessing this site in a web browser. Learn more about name mismatch errors.
    Common name: theaccidentalcoder.com
SANs: theaccidentalcoder.com, ascaatl.org, guildbuildersinc.com, musictohealby.com, souknook.com, thetouristlife.com
Valid from September 1, 2024 to December 21, 2024

apache2ctl -S 的输出

45.56.118.187:443      is a NameVirtualHost
         default server guildbuildersinc.com (/etc/apache2/sites-enabled/guildbuildersinc.com.conf:37)
         port 443 namevhost guildbuildersinc.com (/etc/apache2/sites-enabled/guildbuildersinc.com.conf:37)
         port 443 namevhost musictohealby.com (/etc/apache2/sites-enabled/musictohealby.com.conf:37)
         port 443 namevhost theaccidentalcoder.com (/etc/apache2/sites-enabled/theaccidentalcoder.com.conf:23)
         port 443 namevhost thetouristlife.com (/etc/apache2/sites-enabled/thetouristlife.com.conf:21)
*:443                  halgrossman.com (/etc/apache2/sites-enabled/halgrossman.com-le-ssl.conf:2)
*:80                   is a NameVirtualHost
         default server halgrossman.com (/etc/apache2/sites-enabled/00-default.conf:1)
         port 80 namevhost halgrossman.com (/etc/apache2/sites-enabled/00-default.conf:1)
                 alias www.halgrossman.com
         port 80 namevhost default (/etc/apache2/sites-enabled/000-default.conf:1)
         port 80 namevhost guildbuildersinc.com (/etc/apache2/sites-enabled/guildbuildersinc.com.conf:1)
                 alias www.guildbuildersinc.com
         port 80 namevhost halgrossman.com (/etc/apache2/sites-enabled/halgrossman.com.conf:1)
                 alias www.halgrossman.com
         port 80 namevhost musictohealby.com (/etc/apache2/sites-enabled/musictohealby.com.conf:1)
                 alias www.musictohealby.com
         port 80 namevhost theaccidentalcoder.com (/etc/apache2/sites-enabled/theaccidentalcoder.com.conf:1)
                 alias www.theaccidentalcoder.com
         port 80 namevhost thetouristlife.com (/etc/apache2/sites-enabled/thetouristlife.com.conf:1)
ServerRoot: "/etc/apache2"
Main DocumentRoot: "/var/www/html"

请注意,首先出现的域名列表是针对 IP 列出的,不包括 000-default。它首先列出的域名 guildbuildersinc.com 是按字母顺序在 000-default 之后的第一个域名,也是请求https://halgrossman.com时出现的站点。

apache-httpd
  • 1 1 个回答
  • 27 Views

1 个回答

  • Voted
  1. Best Answer
    JAyenGreen
    2024-10-03T21:09:55+08:002024-10-03T21:09:55+08:00

    在这种情况下,事实证明多域证书中域的 conf 文件有一个 443 条目:

    <VirtualHost thedomainname:443>
    

    而不是

    <VirtualHost *:443>
    

    因此,Apache 会在第一个这样编码的文件处停止。当我按字母顺序修复第一个文件时,它会在下一个文件处停止并返回该站点,依此类推。更改所有 .conf 文件以使其包含正确的行,解决了该问题。

    • 0

相关问题

  • 由于密码,httpd 服务器不兼容

  • Apache 日志 - X-Forwarded-for 与 Virtualhost 一起不记录

  • Apache Common Document root ,不同的虚拟主机,不同的可访问文件

  • apache httpd 指定 CipherSuite

  • 带有 apache2 配置路径错误的 SVN

Sidebar

Stats

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

    模块 i915 可能缺少固件 /lib/firmware/i915/*

    • 3 个回答
  • Marko Smith

    无法获取 jessie backports 存储库

    • 4 个回答
  • Marko Smith

    如何将 GPG 私钥和公钥导出到文件

    • 4 个回答
  • Marko Smith

    我们如何运行存储在变量中的命令?

    • 5 个回答
  • Marko Smith

    如何配置 systemd-resolved 和 systemd-networkd 以使用本地 DNS 服务器来解析本地域和远程 DNS 服务器来解析远程域?

    • 3 个回答
  • Marko Smith

    dist-upgrade 后 Kali Linux 中的 apt-get update 错误 [重复]

    • 2 个回答
  • Marko Smith

    如何从 systemctl 服务日志中查看最新的 x 行

    • 5 个回答
  • Marko Smith

    Nano - 跳转到文件末尾

    • 8 个回答
  • Marko Smith

    grub 错误:你需要先加载内核

    • 4 个回答
  • Marko Smith

    如何下载软件包而不是使用 apt-get 命令安装它?

    • 7 个回答
  • Martin Hope
    user12345 无法获取 jessie backports 存储库 2019-03-27 04:39:28 +0800 CST
  • Martin Hope
    Carl 为什么大多数 systemd 示例都包含 WantedBy=multi-user.target? 2019-03-15 11:49:25 +0800 CST
  • Martin Hope
    rocky 如何将 GPG 私钥和公钥导出到文件 2018-11-16 05:36:15 +0800 CST
  • Martin Hope
    Evan Carroll systemctl 状态显示:“状态:降级” 2018-06-03 18:48:17 +0800 CST
  • Martin Hope
    Tim 我们如何运行存储在变量中的命令? 2018-05-21 04:46:29 +0800 CST
  • Martin Hope
    Ankur S 为什么 /dev/null 是一个文件?为什么它的功能不作为一个简单的程序来实现? 2018-04-17 07:28:04 +0800 CST
  • Martin Hope
    user3191334 如何从 systemctl 服务日志中查看最新的 x 行 2018-02-07 00:14:16 +0800 CST
  • Martin Hope
    Marko Pacak Nano - 跳转到文件末尾 2018-02-01 01:53:03 +0800 CST
  • Martin Hope
    Kidburla 为什么真假这么大? 2018-01-26 12:14:47 +0800 CST
  • Martin Hope
    Christos Baziotis 在一个巨大的(70GB)、一行、文本文件中替换字符串 2017-12-30 06:58:33 +0800 CST

热门标签

linux bash debian shell-script text-processing ubuntu centos shell awk ssh

Explore

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

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve