2010
01.05

My Linux Gateway

My Linux Gateway

使用透明网关,将web流量通过squid走,cache之后可以提高家里机器访问web的速度。

通过squid配置,将被墙的站点设置成通过SSH隧道走。但squid本身不能forward给socks5代理,因此中间加了个privoxy中转。被墙的站点也可以在squid缓存,节省流量。

如果所有的web访问都通过SSH隧道,访问国内的站点慢了。不仅会反向被墙还浪费海外主机的流量。

没有海外主机的时候,SSH隧道可以用TOR替代。

https不可以做透明代理,这时候需要将浏览器的proxy设置到网关的squid。

图上没标出,网关上还安装有bind,提供域名解析服务,用来对付DNS解析被篡改的问题。

现在这个硬件用的是Asus EeeBox b202,安静省电。

  1. [...] This post was mentioned on Twitter by Yining, 无网不剩. 无网不剩 said: RT @yining: shared My Linux Gateway: 使用透明网关,将web流量通过squid走,cache之后可以提高家里机器访问web的速度。 通过squid配置,将被墙的站点设置成通过SSH隧道走。但squ.. http://bit.ly/7xr0If [...]

  2. 求squid的详细配置,我的方案基本跟你的一致,只是dns的部分没有用重量级的bind,用了轻量级的dnsmasq。

  3. 就是加了个cache_peer,发现被墙的站点就在配置文件里加入,然后reload squid就好。后面是squid配置片段

    http_port 3128 transparent
    ...
    
    ##########
    cache_peer localhost parent 8118 7 no-query default
    
    #prefer_direct on
    nonhierarchical_direct off
    #never_direct allow all
    
    # youtube
    cache_peer_domain localhost .youtube.com
    cache_peer_domain localhost .ytimg.com
    cache_peer_domain localhost .googlevideo.com
    
    # twitter
    cache_peer_domain localhost .twitter.com
    
    # facebook
    cache_peer_domain localhost .facebook.com
    
    # blogger, blogspot
    cache_peer_domain localhost .blogger.com
    cache_peer_domain localhost .blogspot.com
    
    # shorturl
    cache_peer_domain localhost .bit.ly
    cache_peer_domain localhost .ff.im
    ...