gh-proxy/README.md

119 lines
3.6 KiB
Markdown
Raw Normal View History

2020-03-22 00:57:39 +00:00
# gh-proxy
2021-04-23 16:30:36 +00:00
2020-03-22 00:57:39 +00:00
## 简介
2020-04-09 14:26:51 +00:00
github release、archive以及项目文件的加速项目支持clone有Cloudflare Workers无服务器版本以及Python版本
2020-03-22 00:57:39 +00:00
2020-03-22 01:14:54 +00:00
## 演示
2020-03-22 05:55:48 +00:00
[https://gh.api.99988866.xyz/](https://gh.api.99988866.xyz/)
2020-03-22 01:14:54 +00:00
2021-04-23 16:30:36 +00:00
演示站为公共服务,如有大规模使用需求请自行部署,演示站有点不堪重负
![imagea272c95887343279.png](https://img.maocdn.cn/img/2021/04/24/imagea272c95887343279.png)
当然也欢迎[捐赠](#捐赠)以支持作者
2020-05-31 07:00:48 +00:00
## python版本和cf worker版本差异
- python版本支持进行文件大小限制超过设定返回原地址 [issue #8](https://github.com/hunshcn/gh-proxy/issues/8)
2021-09-09 13:49:20 +00:00
- python版本支持特定user/repo 封禁/白名单 以及passby [issue #41](https://github.com/hunshcn/gh-proxy/issues/41)
2020-03-22 00:57:39 +00:00
## 使用
2020-04-09 14:26:51 +00:00
直接在copy出来的url前加`https://gh.api.99988866.xyz/`即可
2020-03-22 00:57:39 +00:00
也可以直接访问在input输入
***大量使用请自行部署,以上域名仅为演示使用。***
2022-05-31 17:05:30 +00:00
访问私有仓库可以通过
`git clone https://user:TOKEN@ghproxy.com/https://github.com/xxxx/xxxx` [#71](https://github.com/hunshcn/gh-proxy/issues/71)
2020-03-22 05:55:48 +00:00
以下都是合法输入(仅示例,文件不存在):
2020-03-22 00:57:39 +00:00
2021-04-23 16:30:36 +00:00
- 分支源码https://github.com/hunshcn/project/archive/master.zip
- release源码https://github.com/hunshcn/project/archive/v0.1.0.tar.gz
- release文件https://github.com/hunshcn/project/releases/download/v0.1.0/example.zip
- 分支文件https://github.com/hunshcn/project/blob/master/filename
2020-03-22 00:57:39 +00:00
2021-04-23 16:30:36 +00:00
- commit文件https://github.com/hunshcn/project/blob/1111111111111111111111111111/filename
- gisthttps://gist.githubusercontent.com/cielpy/351557e6e465c12986419ac5a4dd2568/raw/cmd.py
2020-03-22 00:57:39 +00:00
2020-04-09 15:12:40 +00:00
## cf worker版本部署
2020-03-22 00:57:39 +00:00
首页https://workers.cloudflare.com
注册,登陆,`Start building`,取一个子域名,`Create a Worker`。
2022-02-09 14:10:01 +00:00
复制 [index.js](https://cdn.jsdelivr.net/gh/hunshcn/gh-proxy@master/index.js) 到左侧代码框,`Save and deploy`。如果正常,右侧应显示首页。
2020-04-09 14:26:51 +00:00
`ASSET_URL`是静态资源的url实际上就是现在显示出来的那个输入框单页面
`PREFIX`是前缀,默认(根路径情况为"/"如果自定义路由为example.com/gh/*请将PREFIX改为 '/gh/',注意,少一个杠都会错!
2020-04-09 14:26:51 +00:00
## Python版本部署
### Docker部署
2021-04-23 16:30:36 +00:00
2020-04-09 14:26:51 +00:00
```
docker run -d --name="gh-proxy-py" \
-p 0.0.0.0:80:80 \
--restart=always \
hunsh/gh-proxy-py:latest
```
2021-04-23 16:30:36 +00:00
2020-04-09 14:26:51 +00:00
第一个80是你要暴露出去的端口
### 直接部署
2021-04-23 16:30:36 +00:00
2020-04-09 14:26:51 +00:00
安装依赖请使用python3
2020-03-23 15:34:34 +00:00
2020-04-09 14:26:51 +00:00
```pip install flask requests```
2020-03-22 00:57:39 +00:00
2020-04-09 14:26:51 +00:00
按需求修改`app/main.py`的前几项配置
2022-05-31 17:05:30 +00:00
*注意:* 可能需要在`return Response`前加两行
```python3
if 'Transfer-Encoding' in headers:
headers.pop('Transfer-Encoding')
```
2020-04-09 14:26:51 +00:00
### 注意
2020-04-09 14:27:56 +00:00
python版本的机器如果无法正常访问github.io会启动报错请自行修改静态文件url
2021-03-27 12:08:23 +00:00
python版本默认走服务器2021.3.27更新)
2020-04-09 14:26:51 +00:00
## Cloudflare Workers计费
2020-03-22 00:57:39 +00:00
`overview` 页面可参看使用情况。免费版每天有 10 万次免费请求并且有每分钟1000次请求的限制。
如果不够用,可升级到 $5 的高级版本,每月可用 1000 万次请求(超出部分 $0.5/百万次请求)。
2020-03-23 15:34:34 +00:00
## Changelog
2020-04-10 10:32:59 +00:00
* 2020.04.10 增加对`raw.githubusercontent.com`文件的支持
2020-04-09 15:12:40 +00:00
* 2020.04.09 增加Python版本使用Flask
* 2020.03.23 新增了clone的支持
* 2020.03.22 初始版本
2020-03-23 15:34:34 +00:00
2020-03-22 00:57:39 +00:00
## 链接
[我的博客](https://hunsh.net)
## 参考
[jsproxy](https://github.com/EtherDream/jsproxy/)
2021-04-23 16:30:36 +00:00
## 捐赠
![wx.png](https://img.maocdn.cn/img/2021/04/24/image.md.png)
2022-05-31 17:05:30 +00:00
![ali.png](https://www.helloimg.com/images/2021/04/24/BK9vmb.md.png)