全球主机交流论坛

标题: 使用sniproxy反代Github [打印本页]

作者: 嗷嗷    时间: 2020-12-30 01:17
标题: 使用sniproxy反代Github
本帖最后由 嗷嗷 于 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://hostloc-workers.ikyomon.com/thread-790321-1-1.html

我还是更想用nginx来反代,等什么时候闲了,我再试试看自签SSL证书来反代,看看行不行。
作者: 嗷嗷    时间: 2020-12-30 01:22
本帖最后由 嗷嗷 于 2020-12-30 01:24 编辑

2收藏0回复惨案



作者: zxxx    时间: 2020-12-30 01:24
收藏备用。
作者: CCCP    时间: 2020-12-30 01:40
支持一下楼主
作者: etc小号    时间: 2020-12-30 01:54
可以的楼主,解决了我同样的问题,华为的国内小鸡拉git的项目不是一般的慢

我用的方法是先导入到coding,再去拉,比这个麻烦不少
作者: s920361    时间: 2020-12-30 01:56
nginx也有layer 4反代呀,透過sni來分流
作者: dole    时间: 2020-12-30 02:00
好东西
作者: 嗷嗷    时间: 2020-12-30 02:31
s920361 发表于 2020-12-30 01:56
nginx也有layer 4反代呀,透過sni來分流

这个我知道,但是要添加模块编译,我感觉有一点麻烦,之前用过,没有成功。这两天再研究一下
作者: mryin    时间: 2020-12-30 03:09
提示: 作者被禁止或删除 内容自动屏蔽
作者: Laa    时间: 2020-12-30 03:12
推荐nginx官方docker镜像 nginx:alpine 四层模块都做好了的 用着很方便
作者: hcyme    时间: 2020-12-30 06:13
研究学习科学技术
作者: suichang    时间: 2020-12-30 07:36
haproxy做这个不错
作者: wqz    时间: 2020-12-30 08:37
sniproxy貌似不能监听非80/443端口?
我还是倾向于gost或者iptables直接做端口转发来反代...
作者: 嗷嗷    时间: 2020-12-30 10:22
wqz 发表于 2020-12-30 08:37
sniproxy貌似不能监听非80/443端口?
我还是倾向于gost或者iptables直接做端口转发来反代... ...

iptables可以做到不同域名转发到不同IP吗,我不太了解
作者: 嗷嗷    时间: 2020-12-30 10:27
mryin 发表于 2020-12-30 03:09
问一下楼主,这个能反代一些不能访问的网站吗

可以⁢⁢⁢⁢⁢⁢⁢⁢⁢⁢⁢⁢⁢⁢⁢⁢⁢⁢
作者: wqz    时间: 2020-12-30 11:21
嗷嗷 发表于 2020-12-30 10:22
iptables可以做到不同域名转发到不同IP吗,我不太了解

iptables只能对ip转发,无法做到识别域名 但是拿来转发CF还是可以的
作者: ultramancliub    时间: 2020-12-30 11:35
支持一下楼主
作者: mryin    时间: 2020-12-30 14:33
提示: 作者被禁止或删除 内容自动屏蔽
作者: Skywalker    时间: 2020-12-30 14:47
早就玩过了,当年反代google搜索那一套,先是nginx proxy_pass 然后有折腾这个
作者: 镜子里的我    时间: 2020-12-30 22:09
看看,支持一下
作者: ultramancliub    时间: 2020-12-31 18:41
嗷嗷 发表于 2020-12-30 01:22
2收藏0回复惨案

教程非常实用,战略性MARK
作者: jiangcuo    时间: 2020-12-31 18:45
nginx有stream模块




欢迎光临 全球主机交流论坛 (https://hostloc-workers.ikyomon.com/) Powered by Discuz! X3.4