http转https,免费快速申请证书并实现nginx配置

应用场景:着急给客户使用https安全版的,没空等待ssl申请的,可以考虑用这个中转方案。注意:以上方案仅为临时方案,等申请到了及时替换就行。

快速获取证书

参考:https://certbot.eff.org/instructions?ws=nginx\&os=pip

1.选择配置证书的方式

2.无脑输入代码

bash 复制代码
sudo apt update
sudo apt install python3 python3-dev python3-venv libaugeas-dev gcc
sudo python3 -m venv /opt/certbot/
sudo /opt/certbot/bin/pip install --upgrade pip

sudo /opt/certbot/bin/pip install certbot certbot-nginx
sudo ln -s /opt/certbot/bin/certbot /usr/bin/certbot

sudo certbot --nginx【我没有成功】
sudo certbot certonly --nginx【这个命令成功了】

3.获取证书路径

4.教程里有每个月续订的方法

bash 复制代码
# 自动续订
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
# 每月升级
sudo /opt/certbot/bin/pip install --upgrade certbot certbot-nginx

nginx配置

参考:https://comate.baidu.com/zh/page/1rvb3h6h0ow

bash 复制代码
server {
    listen 443 ssl;
    server_name example.com;

    ssl_certificate /path/to/cert.pem;
    ssl_certificate_key /path/to/key.pem;

    add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
}

server {
    listen 80;
    server_name example.com;
    return 301 https://$host$request_uri;
}
相关推荐
GitLqr5 小时前
别再盲目复制了:彻底搞懂 CORS 的本质与那些“神坑”
安全·http·面试
IPdodo_9 小时前
Codex 一直显示 Thinking 怎么办?区分任务运行、界面卡住与会话恢复
http·网络调试
Kina_C12 小时前
Apache HTTP Server 安装、配置与高级功能详解
linux·http·apache
chexus13 小时前
21. 深入 Nginx HTTP 缓存源码:CDN功能
nginx·http·缓存
张小姐的猫1 天前
【Linux】网络编程 —— HTTP协议(上)
linux·运维·服务器·网络·http·单例模式·策略模式
2501_916007471 天前
深入理解HTTPS对称与非对称加密机制及Charles抓包实践
网络协议·http·ios·小程序·https·uni-app·iphone
BelongPanda1 天前
Linux Nginx 纯手动 Let‘s Encrypt 泛域名证书配置教程
linux·nginx
2501_916008891 天前
HTTPS 抓包遇到证书绑定怎么办,使用 TraceEagle 解除 App 证书校验
网络协议·计算机网络·http·网络安全·ios·adb·https
郝亚军2 天前
nginx的三个基础库:PCRE、OpenSSL、Zlib的安装
linux·服务器·nginx
CodexDave2 天前
MySQL事务隔离级别与MVCC机制解析
前端·数据库·mysql·nginx·性能优化·负载均衡