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

推荐订阅源

I
InfoQ
C
CERT Recently Published Vulnerability Notes
The Last Watchdog
The Last Watchdog
P
Proofpoint News Feed
D
Darknet – Hacking Tools, Hacker News & Cyber Security
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
GbyAI
GbyAI
T
Tenable Blog
博客园 - 三生石上(FineUI控件)
P
Privacy & Cybersecurity Law Blog
Simon Willison's Weblog
Simon Willison's Weblog
Jina AI
Jina AI
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
T
Tor Project blog
博客园_首页
F
Fortinet All Blogs
博客园 - Franky
Latest news
Latest news
Last Week in AI
Last Week in AI
T
Threat Research - Cisco Blogs
Scott Helme
Scott Helme
L
LINUX DO - 热门话题
U
Unit 42
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Hugging Face - Blog
Hugging Face - Blog
D
Docker
Project Zero
Project Zero
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
MongoDB | Blog
MongoDB | Blog
F
Full Disclosure
D
DataBreaches.Net
Google DeepMind News
Google DeepMind News
Cisco Talos Blog
Cisco Talos Blog
Y
Y Combinator Blog
WordPress大学
WordPress大学
C
Cyber Attacks, Cyber Crime and Cyber Security
H
Help Net Security
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
月光博客
月光博客
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Blog — PlanetScale
Blog — PlanetScale
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
S
Schneier on Security
C
Cybersecurity and Infrastructure Security Agency CISA
P
Proofpoint News Feed
PCI Perspectives
PCI Perspectives
Cloudbric
Cloudbric
V
Visual Studio Blog
Recorded Future
Recorded Future
人人都是产品经理
人人都是产品经理

iTimothy

那些让人笑出声的Meme排序算法 再谈费曼学习法 第一性原理读书笔记 我的2025 AWS Certified Developer Associate 认证备考指北 我的 AWS Certified Machine Learning – Specialty 认证之旅 2024年的年终总结:转变与沉淀 迟来的2023年终总结 The Heap Sort Algorithm Explained Modern C++ 学习笔记 -- 左值与右值 告别2022 客制化键盘初体验 RAMA WORKS KARA 聊聊被动收入与躺赚 新加坡驾照转换指北 利用GitHub Actions实现版本自动构建与发布流程 逝去的2021 美股期权投资策略学习笔记--期权的基本概念 我的2020 CKAD认证备考经验分享 Emacs启动加速篇
使用Caddy2托管静态博客
Timothy · 2021-10-17 · via iTimothy

最近由于Cloudflare受到一些”干扰”,有网友提醒我的blog在国内有打不开的情况。不幸的是我的Blog + CDN都是托管给Cloudflare的,被无辜”殃及”了。再加上最近比较忙,blog也荒芜了快一年没打理,正好这个周末的晚上可以来折腾一下。

看了一下手上的吃灰的几个小鸡,发现竟然还有一台之前买的搬瓦工的小鸡,登录上去一看,好家伙,uptime 都659天了,稳啊! 好吧,就它了!接下来又是一波骚操作,从德国Contabo的主机rsync直接拷贝所有静态页面过来,速度还挺快。之前用的Nginx,这次打算再次换成Caddy Server,毕竟Caddy都出第二个版本了,自动更新SSL证书是比较能吸引我的地方。去官网研究了一下文档,还是决定用Docker来跑Caddy2,方便!

由于这个VPS只是用来放我的静态blog,所以也不用考虑多站点的问题,Caddyfile的配置简单到发指:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
https://xiaozhou.net
{
encode gzip
tls [email protected] {
protocols tls1.2
}
root * /usr/share/caddy
file_server
}

http://www.xiaozhou.net
{
redir https://xiaozhou.net{url}
}

http://xiaozhou.net
{
redir https://xiaozhou.net{url}
}

配置里面有两个请求转发,把所有非HTTPS的请求都转发到HTTPS。然后,再准备一个shell脚本,用来运行Caddy2:

1
2
3
4
docker run -d --restart=always --name caddy -p 80:80 -p 443:443 \
-v /home/mysite:/usr/share/caddy/ \
-v $PWD/Caddyfile:/etc/caddy/Caddyfile \
caddy:2.4.5-alpine

容器直接暴露80端口和443端口到宿主机器即可。万事具备,只欠东风!去Cloudflare把域名解析过来,等生效,然后直接启动Caddy server。一切顺利,Caddy Server会在第一次启动的时候,自动申请LetsEncrypt的证书,后续也能自动renew。我懒啊,要的就是省心!

后续的流程,去GitHub改掉blog的自动部署流程,把部署的机器更新成现在的小鸡,打完收工!就这样,Blog又又又搬家了一次,从德国搬去了美国西海岸…… 唉……