【发布时间】:2018-08-27 01:38:29
【问题描述】:
我为我的 2 个域 www.example.com 和 example.com
生成了证书以下是 HTTP 和 HTTPS 协议的 .conf 文件:
<VirtualHost *:80>
ServerName example.com
ServerAlias www.example.com
DocumentRoot /var/www/html/funapps
RewriteEngine on
RewriteCond %{SERVER_NAME} =example.com [OR]
RewriteCond %{SERVER_NAME} =www.example.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [NE,R=temp]
</VirtualHost>
在不同的文件中:
<IfModule mod_ssl.c>
<VirtualHost *:443>
ServerName example.com
ServerAlias www.example.com
DocumentRoot /var/www/html/funapps
<Directory /var/www/html>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
RewriteEngine on
RewriteCond %{SERVER_NAME} =example.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
Include /etc/letsencrypt/options-ssl-apache.conf
SSLCertificateFile /etc/letsencrypt/live/www.example.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/www.example.com/privkey.pem
</VirtualHost>
</IfModule>
现在,这发生了:
如果我访问http://example.com 或https://www.example.com,我将分别重定向到https://example.com 和https://www.example.com。但如您所见,我只为 www.example.com 提供了证书,浏览器显示非 www 域的安全警告。
所以基本上,我想知道处理这 2 个域的 2 个证书的更好选择是什么?
- 在同一 HTTPS 虚拟主机部分中为 SSL 证书文件添加 IF / ELSE 条件(我不知道该怎么做)或
- 指定 2 个不同的 HTTPS 虚拟主机包含各自的证书?
【问题讨论】:
标签: apache ssl redirect httpd.conf lets-encrypt