Certbot / letsencrypt生成[www]证书后出现[non-www]域错误

时间:2019-11-15 02:39:16

标签: apache ssl-certificate ubuntu-18.04 lets-encrypt certbot

我使用certbot设置了两个站点(下面的链接),并输入了“ www”。生成HTTPS证书时导致域的一部分,导致两个站点的非www URL都导致错误。

StackOverflow上有许多类似的问题,但到目前为止,还没有一个解决我的问题的。

相关链接

工作域

无效的域(由于缺少“ www。”)

尝试的修复命令

  • sudo certbot certonly --standalone -d fastsitephp.com -d www.fastsitephp.com
  • sudo certbot删除--cert-name www.fastsitephp.com

Chrome将使用上述链接重定向到“ www”站点,但是从Firefox和Mobile Safari可以清除该错误

服务器

  • Ubuntu 18.04 LTS与Apache

帮助!我可以做些什么来解决此问题,而无需设置新服务器和更改URL。理想情况下,服务器将同时支持www和非www。但是,如果无法解决,则可以重写Apache url。

提前谢谢!

1 个答案:

答案 0 :(得分:0)

我最终自己解决了。主要问题是,即使在运行delete之后,Certbot仍然保留其创建的HTTP-> HTTPS重定向和其他一些Apache配置设置(这是假设您在原始设置中选择了从HTTP重定向到HTTPS)。

如果其他人遇到此问题,并且需要完全删除Certbot生成的证书,以下是我使用的命令:

sudo certbot delete
cd /etc/apache2/sites-enabled
ls
sudo nano 000-default.conf
    # Remove the redirect
sudo rm 000-default-le-ssl.conf
    # Also any file other SSL files such as [000-default-le-ssl.conf.sav]
sudo certbot --apache
    # enter both Domains "example.com www.example.com"
sudo service apache2 restart
相关问题