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

推荐订阅源

D
DataBreaches.Net
Apple Machine Learning Research
Apple Machine Learning Research
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
S
SegmentFault 最新的问题
博客园 - 聂微东
罗磊的独立博客
W
WeLiveSecurity
博客园_首页
Scott Helme
Scott Helme
V
Visual Studio Blog
T
The Exploit Database - CXSecurity.com
G
Google Developers Blog
大猫的无限游戏
大猫的无限游戏
Latest news
Latest news
L
Lohrmann on Cybersecurity
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
A
About on SuperTechFans
F
Full Disclosure
Y
Y Combinator Blog
D
Darknet – Hacking Tools, Hacker News & Cyber Security
博客园 - 司徒正美
博客园 - Franky
C
CXSECURITY Database RSS Feed - CXSecurity.com
F
Fortinet All Blogs
Blog — PlanetScale
Blog — PlanetScale
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
阮一峰的网络日志
阮一峰的网络日志
S
Schneier on Security
雷峰网
雷峰网
博客园 - 【当耐特】
P
Privacy International News Feed
C
Cyber Attacks, Cyber Crime and Cyber Security
Engineering at Meta
Engineering at Meta
aimingoo的专栏
aimingoo的专栏
MongoDB | Blog
MongoDB | Blog
J
Java Code Geeks
T
Tor Project blog
V
V2EX
爱范儿
爱范儿
C
Check Point Blog
T
Threatpost
Project Zero
Project Zero
量子位
V
Vulnerabilities – Threatpost
Know Your Adversary
Know Your Adversary
I
Intezer
G
GRAHAM CLULEY
P
Privacy & Cybersecurity Law Blog
GbyAI
GbyAI
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com

Hunsh's Blog

生成个人的 Github PR List 如何选择合适的加密手段 如何优雅导入 k8s.io/kubernetes Make Go mod and Git to use specify .netrc 多架构镜像的体积优化 使用 buildkit 进行多架构构建并提取产物 如何修改镜像 layer(以 sourcemap-less grafana 为例) acme.sh 自动化 Google CA 申请证书 微信小程序嵌入任意公众号文章 k8s && bazel 项目从 go1.20 升级 go1.21 go serve http and https on same port typecho 迁移到 hexo 实现 hexo 文章和资源在同一目录下 golang mitm 遇到的问题 流式数据专用的 mine-type Golang 正向代理对于 Host 的处理 (RFC 7230) 分享 MacOS 的一些系统fix脚本(dns、sleep) prometheus rate/increase/delta/sum等函数不符合预期或出现小数的原理 [油猴脚本] USTB Everywhere 为校外访问添加访问任意网站的能力
Nginx SNI Proxy
2025-04-22 · via Hunsh's Blog

由于互联网相关上相关资料较为零散,本文进行一个常用场景的使用总结

Prepare

ubuntu 可以直接 apt install -y nginx,ALinux 的 yum 上的 nginx 不带有 stream_module,需要自行编译,编译时需要携带 --with-stream=dynamic --with-stream_ssl_module --with-stream_ssl_preread_module

如果 nginx 为自行编译,nginx.conf head 需要加上

1
load_module /usr/lib/nginx/modules/ngx_stream_module.so;

Usage

any domain(不限制域名,转发所有 request,通常作用为限制网络条件下的网关)

1
2
3
4
5
6
7
8
9
stream {
resolver 127.0.0.1;

server {
listen 443;
proxy_pass $ssl_preread_server_name:443;
ssl_preread on;
}
}

specific domains(限制特定域名)

1
2
3
4
5
6
7
8
9
10
11
12
13
stream {
# ip 处也可填写域名
map $ssl_preread_server_name $target_backend {
example.domain.com ip:443;
}
resolver 127.0.0.1;

server {
listen 443;
proxy_pass $target_backend;
ssl_preread on;
}
}

regexp

1
2
3
4
5
6
7
8
9
10
11
12
13
stream {
# ip 处也可填写域名
map $ssl_preread_server_name $target_backend {
~(.*).domain.com $1.other.com:443;
}
resolver 127.0.0.1;

server {
listen 443;
proxy_pass $target_backend;
ssl_preread on;
}
}