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

推荐订阅源

月光博客
月光博客
Martin Fowler
Martin Fowler
博客园_首页
量子位
T
Tailwind CSS Blog
博客园 - Franky
G
Google Developers Blog
D
DataBreaches.Net
Vercel News
Vercel News
B
Blog
Recent Announcements
Recent Announcements
S
SegmentFault 最新的问题
M
MIT News - Artificial intelligence
爱范儿
爱范儿
博客园 - 【当耐特】
The Cloudflare Blog
H
Help Net Security
云风的 BLOG
云风的 BLOG
P
Proofpoint News Feed
C
Check Point Blog
有赞技术团队
有赞技术团队
Microsoft Security Blog
Microsoft Security Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More

Yesterday17's Blog

2026 新年解密红包 / Melody Flag | Yesterday17's Blog 谈谈 Iori 的设计思路(二):如何实现一个 Showroom 录制工具? | Yesterday17's Blog 谈谈 Iori 的设计思路(一):从 Nico Timeshift 说起 | Yesterday17's Blog Iori Minyami 0.1.0 发布 | Yesterday17's Blog 2025 新年解密红包 / Melody Flag | Yesterday17's Blog 使用 Cloudflare Warp 解决罗森票务的海外登录问题 | Yesterday17's Blog How To Blog 04: The Astro v5 Era | Yesterday17's Blog 谈谈 tokio::select! 的公平性 | Yesterday17's Blog Learning Pingora 05 - Connect with TLS | Yesterday17's Blog Leaving Bytedance | Yesterday17's Blog 大橋彩香 AsiaTour「Reflection」上海公演 个人向记录 & Repo | Yesterday17's Blog Recoving from burnout - What happened? | Yesterday17 Yubikey 重建手册 | Yesterday17's Blog How To Blog 03: Heimus | Yesterday17's Blog 🪧 Blog Migration Accouncement | Yesterday17's Blog Learn Your IDE - VSCode 是如何仅重启插件的? | Yesterday17's Blog How To Blog 02: Astro❤️Password | Yesterday17's Blog How To Blog 01: Why, How, and the Future | Yesterday17's Blog Learning Pingora 04 - Establish L4 Connection | Yesterday17's Blog Learning Pingora 03 - Upstreams and Peers | Yesterday17's Blog Learning Pingora 02 - A Simple HTTP Server | Yesterday17's Blog Learning Pingora 01 - Getting Started | Yesterday17's Blog 2024 新年解密红包 / Melody Flag | Yesterday17's Blog 向新的一年飞驰——记录 2023 | Yesterday17's Blog 「サクラノ刻」对话选摘(2) | Yesterday17's Blog PGP Key Revocation 注销声明 | Yesterday17's Blog 「サクラノ刻」对话选摘(1) | Yesterday17's Blog 2023 新年解密红包 / Melody Flag | Yesterday17's Blog 『蒼の彼方のフォーリズム』通关感想 | Yesterday17's Blog 单显卡直通教程 | Yesterday17's Blog
博客建设笔记(2)配置仅 CDN 可访问源站 http(s) 服务 | Yes...
Yesterday17 · 2020-05-17 · via Yesterday17's Blog

最近发现有直接访问源站的请求,查了一下他们的域名直接指向的就是源站,可能是之前这个 IP 的用户吧。为了保险期间,我们希望只允许 CDN 访问,那么应该怎么做呢?

ToC

  • 获取 IP 列表
  • 生成 firewall-cmd 规则
  • 关闭开启的 http(s) 服务

获取 IP 列表

我们使用了 Cloudflare 和 百度云加速,从本质上来看其实都是 Cloudflare(

百度云加速的 IP 列表在此;Cloudflare 的 IP 列表在此

生成 firewall-cmd 规则

这里摸了个脚本:

function generateRule(ips = [], services = ["http", "https"], ip_version = 4) {

return ips

.map(ip => {

return services

.map(

service =>

`sudo firewall-cmd --zone=drop --add-rich-rule='rule family="ipv${ip_version}" source address="${ip}" service name="${service}" accept' --permanent`

)

.join("\n");

})

.join("\n");

}

把对应的 IP 地址分好了塞进去就行了,非常的方便(

关闭开启的 http(s) 服务

接下来就是执行上面输出的结果了。然后我们需要关掉上一篇文章中启用的 httphttps 服务:

sudo firewall-cmd --zone=drop --remove-service=http --permanent

sudo firewall-cmd --zone=drop --remove-service=https --permanent

最后重载 firewalld 即可:

sudo firewall-cmd --reload