欢迎来到好人卡资源网,专注网络技术资源收集,我们不仅是网络资源的搬运工,也生产原创资源。寻找资源请留言或关注公众号:烈日下的男人

使用sniproxy反代Github的教程

linux sky995 3年前 (2021-01-10) 1999次浏览 0个评论

本文及资源最后更新时间 2021-01-10 by sky995

想在国内VPS上连接Github,但是网络苦不堪言,只有20kb/s。

想要加速访问,有正代和反代两个途径。本文说反代,用sniproxy实现的。

sniproxy项目地址:https://github.com/dlundquist/sniproxy

一、安装sniproxy

Debian/Ubuntu

  1. aptget install y git autotoolsdev cdbs debhelper dhautoreconf dpkgdev gettext libevdev libpcre3dev libudnsdev pkgconfig fakeroot devscripts
  2. git clone https://github.com/dlundquist/sniproxy.git
  3. cd sniproxy
  4. ./autogen.sh && dpkgbuildpackage
  5. dpkg i ../sniproxy_*_*.deb
  6. aptget install y sniproxy

Redhat/CentOS

  1. yum install y git autoconf automake curl gettextdevel libevdevel pcredevel perl pkgconfig rpmbuild udnsdevel
  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配置

打开/etc/sniproxy.conf找到开头就是table https_hosts {这一行

添加两行,分别是 (.*.|)github.com$ *(.*.|)githubusercontent.com$ *

修改好后是下面这个样子

  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

这里说的客户端也就是我开头说的国内VPS

修改/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 api.github.com
  4. 1.1.1.1 www.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 marketplacescreenshots.githubusercontent.com
  18. 1.1.1.1 raw.githubusercontent.com
  19. 1.1.1.1 repositoryimages.githubusercontent.com
  20. 1.1.1.1 userimages.githubusercontent.com

其他

我没有更细致研究sniproxy的配置了,我想看看能不能在配置里只让指定的IP可以访问,不过在GitHub看了一下Issues,好像没看到方法,你们可以研究一下。

嗷嗷目前是用iptables来管理443端口指定IP放行

就这些,完成了。


好人卡资源网 , 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:使用sniproxy反代Github的教程
喜欢 (1)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址