用Go语言重写了gh-proxy加速
2024-8-17 23:21:0 Author: www.upx8.com(查看原文) 阅读量:13 收藏

支持 git clone , wget , curl
Dome:gh.jiasu.in
测试:https://gh.jiasu.in/https://github.com/0-RTT/telegraph/blob/main/worker.js

源码:https://github.com/0-RTT/ghproxy-go

安装go

sudo apt update
sudo apt upgrade
wget https://golang.org/dl/go1.22.5.linux-amd64.tar.gz
sudo tar -C /usr/local -xzf go1.22.5.linux-amd64.tar.gz
sudo nano /etc/profile
export PATH=$PATH:/usr/local/go/bin
source /etc/profile
go version

配置ghproxy.service

sudo bash -c 'cat << EOF > /etc/systemd/system/ghproxy.service
[Unit]
Description=ghproxy
After=network.target

[Service]
ExecStart=/usr/local/go/bin/go run /main.go所在路径
Restart=always
User=root
Group=root
WorkingDirectory=/main.go所在路径

[Install]
WantedBy=multi-user.target
EOF'

示例:

[Unit]
Description=ghproxy
After=network.target

[Service]
ExecStart=/usr/local/go/bin/go run /www/wwwroot/gh.jiasu.in/main.go
Restart=always
User=root
Group=root
WorkingDirectory=/www/wwwroot/gh.jiasu.in

[Install]
WantedBy=multi-user.target

设置开机自启:systemctl enable ghproxy.service

启动:systemctl start ghproxy.service

重启:systemctl restart ghproxy.service

查询运行状态:systemctl status ghproxy.service

配置nginx反代

    
    location / {
        proxy_pass http://127.0.0.1:8080;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
    }

CF worker版:https://github.com/0-RTT/ghproxy


文章来源: https://www.upx8.com/4285
如有侵权请联系:admin#unsafe.sh