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

推荐订阅源

GbyAI
GbyAI
Y
Y Combinator Blog
Recent Announcements
Recent Announcements
D
Docker
Blog — PlanetScale
Blog — PlanetScale
罗磊的独立博客
美团技术团队
V
V2EX
Last Week in AI
Last Week in AI
D
DataBreaches.Net
T
The Blog of Author Tim Ferriss
宝玉的分享
宝玉的分享
Microsoft Security Blog
Microsoft Security Blog
Microsoft Azure Blog
Microsoft Azure Blog
人人都是产品经理
人人都是产品经理
M
MIT News - Artificial intelligence
P
Proofpoint News Feed
B
Blog RSS Feed
博客园_首页
B
Blog
博客园 - 叶小钗
I
InfoQ
WordPress大学
WordPress大学
L
LangChain Blog
Apple Machine Learning Research
Apple Machine Learning Research
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
A
About on SuperTechFans
The GitHub Blog
The GitHub Blog
The Register - Security
The Register - Security
MyScale Blog
MyScale Blog
云风的 BLOG
云风的 BLOG
博客园 - 司徒正美
Latest news
Latest news
W
WeLiveSecurity
T
The Exploit Database - CXSecurity.com
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
aimingoo的专栏
aimingoo的专栏
小众软件
小众软件
Cyberwarzone
Cyberwarzone
Scott Helme
Scott Helme
D
Darknet – Hacking Tools, Hacker News & Cyber Security
C
CERT Recently Published Vulnerability Notes
C
CXSECURITY Database RSS Feed - CXSecurity.com
Recent Commits to openclaw:main
Recent Commits to openclaw:main
N
News and Events Feed by Topic
S
Secure Thoughts
The Hacker News
The Hacker News
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Google DeepMind News
Google DeepMind News

Cloudflare on 老刘博客

博客web端改用apache 利用cloudFlare的边缘计算workers实现外链转内链跳转
利用cloudflare页面规则设置301永久跳转
老刘 · 2023-12-01 · via Cloudflare on 老刘博客

前言

细心的读者可能已经发现,图南博客的域名已经由iliu.org 更换到iliu.org。这个域名是之前在Google注册的,可惜的80端口被墙了,也不知道是怎么实现强域名80端口的。于是在暂时使用一段时间后又使用了原域名。

前两天的时候,感觉还是需要用iliu这个域名,和博客的名字比较搭配,而且用了ssl之后,网站走的443端口,基本上也不会影响什么,所以就切换了过来。

换域名之后另一个需要的解决的事情是要把iliu.org的网址301跳转到新网站,以前用VPS的时候,直接在nginx里设置,现在不用vps了,有没有别的方法呢?答案是肯定的,而且比vps更方便。那就是使用Cloudflare的页面规则进行跳转。

方法

进入到cloudflare的个人中心,点击需要跳转的网站域名,点击DNS。 把域名解析到8.8.8.8,当然你解析到1.1.1.1也是可以的。然后点击规则,再点击页面规则。具体的设置如下图:规则

这样,就把iliu.org这个网站的网址,按照同样的规则,跳转到了iliu.org这个网站。

使用免费的cloudflare一个域名只有3个免费的页面规则,因此还有另外一个方法也可以实现,那就是利用cloudflareworkers

进入到cloudflare的后台后,点击Workers 和 Pages

点击创建应用程序,再点击创建workers:把下面的代码修改一下,复制到代码区保存。

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
/**
 * Welcome to Cloudflare Workers! This is your first worker.
 *
 * - Run "npm run dev" in your terminal to start a development server
 * - Open a browser tab at http://localhost:8787/ to see your worker in action
 * - Run "npm run deploy" to publish your worker
 *
 * Learn more at https://developers.cloudflare.com/workers/
 */

// Redirect requests from one domain to another

const base = "https://iliu.org"
const statusCode = 301

async function handleRequest(request) {
  const url = new URL(request.url)
  const { pathname, search } = url
  const destinationURL = base + pathname + search

  return Response.redirect(destinationURL, statusCode)
}

addEventListener("fetch", async event => {
  event.respondWith(handleRequest(event.request))
})

上面秩序把域名化成你的域名,然后设置workers的域名是你要转出的域名即可。