我有一个静态 html 网站,可以通过 http 正常工作,但不能通过 https 工作, 我不知道出了什么问题,这是我的 nginx 配置文件:
server {
listen 80;
listen 443 ssl;
root /var/www/site.com/site;
index index.html index.htm index.nginx-debian.html;
server_name site.com www.site.com;
ssl_certificate /etc/nginx/ssl/site.com/site.com;
ssl_certificate_key /etc/nginx/ssl/site.com/myserver.key;
ssl_prefer_server_ciphers on;
location / {
try_files $uri $uri/ =404;
}
}
我遇到了同样的问题,结果发现删除现有证书并再次重新生成证书更简单。我做了什么:
$ sudo certbot delete --cert-name setoelkahfi.com
Saving debug log to /var/log/letsencrypt/letsencrypt.log
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
The following certificate(s) are selected for deletion:
* setoelkahfi.com
Are you sure you want to delete the above certificate(s)?
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(Y)es/(N)o: y
Deleted all files relating to certificate setoelkahfi.com.
$ sudo certbot --nginx -d setoelkahfi.com
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator nginx, Installer nginx
Requesting a certificate for setoelkahfi.com
Deploying Certificate to VirtualHost /etc/nginx/sites-enabled/setoelkahfi.com
Redirecting all traffic on port 80 to ssl in /etc/nginx/sites-enabled/setoelkahfi.com
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Congratulations! You have successfully enabled https://setoelkahfi.com
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
IMPORTANT NOTES:
- Congratulations! Your certificate and chain have been saved at:
/etc/letsencrypt/live/setoelkahfi.com-0001/fullchain.pem
Your key file has been saved at:
/etc/letsencrypt/live/setoelkahfi.com-0001/privkey.pem
Your certificate will expire on 2025-03-29. 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"
- If you like Certbot, please consider supporting our work by:
Donating to ISRG / Let's Encrypt: https://letsencrypt.org/donate
Donating to EFF: https://eff.org/donate-le
nginx
配置文件中的证书路径。sudo service nginx restart
) 就到此为止了。