v2ray-agent/documents/cloudflare_workers.md

51 lines
2.2 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

- [注意事项](#注意事项)
- [步骤](#步骤)
* [1.创建Workers自定义域名](#1创建Workers自定义域名)
* [2.绑定域名](#2绑定域名)
* [3.创建Workers](#3创建Workers)
* [4.使用](#4使用)
# 注意事项
- Wokers是Cloudflare基于CDN的无服务器应用程序。
- ~~想使用Wokers域名必须必须托管在Cloudflare~~[错误]
- 每天10万条请求
- 保证在没有使用Workers的情况可以正常使用服务【CDN+WebSocket+TLS or WebSocket+TLS】
# 步骤
## 1.创建Workers自定义域名
- 域名的前缀可以自定义
- Plan选择free即可
- 会验证邮箱
<img src="https://raw.githubusercontent.com/mack-a/v2ray-agent/master/fodder/Workers/Workers_01.png" width=400>
<img src="https://raw.githubusercontent.com/mack-a/v2ray-agent/master/fodder/Workers/Workers_02.png" width=400>
## ~~2.绑定域名~~[这一步可以不用看,直接看下面的即可]
- 1.添加域名
<img src="https://raw.githubusercontent.com/mack-a/v2ray-agent/master/fodder/Workers/Workers_03.png" width=400>
- 2.修改域名注册商的Nameserver
<img src="https://raw.githubusercontent.com/mack-a/v2ray-agent/master/fodder/Workers/Workers_04.png" width=400>
- 3.创建域名解析这里域名可以直接用能正常访问的服务或者创建新的如果创建新的并且证书是通配符证书则用新旧域名都无影响如果不是通配符需要重新生成证书以及配置相关的Nginx服务
<img src="https://raw.githubusercontent.com/mack-a/v2ray-agent/master/fodder/Workers/Workers_06.png" width=400>
## 3.创建Workers
- 1.填写Workers的Script为下方内容【hostname填写科学上网的域名比如 workerproxy.v2ray-agent.com 】
```
addEventListener(
"fetch",event => {
let url=new URL(event.request.url);
url.hostname="这里要修改为自己的";
let request=new Request(url,event.request);
event. respondWith(
fetch(request)
)
}
)
```
<img src="https://raw.githubusercontent.com/mack-a/v2ray-agent/master/fodder/Workers/Workers_05.png" width=400>
<img src="https://raw.githubusercontent.com/mack-a/v2ray-agent/master/fodder/Workers/Workers_07.png" width=400>
## 4.使用
- 1.客户端只需要将address部分修改为上图第二个红框位置的内容即可