apache - 具有动态 apache vhosts 的非通配符证书

标签 apache ssl vhosts lets-encrypt

我正在尝试根据用于连接到我的服务器的 url 动态读取 SSL 证书的位置。我尝试了几种不同的方法,但似乎都不起作用。目前我有如下所述的配置

UseCanonicalName Off

listen 443

<VirtualHost *:443>
  ServerName example
  ServerAlias *

  SSLEngine on
  SSLCertificateFile /etc/letsencrypt/live/%0/cert.pem
  SSLCertificateKeyFile /etc/letsencrypt/live/%0/privkey.pem

  VirtualDocumentRoot /var/www/vhosts/%-2/%-3+/public
</VirtualHost>

这里的问题是,当我启动 apache 时,我收到一条错误消息,指出它找不到 ssl 证书的文件位置,说明 '/etc/letsencrypt/live/%0/cert.pem'

所以 %0 似乎没有被 url 替换。

编辑:当我只用 url 手动替换 %0 时,然后说 url 有工作 SSL

最佳答案

来自documentation :

The variable %0 references the requested servername, as indicated in the Host: header.

主机 header 是 HTTP 请求的一部分。 HTTP 请求仅在 TLS 握手成功后可用。此握手需要证书。因此,%0 不能用于指定证书的路径。

我怀疑任何其他变量是否可以用于此目的,因为证书是在启动时加载的,因此文件名必须在启动时就已经可用。

关于apache - 具有动态 apache vhosts 的非通配符证书,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41635535/

相关文章:

iOS如何使用SecCertificateCreateWithData

Docker 容器 : Access private endpoint that requires VPN - SSL_ERROR_SYSCALL

非标准端口上的 Apache vhost 配置 - 仅提供第一个 vhost

PHP 命名空间与 Phalcon、Vagrant、Apache2 的冲突

php - 如何在 Ubuntu 22 的 Apache 中使用 Php7.4?

apache - 如何使用 HTACCESS 将特定页面重定向到错误页面

php - 如何在 "Unable to connect Firefox can' t 建立到 '' 一些 ip 的服务器的连接时重定向到另一个本地主机

android - 当我尝试在 Android 设备上访问我的 https 网站时,总是提示我,为什么?

apache - 启动 apache 时出错,httpd : Configuration error: More than one MPM loaded

apache2 - 如何限制apache2中每个虚拟主机的连接数?