使用certbot-auto for nginx

Den*_*boy 7 ssl nginx lets-encrypt

我有一个运行nginx.现在我希望我的nginx使用SSL:

certbot-auto --nginx -d my.domain.com -n --agree-tos --email admin@mail.com
Run Code Online (Sandbox Code Playgroud)

OUTPUT:

Performing the following challenges:
tls-sni-01 challenge for my.domain.com
Cleaning up challenges
Cannot find a VirtualHost matching domain my.domain.com.
Run Code Online (Sandbox Code Playgroud)

my.domain.com指向我服务器的IP.这是它的DNS名称.我究竟做错了什么?我已经为apache做了这个,它工作正常.我的nginx正在运行(并且我无法在之后手动重启它,certbot-auto但是在我使用时不需要这样做certbot-auto --apache

big*_*ter 8

在我的情况下,我不得不添加"server_name"行,因为它不在我的nginx配置中,所以当我运行时它给了我错误消息"找不到VirtualHost匹配域my.domain.com":

certbot --nginx
Run Code Online (Sandbox Code Playgroud)

确保这在您的配置中:

server {
    server_name my.domain.com;
    ....
}
Run Code Online (Sandbox Code Playgroud)