如何基于请求域动态设置SSL证书?
我正在尝试使用SSL设置动态apache虚拟主机配置 假设我有3个域example1.com、example2.com和example3.com,它们的项目文件夹位于/var/www/html/如何基于请求域动态设置SSL证书?,ssl,apache2,apache2.4,Ssl,Apache2,Apache2.4,我正在尝试使用SSL设置动态apache虚拟主机配置 假设我有3个域example1.com、example2.com和example3.com,它们的项目文件夹位于/var/www/html/ 例如 example1.com-/var/www/html/example1/ example2.com-/var/www/html/example2/ example3.com-/var/www/html/example3/ 我已将apache配置为从域设置UseCononicalName到Off形成
例如
example1.com-/var/www/html/example1/
example2.com-/var/www/html/example2/
example3.com-/var/www/html/example3/ 我已将apache配置为从域设置UseCononicalName到Off形成自引用URL。参考这份文件。 我的脸看起来像这样
UseCanonicalName Off
VirtualDocumentRoot /var/www/html/%1
<Directory /var/www/html>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
Require all granted
</Directory>
它吐了出来
SSLCertificateFile: file '/home/abc/certs/%1/domain.crt' does not exist or is empty
我怎样才能解决这个问题?有没有办法从数据库设置ssl
问题2\
使用上述vhost配置后,apache无法映射专用服务器名称
UseCanonicalName Off
VirtualDocumentRoot /var/www/html/%1
<Directory /var/www/html>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
Require all granted
</Directory>
<VirtualHost *:80>
ServerName dev.example.com
DocumentRoot /var/www/html/devportal
<Directory "/var/www/html/devportal">
Options Indexes FollowSymLinks Multiviews
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
useCononicalName关闭
VirtualDocumentRoot/var/www/html/%1
选项索引跟随符号链接多视图
允许超越所有
命令允许,拒绝
通融
要求所有授权
ServerName dev.example.com
DocumentRoot/var/www/html/devportal
选项索引跟随符号链接多视图
允许超越所有
要求所有授权
上面的VirtualDocumentRoot覆盖其他virutalhost块。当我尝试将VirtualDocumentRoot封装在VirtualHost块中时,dev.example.com可以工作,但其他域指向默认的apache html。
我不知道我犯了什么错误
SSLCertificateFile /home/abc/certs/%1/domain.crt
这是办不到的。它需要有一个静态路径名,因为证书是在启动时加载的,而不是在TLS握手时加载的。有什么方法可以动态加载SSL吗?apache是否提供其他解决方案?@Abishek:据我所知,您无法动态加载证书。您需要在配置中静态地包括所有域。但是如果所有的名字都知道,你就可以创建包含多个名字的证书。我不知道域名,这就是我想让它动态的原因。无论如何,谢谢你的回答。
SSLCertificateFile /home/abc/certs/%1/domain.crt