自学内容网 自学内容网

免费使用Certbot在Amazon EC2上启用https证书

本文测试使用Certbot在Amazon EC3上启用免费的https证书。

测试环境:Amzon EC2 (Ubuntu Server 24.0.2 LTS), 使用Nginx作为网页服务器

一、安装Nginx: sudo apt install nginx

二、添加nginx配置: sudo nano /etc/nginx/conf.d/test.com.conf

内容如下:

server {

listen 80;

server_name xxx.com;

root /usr/share/nginx/html;

index index.html;

charset UTF-8;

}

三、下载并安装certbot

1. 安装系统依赖项

sudo apt install python3

2. 设置Python虚拟环境

sudo python3 -m venv /opt/certbot/

sudo /opt/certbot/bin/pip install --upgrade pip

3. 安装Certbot

sudo /opt/certbot/bin/pip install certbot certbot-nginx

4. 准备certbot命令

sudo ln -s /opt/certbot/bin/certbot /usr/bin/certbot

5. 运行certbot命令

运行此命令以获取证书并让 Certbot 自动编辑 nginx 配置以提供服务,只需一步即可启用 HTTPS 访问,按提示配置就可以。

 sudo certbot --nginx

6. (可选)自动续订

echo "0 0,12 * * * root /opt/certbot/bin/python -c 'import random; import time; time.sleep(random.random() * 3600)' && sudo certbot renew -q" | sudo tee -a /etc/crontab > /dev/null


原文地址:https://blog.csdn.net/tealcwu/article/details/142834621

免责声明:本站文章内容转载自网络资源,如本站内容侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!