我被难住了。我有 2 个不同的域,我正在尝试在 Digital Ocean Ubuntu 服务器上使用 Certbot 安装 SSL 证书。这是我为获取 SSL 证书而运行的最后一个命令:
sudo certbot --nginx -d mydomain1.com -d www.mydomain1.com
我对 mydomain1.com
和 mydomain2.com
运行完全相同的命令
这是没有意义的。 mydomain1.com
的身份验证通过,但 mydomain2.com
我为两个域使用相同的 Nginx 服务器 block 配置文件。是的,这包括两者的 Nginx 配置文件中相同的根文件路径和服务器名称。
我将两个配置文件都设置为以下内容:
listen 80;
listen [::]:80;
root /var/www/mydomain2.com;
index index.html index.htm index.nginx-debian.html;
server_name mydomain2.com www.mydomain2.com;
是的,两个配置文件(mydomain1.com
和 mydomain2.com
都设置为 mydomain2.com
的根路径和服务器名称mydomain2.com
因为我需要 Nginx 提供与我在该目录中完全相同的内容。我这样做的目的是让 mydomain1.com
重定向到 mydomain2.com
但它似乎无法正常工作,这是一个单独的问题。现在我只是尝试验证 mydomain2.com
的 SSL 证书,然后我'我们会找出重定向。
预先感谢您的帮助。
最佳答案
如果我理解正确,答案如下:
certbot certonly --standalone --preferred-challenges http -d domain1.com -d www.domain1.com
不需要修改nginx default.conf文件。请改用以下方法。
nano/etc/nginx/sites_available/domain1.com
server {
listen 80;
listen [::]:80;
server_name domain1.com www.domain1.com;
return 301 https://domain1.com\$request_uri;
}
server {
listen 443 ssl;
server_name domain1.com;
ssl_certificate /etc/letsencrypt/live/domain1.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/domain1.com/privkey.pem;
}
站点启用符号链接(symbolic link)
ln -s /etc/nginx/sites-available/domain1.conf /etc/nginx/sites-enabled
在 domain2.com 中相同
关于ssl - Certbot 域身份验证失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58420494/