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

推荐订阅源

Y
Y Combinator Blog
Security Archives - TechRepublic
Security Archives - TechRepublic
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Apple Machine Learning Research
Apple Machine Learning Research
Blog — PlanetScale
Blog — PlanetScale
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
G
Google Developers Blog
F
Full Disclosure
大猫的无限游戏
大猫的无限游戏
酷 壳 – CoolShell
酷 壳 – CoolShell
T
Threat Research - Cisco Blogs
A
Arctic Wolf
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
The Cloudflare Blog
博客园 - 【当耐特】
AWS News Blog
AWS News Blog
U
Unit 42
V
Vulnerabilities – Threatpost
P
Privacy International News Feed
T
Tor Project blog
Microsoft Security Blog
Microsoft Security Blog
宝玉的分享
宝玉的分享
Google DeepMind News
Google DeepMind News
爱范儿
爱范儿
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Recorded Future
Recorded Future
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
C
CXSECURITY Database RSS Feed - CXSecurity.com
T
Threatpost
Latest news
Latest news
GbyAI
GbyAI
S
SegmentFault 最新的问题
MongoDB | Blog
MongoDB | Blog
N
Netflix TechBlog - Medium
Hacker News: Ask HN
Hacker News: Ask HN
美团技术团队
N
News | PayPal Newsroom
J
Java Code Geeks
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Microsoft Azure Blog
Microsoft Azure Blog
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
The Hacker News
The Hacker News
The GitHub Blog
The GitHub Blog
V
V2EX
N
News and Events Feed by Topic
T
Troy Hunt's Blog
Security Latest
Security Latest
博客园 - 叶小钗
P
Palo Alto Networks Blog

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又又又搬家了一次,从德国搬去了美国西海岸…… 唉……