web服务器https访问

web服务器https访问

LinJiefeng Lv3

手动更新证书

  • 常规操作

    1
    2
    3
    sudo systemctl stop nginx   # 停止nginx服务
    sudo certbot renew # 更新证书
    sudo systemctl start nginx # 启动nginx服务
  • 使用插件

    1
    sudo certbot renew --nginx

安装Let“s Encrypt证书

使网站可以使用https访问

1.安装Certbot

1
2
sudo apt update
sudo apt install certbot python3-certbot-nginx -y # 如果使用 Nginx

2.获取SSL证书

方式一、自动获取

  • 申请证书

    1
    sudo certbot --nginx -d 域名  # 如果是 Nginx

    证书配置文件[renewalparams]节点下authenticator = nginx

  • 模拟自动续期

    1
    sudo certbot renew --dry-run

方式二、手动获取

1
sudo certbot certonly --standalone -d 域名

证书配置文件[renewalparams]节点下authenticator = standalone

3.配置web服务器

nginx站点文件会自动添加相关配置文件

1
2
3
4
location /images/ {
# 允许访问图片目录
autoindex on; # 可选:开启目录列表(类似文件浏览器)
}

在目录下新增 autoindex on;开启目录列表(类似文件浏览器)

查看证书有效期

1
sudo certbot certificates
  • 标题: web服务器https访问
  • 作者: LinJiefeng
  • 创建于 : 2025-07-16 21:00:51
  • 更新于 : 2026-07-02 10:29:03
  • 链接: https://blog.icsteam.cn/2025/07/16/101_web_https/
  • 版权声明: 本文章采用 CC BY 4.0 进行许可。
评论