Coder Social home page Coder Social logo

gaboolic / cloudflare-reverse-proxy Goto Github PK

View Code? Open in Web Editor NEW
718.0 8.0 266.0 6.02 MB

cloudflare反向代理|OpenAI/ChatGPT 免翻墙代理|github免翻墙代理|github下载加速|google代理|cloudflare万能代理

Home Page: https://github.com/gaboolic/vercel-reverse-proxy

JavaScript 100.00%
chatgpt-proxy cloudflare github-proxy google-proxy openai-proxy reverse-proxy cloudflare-proxy cloudflare-reverse-proxy

cloudflare-reverse-proxy's Introduction

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麻烦一点,需要写一个package.json文件,但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

cloudflare-reverse-proxy's People

Contributors

chise0713 avatar gaboolic avatar madisonwirtanen avatar whueugene avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cloudflare-reverse-proxy's Issues

能否url不跳转。

现在只能加速静态url,点击连接后就跳转了。能否加速跳转后的链接呢?

不能自动添加https

在使用反代理后打开链接,除链接本身可以访问。剩下都不行。然后一看访问跳转时是不加https的,就导致了无法加载。

【改进】感谢作者,这里做了一些小小的改进

项目地址:

https://github.com/1234567Yang/cf-proxy-ex/

在线体验:

https://y.demo.wvusd.homes/

轻点薅。

基于原项目的改进:

  • 去掉/proxy/,方便使用。我看到有issue说了,但是作者说想添加引导界面,这个问题我也解决了。
  • 手动处理转跳事件(3XX),防止一些相对资源加载不出来。
  • 判断欲代理的网址是否以http开头,如果不是就自动加上。
  • 把header里所有有关代理网址的信息全部换成要代理的网站的信息,防止某些网站阻止代理。
  • 相对路径全部转换绝对路径,方便加载资源(如JS,CSS等)。
  • Cookie作用域修改成仅当代理那个网站时,防止Cookie太大服务器发来400 bad request,同时也可以防止一个敏感的Cookie被探测到导致整个网站无法使用,详细:#7
  • XMLHttpRequestfetch注入返回的HTML,这样也可以提交表单数据。
  • 把一个文档监视器注入到返回的HTML,这样有新的链接也可以相对转绝对。
  • 修改Content-Security-PolicyX-Frame-Options的Header,实现可代理Duckduckgo,同时也解决了一些网站打不开的问题。
  • 在返回的时候,如果是HTML,那么添加"Content-Type": "text/html; charset=utf-8",防止一些较为古老的中文网站打开出现锟斤拷烫烫烫的问题。
  • 优化了一些代码。

把url跳转和密码验证结合了一下,但是写死了只能访问github

https://github.com/nekoaday/cloudflare-reverse-proxy
相当于是结合了两个项目的bug,由于本人不会JavaScript只是ctrlCV工程师
访问除github之外的连接都有问题,希望这样能让墙通融一下
ivesyi的url的encodeURIComponent改了
href,src,action,后面有可能是个完整http(github release里),有可能是一部分(这个原项目解决),还有直接写死你的网址的(github头像)
css没办法,代理了获取不到,于是没管,勉强能用
然后把这几个问题解决了,发现自己的水平已经把github写死代码里了

请求一位正则仙人,以我水平属实不会了

这个方法是不行了吗?一直报错403 Forbidden: "error code: 1010"

直接post “/v1/chat/completions” 是说没有api key
"error": {
"message": "You didn't provide an API key. You need to provide your API key in an Authorization header using Bearer auth (i.e. Authorization: Bearer YOUR_KEY), or as the password field (with blank username) if you're accessing the API from your browser and are prompted for a username and password. You can obtain an API key from https://platform.openai.com/account/api-keys.",
"type": "invalid_request_error",
"param": null,
"code": null
}
给了api key之后报的是:403 Forbidden: "error code: 1010",看上去是被ban了,但是直接用openai的url是可以的

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.