全球主机交流论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

CeraNetworks网络延迟测速工具IP归属甄别会员请立即修改密码
查看: 2328|回复: 21

使用sniproxy反代Github

[复制链接]
发表于 2020-12-30 01:17:14 | 显示全部楼层 |阅读模式
本帖最后由 嗷嗷 于 2020-12-30 12:53 编辑

用sniproxy做的


这是一个TCP4层转发工具


https://github.com/dlundquist/sniproxy


一、安装sniproxy

  1. apt-get install -y git autotools-dev cdbs debhelper dh-autoreconf dpkg-dev gettext libev-dev libpcre3-dev libudns-dev pkg-config fakeroot devscripts
  2. git clone https://github.com/dlundquist/sniproxy.git
  3. cd sniproxy
  4. ./autogen.sh && dpkg-buildpackage
  5. dpkg -i ../sniproxy_*_*.deb
  6. apt-get install -y sniproxy
复制代码

  1. yum install -y git autoconf automake curl gettext-devel libev-devel pcre-devel perl pkgconfig rpm-build udns-devel
  2. git clone https://github.com/dlundquist/sniproxy.git
  3. cd sniproxy
  4. ./autogen.sh && ./configure && make dist
  5. rpmbuild --define "_sourcedir `pwd`" -ba redhat/sniproxy.spec
  6. yum install ../sniproxy-*.*.rpm
  7. yum install -y sniproxy
复制代码


二、修改sniproxy配置


找到开头就是table https_hosts {这一行

修改成下面这样子
  1. # named tables are defined with the table directive
  2. table https_hosts {
  3.     # When proxying to local sockets you should use different tables since the
  4.     # local socket server most likely will not autodetect which protocol is
  5.     # being used
  6.     example.org unix:/var/run/server.sock
  7.     (.*.|)github.com$ *
  8.     (.*.|)githubusercontent.com$ *
  9. }
复制代码


三、启动sniproxy

  1. sniproxy -c /etc/sniproxy.conf
复制代码


关闭:pkill sniproxy


四、在客户端设置hosts

修改/etc/hosts

如果原本有github的hosts配置了,就删除或者注释掉
添加下面的这些,把1.1.1.1改为你启动了sniproxy的VPS的IP

  1. 1.1.1.1 gist.github.com
  2. 1.1.1.1 github.com
  3. 1.1.1.1 www.github.com
  4. 1.1.1.1 api.github.com
  5. 1.1.1.1 avatars0.githubusercontent.com
  6. 1.1.1.1 avatars1.githubusercontent.com
  7. 1.1.1.1 avatars2.githubusercontent.com
  8. 1.1.1.1 avatars3.githubusercontent.com
  9. 1.1.1.1 avatars4.githubusercontent.com
  10. 1.1.1.1 avatars5.githubusercontent.com
  11. 1.1.1.1 avatars6.githubusercontent.com
  12. 1.1.1.1 avatars7.githubusercontent.com
  13. 1.1.1.1 avatars8.githubusercontent.com
  14. 1.1.1.1 camo.githubusercontent.com
  15. 1.1.1.1 cloud.githubusercontent.com
  16. 1.1.1.1 gist.githubusercontent.com
  17. 1.1.1.1 marketplace-screenshots.githubusercontent.com
  18. 1.1.1.1 raw.githubusercontent.com
  19. 1.1.1.1 repository-images.githubusercontent.com
  20. 1.1.1.1 user-images.githubusercontent.com
复制代码


其他

IP add one:https://haoduck.com/713.html


如我上帖子所说:https://www.hostloc.com/thread-790321-1-1.html

我还是更想用nginx来反代,等什么时候闲了,我再试试看自签SSL证书来反代,看看行不行。
 楼主| 发表于 2020-12-30 01:22:30 | 显示全部楼层
本帖最后由 嗷嗷 于 2020-12-30 01:24 编辑

2收藏0回复惨案


发表于 2020-12-30 01:40:03 | 显示全部楼层
支持一下楼主
发表于 2020-12-30 01:54:45 | 显示全部楼层
可以的楼主,解决了我同样的问题,华为的国内小鸡拉git的项目不是一般的慢

我用的方法是先导入到coding,再去拉,比这个麻烦不少
发表于 2020-12-30 01:56:05 来自手机 | 显示全部楼层
nginx也有layer 4反代呀,透過sni來分流
 楼主| 发表于 2020-12-30 02:31:10 | 显示全部楼层
s920361 发表于 2020-12-30 01:56
nginx也有layer 4反代呀,透過sni來分流

这个我知道,但是要添加模块编译,我感觉有一点麻烦,之前用过,没有成功。这两天再研究一下
发表于 2020-12-30 03:09:27 来自手机 | 显示全部楼层
提示: 作者被禁止或删除 内容自动屏蔽
发表于 2020-12-30 03:12:12 来自手机 | 显示全部楼层
推荐nginx官方docker镜像 nginx:alpine 四层模块都做好了的 用着很方便
您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|小黑屋|全球主机交流论坛

GMT+8, 2024-4-23 15:12 , Processed in 0.061845 second(s), 8 queries , Gzip On, MemCache On.

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表