Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 3b8ea7e

Browse files
committedNov 29, 2023
Initial commit
Created from https://vercel.com/new
0 parents  commit 3b8ea7e

9 files changed

+88
-0
lines changed
 

‎README.md

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# vercel-reverse-proxy
2+
[English README](./README_EN.md)
3+
4+
本项目是vercel反向代理。完全免费,万能代理,可代理全网一切接口,包括openai、github、google等等。http和https接口、单页面均可代理,在网络环境不好的情况下均可用。(直接浏览器打开代理页面的情况下,由于某些js和css的路径可能会不对造成访问不到,页面样式有点小问题。)
5+
6+
vercel现在每月有100GB的免费流量。本人又基于[cloudflare](https://www.cloudflare.com/)搞了一个反向代理,仓库地址:[cloudflare-reverse-proxy](https://github.com/gaboolic/cloudflare-reverse-proxy)供大家参考,也作为一个备份吧。
7+
我自己的vercel项目部署失败,疑似被ban,各位别直接一键部署了,先fork到自己的仓库改改项目名 删掉readme试试吧。实在不行 移步上面cloudflare项目,cloudflare的格局比较大
8+
9+
## 部署
10+
[![Vercel](https://vercel.com/button)](https://vercel.com/import/project?template=https://github.com/gaboolic/vercel-reverse-proxy)
11+
12+
13+
## 使用方法
14+
1 部署。部署有两种方法,一是直接点击上方按钮一键部署,二是可以先fork本项目,再登录[vercel](https://vercel.com/)网站新建。vercel可以通过github一键注册只需要绑定手机号支持cn
15+
![新建项目](img/newproject.png)
16+
17+
2 绑定自己的域名(不是必须,使用vercel自带的子域名也可以,但是自带的域名vercel.app在国内网络环境不好的情况下不可用) 可以申请[tk免费域名](http://www.dot.tk/)或者薅小域名注册商首年免费羊毛
18+
![绑定域名](img/domain.png)
19+
绑定域名时按照vercel上的说明配置即可,其实就是在你的域名上配了一个子域名,cname到vercel服务器
20+
21+
3 访问 域名/proxy/url 或者/httpproxy/url即可。
22+
映射规则为/proxy/url映射到https接口,/httpproxy/url映射到http接口
23+
24+
## 示例
25+
例1 访问https://替换为你自己的域名.com/proxy/api.openai.com/v1/chat/completions
26+
实际上会替换为https://api.openai.com/v1/chat/completions
27+
![demo1](img/demo1.png)
28+
29+
如何在一些常见的开源项目中使用?
30+
一般开源项目都是引用的openai的库,可以看到里面有一个属性是api_base = os.environ.get("OPENAI_API_BASE", "https://api.openai.com/v1")
31+
32+
所以使用的时候只需要设置一下openai.api_base="https://你的域名/proxy/api.openai.com/v1" 就可以了
33+
34+
例2 访问https://替换为你自己的域名.com/proxy/raw.githubusercontent.com/gaboolic/vercel-reverse-proxy/main/vercel.json
35+
实际上会替换为https://raw.githubusercontent.com/gaboolic/vercel-reverse-proxy/main/vercel.json
36+
![demo2](img/demo2.png)
37+
映射规则为/proxy/url映射到https接口,/httpproxy/url映射到http接口
38+
39+
也可用于github下载加速。假如原始链接是https://objects.githubusercontent.com/github-production-release-asset-2e65be/xxxxxx
40+
改为https://替换为你自己的域名.com/proxy/objects.githubusercontent.com/github-production-release-asset-2e65be/xxxxxx 就可以加速了。下图是github原始链接和加速后对比。可以看到效果杠杠的,每秒50kb小水管变成了每秒2mb的大水管
41+
![github-download](img/github-download.png)
42+
43+
例3 访问https://替换为你自己的域名.com/proxy/www.google.com/search?q=vercel-reverse-proxy
44+
实际上会替换为https://www.google.com/search?q=vercel-reverse-proxy
45+
![demo3](img/demo3.png)
46+
代理google搜索结果页面

‎README_EN.md

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# vercel-reverse-proxy
2+
[简体中文](./README.md)
3+
4+
This project is a Vercel reverse proxy. It's completely free and an all-purpose proxy that can handle all interfaces on the internet, including OpenAI, GitHub, Google, and more. Both HTTP and HTTPS interfaces as well as single pages can be proxied and used in poor network environments. (When accessing the proxy page directly from a browser, some JS and CSS paths may not work correctly causing access issues and minor styling problems.)
5+
## Deploy
6+
[![Vercel](https://vercel.com/button)](https://vercel.com/import/project?template=https://github.com/gaboolic/vercel-reverse-proxy)
7+
8+
9+
## How to Use
10+
1 Deployment. There are two methods for deployment: one is to directly click the button above for one-click deployment, and the other is to first fork this project and then log in [vercel](https://vercel.com/) to create new one.
11+
![new project](img/newproject.png)
12+
13+
2 Bind your own domain name (not mandatory, you can also use Vercel's built-in subdomain, but the built-in domain vercel.app may not be accessible in poor network conditions in China).
14+
![domain](img/domain.png)
15+
When binding a domain, simply follow the instructions on Vercel to configure it. Essentially, you are setting up a subdomain on your domain and pointing its CNAME record to the Vercel server.
16+
3 To visit the https://yourdomain.com/proxy/url, or https://yourdomain.com/httpproxy/url.
17+
The mapping rule is to map /proxy/url to the https interface, and /httpproxy/url to the http interface.
18+
19+
20+
demo1: visit https://yourdomain.com/proxy/api.openai.com/v1/chat/completions
21+
Actually will be replaced with https://api.openai.com/v1/chat/completions
22+
![demo1](img/demo1.png)
23+
24+
demo2: visit https://yourdomain.com/proxy/raw.githubusercontent.com/gaboolic/vercel-reverse-proxy/main/vercel.json
25+
Actually will be replaced with https://raw.githubusercontent.com/gaboolic/vercel-reverse-proxy/main/vercel.json
26+
![demo2](img/demo2.png)
27+
The mapping rule is to map /proxy/url to the https interface, and /httpproxy/url to the http interface.
28+
29+
demo3: visit https://yourdomain.com/proxy/www.google.com/search?q=vercel-reverse-proxy
30+
Actually will be replaced with https://www.google.com/search?q=vercel-reverse-proxy
31+
![demo3](img/demo3.png)
32+
Reverse proxy Google search results page.
33+
34+

‎img/demo1.png

559 KB
Loading

‎img/demo2.png

133 KB
Loading

‎img/demo3.png

951 KB
Loading

‎img/domain.png

616 KB
Loading

‎img/github-download.png

145 KB
Loading

‎img/newproject.png

442 KB
Loading

‎vercel.json

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"rewrites": [
3+
{ "source": "/proxy/:match/:url*", "destination": "https://:match/:url*" },
4+
{ "source": "/proxy/:match/:url*/", "destination": "https://:match/:url*/" },
5+
{ "source": "/httpproxy/:match/:url*", "destination": "http://:match/:url*" },
6+
{ "source": "/httpproxy/:match/:url*/", "destination": "http://:match/:url*/" }
7+
]
8+
}

0 commit comments

Comments
 (0)
Please sign in to comment.