我有一个安装了LetsEncrypt证书和apache conf设置的域,用于将www转发到非www并将non-ssl转发到ssl。一切正常,直到我决定添加一个子域并尝试生成一个新证书来覆盖这两个域。
现在,当我运行certbot时,将得到以下输出:
root@arthas:~# certbot
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator apache, Installer apache
Which names would you like to activate HTTPS for?
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1: domain.com
2: playground.domain.com
3: www.playground.domain.com
4: www.domain.com
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Select the appropriate numbers separated by commas and/or spaces, or leave input
blank to select all options shown (Enter 'c' to cancel): 1,2,3,4
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
You have an existing certificate that contains a portion of the domains you
requested (ref: /etc/letsencrypt/renewal/domain.com.conf)
It contains these names: domain.com, www.domain.com
You requested these names for the new certificate: domain.com,
playground.domain.com, www.playground.domain.com, www.domain.com.
Do you want to expand and replace this existing certificate with the new
certificate?
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(E)xpand/(C)ancel: e
Renewing an existing certificate
Performing the following challenges:
http-01 challenge for domain.com
http-01 challenge for playground.domain.com
http-01 challenge for www.domain.com
http-01 challenge for www.playground.domain.com
Waiting for verification...
Cleaning up challenges
Deploying Certificate to VirtualHost /etc/apache2/sites-enabled/000-default-le-ssl.conf
Created an SSL vhost at /etc/apache2/sites-enabled/000-default-le-ssl.conf
Deploying Certificate to VirtualHost /etc/apache2/sites-enabled/000-default-le-ssl.conf
Deploying Certificate to VirtualHost /etc/apache2/sites-enabled/000-default-le-ssl.conf
An unexpected error occurred:
ValueError: Unable to set value to path!
Please see the logfiles in /var/log/letsencrypt for more details.
IMPORTANT NOTES:
- Unable to install the certificate
- Congratulations! Your certificate and chain have been saved at /etc/letsencrypt/live/domain.com/fullchain.pem
Your key file has been saved at: /etc/letsencrypt/live/domain.com/privkey.pem
Your cert will expire on 2019-07-19.
To obtain a new or tweaked version of this certificate in the future, simply run certbot again with the "certonly" option.
To non-interactively renew *all* of your certificates, run "certbot renew"
- Some rewrite rules copied from /etc/apache2/sites-enabled/000-default.conf were disabled in the vhost for your HTTPS site located at /etc/apache2/sites-enabled/000-default-le-ssl.conf because they have the potential to create redirection loops.
此外,我还复制了下面的000-default.conf文件的内容:
# Added to mitigate CVE-2017-8295 vulnerability
UseCanonicalName On
<VirtualHost *:80>
ServerAdmin webmaster@localhost
ServerName domain.com
ServerAlias www.domain.com
DocumentRoot /var/www/html
<Directory /var/www/html/>
Options FollowSymLinks
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
RewriteEngine on
RewriteCond %{SERVER_NAME} =www.domain.com [OR]
RewriteCond %{SERVER_NAME} =domain.com [OR]
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
<VirtualHost *:80>
ServerAdmin webmaster@localhost
ServerName playground.domain.com
ServerAlias www.playground.domain.com
DocumentRoot /var/www/html/playground
<Directory /var/www/html/playground>
Options FollowSymLinks
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
RewriteEngine on
RewriteCond %{SERVER_NAME} =www.playground.domain.com [OR]
RewriteCond %{SERVER_NAME} =playground.domain.com [OR]
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
答案 0 :(得分:0)
您似乎有几个.conf
文件可能会引起冲突。
VirtualHost *:80>
和<VirtualHost *:443>
相同配置文件中的规则Include /path/to/httpd-le-ssl.conf
添加到
000-default.conf 运行$ sudo certbot renew --dry-run
来检查修改后的配置是成功还是失败。
在进行故障排除和修复配置时,使用--dry-run
不会影响您的限制。成功完成后,您可以再次运行renew
命令,而无需使用--dry-run
答案 1 :(得分:0)
一次尝试为多个域安装证书时,出现相同的错误消息。如果所有VirtualHost都位于同一配置文件中,并且不想分开它们,请尝试分别为域安装证书。
示例:
当您需要为以下域安装证书
在步骤
Select the appropriate numbers separated by commas and/or spaces, or leave input blank to select all options shown (Enter 'c' to cancel): 1,2,3,4
输入1、2而不是1,2、3、4,然后重复安装3、4
答案 2 :(得分:0)
我遇到了同样的问题。下面的步骤已经解决了我的问题。
如果您已经尝试设置 SSL,请删除所有现有的 certbot 文件。 按照此链接如何从系统中删除现有的 Certbot 文件 https://askubuntu.com/a/1195603/871518
将所有单个域与单个 vhost.conf 文件分开。 示例:
domain1.conf
domain2.conf
Enable vhost in your created two new file by typing :
<块引用>
a2ensite domain1.conf
a2esnite domain2.conf
sudo certbot --apache
如果“serverAlias”包含在您的虚拟列表中,您可能会看到 4 个域列表:
1. domain1.com
2. domain2.com
3. www.domain1.com
4. www.domain2.com
在第一次旅程中只选择 1 和 3
sudo certbot --apache
答案 3 :(得分:0)
运行此命令时,请确保顺序也正确。例如:example.org 应该在请求中的 mail.example.org 之前。否则,尤其是在使用 Route 53 选项时,会收到奇怪的区域错误消息。