惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

S
Security Affairs
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
大猫的无限游戏
大猫的无限游戏
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
爱范儿
爱范儿
阮一峰的网络日志
阮一峰的网络日志
GbyAI
GbyAI
D
Docker
美团技术团队
N
Netflix TechBlog - Medium
罗磊的独立博客
V
Visual Studio Blog
人人都是产品经理
人人都是产品经理
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Hugging Face - Blog
Hugging Face - Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
Jina AI
Jina AI
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
M
MIT News - Artificial intelligence
腾讯CDC
MongoDB | Blog
MongoDB | Blog
Last Week in AI
Last Week in AI
博客园 - 三生石上(FineUI控件)
博客园 - 叶小钗
V
V2EX
L
LangChain Blog
博客园 - 【当耐特】
B
Blog RSS Feed
量子位
U
Unit 42
Engineering at Meta
Engineering at Meta
小众软件
小众软件
宝玉的分享
宝玉的分享
H
Help Net Security
Microsoft Azure Blog
Microsoft Azure Blog
云风的 BLOG
云风的 BLOG
博客园 - 聂微东
博客园 - 司徒正美
The Cloudflare Blog
The GitHub Blog
The GitHub Blog
T
Tailwind CSS Blog
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
The Last Watchdog
The Last Watchdog
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
S
SegmentFault 最新的问题
博客园_首页
Attack and Defense Labs
Attack and Defense Labs
TaoSecurity Blog
TaoSecurity Blog
Apple Machine Learning Research
Apple Machine Learning Research
S
Security @ Cisco Blogs

博客园 - ayanmw

极度推荐: 9router 一个npm服务,可以让你将白嫖到的所有AI token以及付费API都集中到一起 开源项目介绍 OpenTeam 命令行 检测验证网站的 SSL证书 是否安全 关闭夸克浏览器在windows资源管理器中,图片右键菜单的万能转换开关 golang的defer 深坑 Windows Terminal 清屏方法 Ctrl+Shift+K 免费二级域名以及设置SSL证书和解析 docker加速镜像 golang + AI 写一个可以 一键让nas下载百度网盘链接的文件 的程序 raid 为什么而不可以两个硬盘交叉读写和交叉备份? google-protobuf库 在golang语言下的插件扩展 golang 空切片和nil切片 有区别吗? golang json库 忽略 omitempty Go语言: golang如何判断一个结构体的一个方法是匿名组合的,还是该结构体自己的方法? golang 获得一个结构体的字节大小 吐槽 WPS 流氓行为: WPS 未经用户允许, 就建立了 WPS本地云盘 , 然后 云文档的文件 莫名其妙的的被删除了, 现在只能开会员恢复WPS云空间回收站的文件. 预测未来会有 内嵌AI大模型的游戏 好奇: windows10+都可以运行多个linux子系统了,为什么不支持运行多个windows子系统呢? gorm使用事务并发情况下切有最大mysql连接数限制的情况下的BUG,踩坑了 2024年 个人养老金 账户 应知应会 两个Mysql唯一索引的交换: 避免重复索引 Duplicate entry '3' for key 'priority_UNIQUE'
Nginx 使用自签名 SSL 证书
ayanmw · 2026-02-04 · via 博客园 - ayanmw

方法一 使用 snakeoil

使用 apt 安装的 nginx,默认配置文件中会有一行被注释的 include snippets/snakeoil.conf; 解除注释,通过 systemctl reload nginx 重新加载配置即可。

若重新加载失败提示

nginx: [emerg] cannot load certificate "/etc/ssl/certs/ssl-cert-snakeoil.pem": BIO_new_file() failed (SSL: 
error:02001002:system library:fopen:No such file or directory:fopen('/etc/ssl/certs/ssl-cert-snakeoil.pem','r') 
error:2006D080:BIO routines:BIO_new_file:no such file)

则需要使用 apt install ssl-cert 安装依赖,再次重新加载配置即可

方法二 使用 OpenSSL 自签名 (重点)

创建私钥

openssl genrsa -out server.key 2048

创建证书签名请求

openssl req -new -key server.key -out server.csr

此时可以根据自己需要对信息进行填写,需要注意 Common Name 必须为对应网站域名或ip地址

output and input:

You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [AU]:**cn**
State or Province Name (full name) [Some-State]:**localhost**
Locality Name (eg, city) []:**sh**
Organization Name (eg, company) [Internet Widgits Pty Ltd]:****
Organizational Unit Name (eg, section) []:****
Common Name (e.g. server FQDN or YOUR name) []:**localhost**
Email Address []:**admin@localhost**

Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:**nopass**
An optional company name []:**cn-ltd**

创建自签名证书

openssl x509 -req -in server.csr -signkey server.key -out server.crt

output:

Certificate request self-signature ok
subject=C = cn, ST = localhost, L = sh, O = Internet Widgits Pty Ltd, CN = localhost, emailAddress = admin@localhost

配置 nginx

server {
      listen              443 ssl;
      ssl_certificate     /path/to/server.crt
      ssl_certificate_key /path/to/server.key
      ....
}

配置完成后使用 systemctl reload nginx 来重载配置

当使用 Chrome 访问自签名证书的网站时,会提示不安全。

解决方法 就是 忽略 或者 添加到本地信任机构证书(貌似没什么卵用)

意义:

起码 你有了SSL证书 用于开发、部署测试。

copy from:

https://jackyu.cn/tech/nginx-selfsign-ssl-cert/