Giter Site home page Giter Site logo

gh-proxy's Introduction

gh-proxy

简介

github release、archive以及项目文件的加速项目,支持clone,有Cloudflare Workers无服务器版本以及Python版本

演示

https://gh.api.99988866.xyz/

演示站为公共服务,如有大规模使用需求请自行部署,演示站有点不堪重负

imagea272c95887343279.png

当然也欢迎捐赠以支持作者

python版本和cf worker版本差异

  • python版本支持进行文件大小限制,超过设定返回原地址 issue #8

  • python版本支持特定user/repo 封禁/白名单 以及passby issue #41

使用

直接在copy出来的url前加https://gh.api.99988866.xyz/即可

也可以直接访问,在input输入

大量使用请自行部署,以上域名仅为演示使用。

访问私有仓库可以通过

git clone https://user:[email protected]/https://github.com/xxxx/xxxx #71

以下都是合法输入(仅示例,文件不存在):

cf worker版本部署

首页:https://workers.cloudflare.com

注册,登陆,Start building,取一个子域名,Create a Worker

复制 index.js 到左侧代码框,Save and deploy。如果正常,右侧应显示首页。

ASSET_URL是静态资源的url(实际上就是现在显示出来的那个输入框单页面)

PREFIX是前缀,默认(根路径情况为"/"),如果自定义路由为example.com/gh/*,请将PREFIX改为 '/gh/',注意,少一个杠都会错!

Python版本部署

Docker部署

docker run -d --name="gh-proxy-py" \
  -p 0.0.0.0:80:80 \
  --restart=always \
  hunsh/gh-proxy-py:latest

第一个80是你要暴露出去的端口

直接部署

安装依赖(请使用python3)

pip install flask requests

按需求修改app/main.py的前几项配置

注意: 可能需要在return Response前加两行

if 'Transfer-Encoding' in headers:
    headers.pop('Transfer-Encoding')

注意

python版本的机器如果无法正常访问github.io会启动报错,请自行修改静态文件url

python版本默认走服务器(2021.3.27更新)

Cloudflare Workers计费

overview 页面可参看使用情况。免费版每天有 10 万次免费请求,并且有每分钟1000次请求的限制。

如果不够用,可升级到 $5 的高级版本,每月可用 1000 万次请求(超出部分 $0.5/百万次请求)。

Changelog

  • 2020.04.10 增加对raw.githubusercontent.com文件的支持
  • 2020.04.09 增加Python版本(使用Flask)
  • 2020.03.23 新增了clone的支持
  • 2020.03.22 初始版本

链接

我的博客

参考

jsproxy

捐赠

wx.png ali.png

gh-proxy's People

Contributors

fcying avatar gizmo-ds avatar hunshcn avatar libsgh avatar m4nk1n avatar trumeet avatar xyz8848 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  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

gh-proxy's Issues

测试页面无法打开

curl -v https://gh.api.99988866.xyz/ -i --connect-timeout 10
*   Trying 104.18.36.125:443...
* Connection timed out after 10005 milliseconds
* Closing connection 0
curl: (28) Connection timed out after 10005 milliseconds

A judgment

I use cf-worker version and close "cnpmjs" ,when I visit home page, it occur an error:

cfworker error:
TypeError: Cannot read property 'href' of null
at proxy (worker.js:135:36)
at httpHandler (worker.js:125:12)
at fetchHandler (worker.js:73:16)
at worker.js:49:17

I found the error code:
if(path.search(exp1) === 0 || !Config.cnpmjs && (path.search(exp3) === 0 || path.search(exp4))) I have read and tested code, I think it may should be:
if (path.search(exp1) === 0 || !Config.cnpmjs && (path.search(exp3) === 0 || path.search(exp4) === 0))

Support git push

Cf-worker version doesn't seem to support git push when I close cnpmjs.
Is it possible to fix it?

用curl 获取 releases/latest 的值和 不加proxy的有点不一样.

象下面这样. 用来获取软件最新的版本号.

$ curl https://github.com/BurntSushi/ripgrep/releases/latest
<html><body>You are being <a href="https://github.com/BurntSushi/ripgrep/releases/tag/13.0.0">redirected</a>.</body></html>

现在的效果好像是直接把 重定向后的页面刷出来了

$curl https://gh.api.99988866.xyz/https://github.com/BurntSushi/ripgrep/releases/latest                                                                                                        

<!DOCTYPE html>
<html lang="en" data-color-mode="auto" data-light-theme="light" data-dark-theme="dark">
  <head>
    <meta charset="utf-8">
  <link rel="dns-prefetch" href="https://github.githubassets.com">
  <link rel="dns-prefetch" href="https://avatars.githubusercontent.com">
  <link rel="dns-prefetch" href="https://github-cloud.s3.amazonaws.com">
  <link rel="dns-prefetch" href="https://user-images.githubusercontent.com/">
  <link rel="preconnect" href="https://github.githubassets.com" crossorigin>
  <link rel="preconnect" href="https://avatars.githubusercontent.com">

docker 版的问题还是vps问题?

你的最新源码和dockerfile做了镜像.并启动
jsdelivr = 0
cnpmjs = 0
时 git clone 总提示500错误.
而且直接页面下载经常失败,要刷新几次才行.

后来改为
jsdelivr = 1
cnpmjs = 1
新版的raw.githubusercontent.com支持也报错...

不知道时我vps问题还是镜像问题..求解.

断点下载

我用 wget 测试,好像无法支持断点下载。希望未来能加上支持。

移除github限制

我想用它来加速克隆chromium源码,不知道该怎么修改?

feat: 负载均衡

因为群里大部分人都搞了自己的cf worker,能否添加个类似nginx的upstream或者负载均衡,然后把群里的节点都收集上来,然后做个公益让更多的人用。

Docker 版本使用报错

前台是可以打开的,转很久圈圈后页面显示如下。

server error HTTPSConnectionPool(host='raw.githubusercontent.com', port=443): Max retries exceeded with url: /xxx/xxx/xxx(Caused by NewConnectionError(': Failed to establish a new connection: [Errno -3] Temporary failure in name resolution'))

参数转义问题

使用参数传递 github 下载地址会有转义问题,这个对写脚本会造成一些困扰

...
ENV CATTLE_K3S_VERSION v1.17.2+k3s1

ENV K3S_URL_amd64="https://gh.api.99988866.xyz/?q=https://github.com/rancher/k3s/releases/download/${CATTLE_K3S_VERSION}/k3s" \
    K3S_URL_arm64="https://gh.api.99988866.xyz/?q=https://github.com/rancher/k3s/releases/download/${CATTLE_K3S_VERSION}/k3s-arm64" \
    K3S_URL=K3S_URL_${ARCH} \

由于版本号中有个 +,直接把原地址加个前缀会导致解析出现问题:

地址

https://gh.api.99988866.xyz/?q=https://github.com/rancher/k3s/releases/download/v1.17.2+k3s1/k3s

会跳转至

https://gh.api.99988866.xyz/https:/github.com/rancher/k3s/releases/download/v1.17.2%20k3s1/k3s

然而这个地址是无效的。

当把 + 转义为 %2B 后请求正常:

https://gh.api.99988866.xyz/?q=https://github.com/rancher/k3s/releases/download/v1.17.2%2Bk3s1/k3s

建议能够提供类似 jsdelivr 的路径方式:

https://cdn.jsdelivr.net/gh/rancher/[email protected]+k3s1/k3s

问下 Cloudflare Workers 是否可以指定自选 CDN IP?

搭建 Python 版本毕竟还需要消耗服务器流量,就想着用 Workers 会好点,但是我只知道可以用其他方法给搭建在服务器上的网站指定自选 Cloudflare CDN IP,但是不知道 Workers 是否也能这样做。

特来问一下,这样正好可以用我写的 Cloudflare CDN 测速工具 来获得最快 IP~

Cloudflare 默认分配的给**访客的 IP 比较差,如果可以自选 CDN IP 会好很多。

关于子目录的报错问题

我的环境是Cloudflare Workers.
使用Workers自己的域名,是可以正常访问的。
但是在Clouflare域名设置中开启Workers路由功能后,路由过的域名(也就是api.ineko.cc)就会报error code: 1000的错误。
image
image
我尝试修改了js文件无果。
求解..

cnpmjs设置为0时异常

异常信息

cfworker error:
TypeError: Cannot read property 'href' of null
    at proxy (worker.js:130:36)
    at httpHandler (worker.js:120:12)
    at fetchHandler (worker.js:73:16)
    at worker.js:49:17

建议加上下载文件大小限制

如果需要中转的文件大小较大,有可能长时间消耗服务器网络资源,可以在配置中加上文件大小限制,超出则返回原url。

能否加一下raw之类的链接分解

因为很多脚本都是直接指向了raw(eg:https://raw.githubusercontent.com/hiCasper/Shell/master/AutoReinstall.sh),所以每次都需要先找到原文件复制成https://github.com/hiCasper/Shell/blob/master/AutoReinstall.sh这种链接才可以使用,有一点麻烦,希望可以增加一下

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.