Ubuntu nginx let‘s encrypt免费 https 设置

1.安装配置证书

apt-get update

apt-get -y install certbot

apt-get -y install python3-certbot-nginx

certbot --nginx

2.注意事项

1.保证服务器可域名访问,certbot需要验证 txt 记录。

2.同时要保证nginx 已配置 80端口的域名,否则提示

Could not automatically find a matching server block for secure.o3i.international. Set the server_name directive to use the Nginx installer.

server { listen 80;

server_name o3i.international;

access_log logs/ o3i.international.access.log main; r

oot /var/www/ o3i.international/htdocs; }

3.certbot会自动修改 nginx 的配置文件,原来 80 端口不能被访问了,443 端口可访问了。

80 会跳 443,但是nginx如果是 代理接口,要配置两个 server 分别占用 80,443。保留 80

4.自动续期:

sudo certbot renew --dry-run

如果测试成功,Certbot 会自动配置系统定期运行证书续期。通常情况下,Certbot 会自动将续期命令添加到系统的任务调度器中,确保证书在过期前得到更新。

5.阿里云服务器要开启 443 端口

参考文档

使用Certbot工具来申请和管理Let's Encrypt证书-腾讯云开发者社区-腾讯云

相关推荐
若云止水1 小时前
Ubuntu 下 nginx-1.24.0 源码分析 - ngx_init_cycle 函数 - 详解(4)
数据库·nginx·ubuntu
浪九天4 小时前
Nginx系列05(负载均衡、动静分离)
nginx·运维开发·持续部署
m0_7482365811 小时前
Nginx中$http_host、$host、$proxy_host的区别
运维·nginx·http
放情12 小时前
Ubutu部署WordPress
ubuntu·云原生
Xiezequan12 小时前
Ubuntu指令(一)
linux·运维·ubuntu
ForTodayzzZ12 小时前
centos和ubuntu安装mysql教程
linux·mysql·ubuntu·centos
尘佑不尘13 小时前
【无标题】oscp备考,oscp系列——Tr0ll1靶场,两种提权方式,ftp匿名登录,ssh爆破,ubuntu内核提权,计划任务
web安全·ubuntu·渗透测试·ssh·vulnhub
web1478621072313 小时前
Linux(CentOS)安装 Nginx
linux·nginx·centos
追风赶月、13 小时前
【网络】HTTPS协议原理
网络·网络协议·https