Ubuntu - 使用不同证书保护 *.mydomain.com 和 *.sub.mydomain.com 时遇到问题
Ubuntu - trouble securing *.mydomain.com and *.sub.mydomain.com using different certs
我刚刚向我的站点添加了一个子域,并正在尝试使 SSL 正常工作。以前我使用来自 namespace.com.
的证书在 example.net 和 www.example.net 上使用 SSL
有了子域,事情就不太好了。
这是我在 DNS 条目中的内容:
CNAME: www.sub.example.net is an alias of example.net
A: sub.example.net directs to IP
CNAME: www.example.net is an alias of example.net
A: example.net directs to IP
这是我的 example.net 配置文件:
<VirtualHost *:80>
ServerName example.net
Redirect permanent / https://example.net/
</VirtualHost>
<VirtualHost *:443>
ServerName example.net
DocumentRoot "/var/www/example/public"
<Directory "/var/www/example/public">
AllowOverride all
</Directory>
SSLEngine on
SSLCertificateKeyFile /root/example.net.key
SSLCertificateFile /root/example.net.crt
SSLCertificateChainFile /root/example.net.ca-bundle
</VirtualHost>
还有我的 sub.example 配置文件:
<VirtualHost *:80>
ServerName sub.example.net
ServerAlias www.sub.example.net
DocumentRoot /var/www/sub.example
Redirect permanent / https://sub.example.net/
</VirtualHost>
<VirtualHost *:443>
ServerName sub.example.net
ServerAlias www.sub.example.net
DocumentRoot /var/www/sub.example
SSLCertificateFile /etc/letsencrypt/live/sub.example.net/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/sub.example.net/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>
如果我去 sub.example.net
和 www.sub.example.net
那么一切都很好。
如果我去 example.net
一切都很好。
但是,当我转到 www.example.net
时,我收到有关证书仅对 sub.example.net
和 *.sub.example.net
.
有效的错误
所以出于某种原因,example.net
前面的 www
让 apache 不查看我为 example.net
.[=26 使用的 namespace.com 通配符证书=]
现在,我通过
创建了子域证书
sudo certbot certonly --manual -d *.sub.example.net -d sub.example.net --agree-tos --no-bootstrap --manual-public-ip-logging-ok --preferred-challenges dns-01 --server https://acme-v02.api.letsencrypt.org/directory
我感觉我有一些奇怪的 apache conf 设置和 DNS 条目组合导致了这种行为。知道我做错了什么吗?
谢谢,
布莱恩
So for some reason the www in front of example.net is having apache not look at the namespace.com wildcard cert that I have for example.net.
您没有为 www.example.net
定义 ServerAlias,这意味着它将无法找到与域名完全匹配的名称。在这种情况下,它使用配置中的第一个虚拟主机,以您的情况为准。
我刚刚向我的站点添加了一个子域,并正在尝试使 SSL 正常工作。以前我使用来自 namespace.com.
的证书在 example.net 和 www.example.net 上使用 SSL有了子域,事情就不太好了。
这是我在 DNS 条目中的内容:
CNAME: www.sub.example.net is an alias of example.net
A: sub.example.net directs to IP
CNAME: www.example.net is an alias of example.net
A: example.net directs to IP
这是我的 example.net 配置文件:
<VirtualHost *:80>
ServerName example.net
Redirect permanent / https://example.net/
</VirtualHost>
<VirtualHost *:443>
ServerName example.net
DocumentRoot "/var/www/example/public"
<Directory "/var/www/example/public">
AllowOverride all
</Directory>
SSLEngine on
SSLCertificateKeyFile /root/example.net.key
SSLCertificateFile /root/example.net.crt
SSLCertificateChainFile /root/example.net.ca-bundle
</VirtualHost>
还有我的 sub.example 配置文件:
<VirtualHost *:80>
ServerName sub.example.net
ServerAlias www.sub.example.net
DocumentRoot /var/www/sub.example
Redirect permanent / https://sub.example.net/
</VirtualHost>
<VirtualHost *:443>
ServerName sub.example.net
ServerAlias www.sub.example.net
DocumentRoot /var/www/sub.example
SSLCertificateFile /etc/letsencrypt/live/sub.example.net/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/sub.example.net/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>
如果我去 sub.example.net
和 www.sub.example.net
那么一切都很好。
如果我去 example.net
一切都很好。
但是,当我转到 www.example.net
时,我收到有关证书仅对 sub.example.net
和 *.sub.example.net
.
所以出于某种原因,example.net
前面的 www
让 apache 不查看我为 example.net
.[=26 使用的 namespace.com 通配符证书=]
现在,我通过
创建了子域证书sudo certbot certonly --manual -d *.sub.example.net -d sub.example.net --agree-tos --no-bootstrap --manual-public-ip-logging-ok --preferred-challenges dns-01 --server https://acme-v02.api.letsencrypt.org/directory
我感觉我有一些奇怪的 apache conf 设置和 DNS 条目组合导致了这种行为。知道我做错了什么吗?
谢谢, 布莱恩
So for some reason the www in front of example.net is having apache not look at the namespace.com wildcard cert that I have for example.net.
您没有为 www.example.net
定义 ServerAlias,这意味着它将无法找到与域名完全匹配的名称。在这种情况下,它使用配置中的第一个虚拟主机,以您的情况为准。