Skip to content

tomiaa12/cloudflare-reverse-proxy

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 

Repository files navigation

cloudflare-reverse-proxy

本项目是cloudflare反向代理。在cloudflare网站中新建worker,把worker.js文件中的内容复制进去即可使用。

使用方法为在任意url前面加上https://你的域名/proxy/ 即可使用cloudflare加速。

例如https://你的域名/proxy/https://raw.githubusercontent.com/gaboolic/cloudflare-reverse-proxy/main/worker.js

本人另外一个项目是基于vercel的反向代理,仓库地址https://github.com/gaboolic/vercel-reverse-proxy 供大家参考

详细步骤

0 登录https://www.cloudflare.com/

1 创建应用程序 创建应用程序 2 创建worker(pages也一样,也可以fork此项目在pages里直接部署) 创建worker 3 点"部署"按钮 创建worker 4 编辑代码 编辑代码 5 把worker.js文件中的内容复制进去,点"保存并部署" 保存并部署 6 (可选) 添加自定义域

绑定自己的域名。不需要教程了,现在在cloudflare点添加自定义域名,输入子域名自动添加好dns

免费域名申请:https://secure.nom.za/ https://nic.eu.org/ https://nic.ua

不需要申请,link域名0元免费1年:dynadot.com

使用方法

在任意url前面加上https://你的域名/proxy/ 即可使用cloudflare加速。

例1 https://github.com/gaboolic 前面加上https://你的域名/proxy/ demo1 例2 调用openai的post接口,https://api.openai.com/v1/chat/completions 前面加https://你的域名/proxy/ demo2

如何在一些常见的开源项目中使用? 一般开源项目都是引用的openai的库,可以看到里面有一个属性是api_base = os.environ.get("OPENAI_API_BASE", "https://api.openai.com/v1")

所以使用的时候只需要设置一下openai.api_base="https://你的域名/proxy/https://api.openai.com/v1" 就可以了

更多使用方法也可以参考https://github.com/gaboolic/vercel-reverse-proxy

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%