当前位置: 代码迷 >> PB >> Play Raspberry Pi(二)Proxy Server in US
  详细解决方案

Play Raspberry Pi(二)Proxy Server in US

热度:1656   发布时间:2016-04-29 05:21:30.0
Play Raspberry Pi(2)Proxy Server in US
Play Raspberry Pi(2)Proxy Server in US
?
Reading a lot of documents.?
?
There are something really helpful.
In?https://github.com/zhuzhuor/Unblock-Youku, there is some example of nodeJS proxy.
?
And I may also get some idea from here to write the proxy + router logic together.
https://github.com/nodejitsu/node-http-proxy
https://github.com/wallproxy/wallproxy
?
?
Also,?squid seems to be a good logic handler and cache provider. I will check on that.
?
The problem is that my raspberry pi is in US, I plan to router back to China only for some websites for speed up.
?
We can also use nginx to do the routing I guess.?
http://www.cnblogs.com/edisonchou/p/4126742.html
http://bigc.at/reverse-proxy.orz
?
nginx proxy
http://blog.chinaunix.net/uid-10540984-id-3074799.html
http://itoedr.blog.163.com/blog/static/1202842972013021107564/
?
squid work with pac
https://github.com/zhuzhuor/Unblock-Youku/wiki/%E8%AE%A9Squid%E5%B8%A6%E6%9C%89Unblock-Youku%E5%8A%9F%E8%83%BD
?
1. Start to Config and Use Squid
Official website
http://www.squid-cache.org/
?
I decide to download the source file and compile myself on my ubuntu-pilot, I choose this version>
http://www.squid-cache.org/Versions/v3/3.4/squid-3.4.10.tar.gz
?
Install the compile c tool if I do not have, actually this is my latest ubuntu 10 14 pilot machine, I need to install that.
>sudo apt-get install build-essential
?
use configure, make, make install to install that.
?
https://www.suse.com/zh-cn/documentation/sles11/singlehtml/book_sle_admin/cha.squid.html#sec.squid.start
https://www.suse.com/zh-cn/documentation/sles11/singlehtml/book_sle_admin/cha.squid.html#sec.squid.acl
http://blog.sina.com.cn/s/blog_710236d201012xuu.html
http://blog.csdn.net/crazyhan00/article/details/8024817
?
Check the cache directory
> squid -z
?
Check the configuration file
> squid -k parse
?
Start the Server in command Line
> squid -N -dl
?
Start the Squid in daemon mode
> squid -s
?
Command to shutdown the squid
> squid -k shutdown
?
Reload the configuration
> squid -k reconfigure
?
Proxy Auto-Configuration ?PAC
http://scm.zoomquiet.io/data/20071028213637/index.html
http://wolaos123.blog.163.com/blog/static/102651333201002092424761/
http://zhiwei.li/text/2013/12/%E7%94%A8%E4%BB%A3%E7%90%86%E8%87%AA%E5%8A%A8%E9%85%8D%E7%BD%AE%E6%96%87%E4%BB%B6pac%E7%BB%99iphone%E5%92%8Cipad%E8%AE%BE%E5%A4%87%E6%B7%BB%E5%8A%A0socks%E4%BB%A3%E7%90%86/
?
One example pac file is as follow:
/*
? Installing/using this software, you agree that this software is
? only for study purposes and its authors and service providers
? take no responsibilities for any consequences.
*/
function _check_regex_list(i,o){
? var c;
? for(c=0;c<i.length;c++){
?? if(i[c].test(o)){
??? return!0;
?? }
?? return!1
? }
}
?
function _check_patterns(i,o,c,p){
?return i.hasOwnProperty(o)&&_check_regex_list(i[o],c.slice(p+o.length))?!0:_check_regex_list(i.any,c.slice(p))?!0:!1
}
?
function _find_proxy(i,o,c,p){
?return _check_patterns(i.white,o,c,p)?"DIRECT":_check_patterns(i.proxy,o,c,p)?_proxy_str:"DIRECT"
}
?
function FindProxyForURL(i,o){
?var c=i.slice(0,6);
?return"http:/"===c?_find_proxy(_http_map,o,i,7):"https:"===c?_find_proxy(_https_map,o,i,8):"DIRECT"
}
?
var _http_map={
?white:{any:[/^[^/]*\/ipad\?file=\//i]},
?proxy:{
? any:[/^[^/]*\.dpool\.sina\.com\.cn\/iplookup/i,/^[^/]*\/vrs_flash\.action/i],
? "v.youku.com":[/^\/player\//i],
? "api.youku.com":[/^\/player\//i],
? "v2.tudou.com":[/^\//i],
? "www.tudou.com":[/^\/a\//i,/^\/v\//i,/^\/outplay\/goto\/getTvcCode/i,/^\/tvp\/alist\.action/i],
? "s.plcloud.music.qq.com":[/^\/fcgi\-bin\/p\.fcg/i],
? "hot.vrs.sohu.com":[/^\//i],
? "live.tv.sohu.com":[/^\/live\/player/i],
? "pad.tv.sohu.com":[/^\/playinfo/i],
? "my.tv.sohu.com":[/^\/play\/m3u8version\.do/i],
? "hot.vrs.letv.com":[/^\//i],
? "data.video.qiyi.com":[/^\/v\./i],
? "cache.video.qiyi.com":[/^\/vms\?/i],
? "cache.vip.qiyi.com":[/^\/vms\?/i],
? "vv.video.qq.com":[/^\//i,/^\/getvinfo/i,/^\/getinfo/i,/^\/geturl/i],
? "tt.video.qq.com":[/^\/getvinfo/i],
? "ice.video.qq.com":[/^\/getvinfo/i],
? "tjsa.video.qq.com":[/^\/getvinfo/i],
? "a10.video.qq.com":[/^\/getvinfo/i],
? "xyy.video.qq.com":[/^\/getvinfo/i],
? "vcq.video.qq.com":[/^\/getvinfo/i],
? "vsh.video.qq.com":[/^\/getvinfo/i],
? "vbj.video.qq.com":[/^\/getvinfo/i],
? "bobo.video.qq.com":[/^\/getvinfo/i],
? "flvs.video.qq.com":[/^\/getvinfo/i],
? "bkvv.video.qq.com":[/^\/getvinfo/i],
? "geo.js.kankan.xunlei.com":[/^\//i],
? "web-play.pptv.com":[/^\//i],
? "web-play.pplive.cn":[/^\//i],
? "dyn.ugc.pps.tv":[/^\//i],
? "v.pps.tv":[/^\/ugc\/ajax\/aj_html5_url\.php/i],
? "inner.kandian.com":[/^\//i],
? "ipservice.163.com":[/^\//i],
? "so.open.163.com":[/^\/open\/info\.htm/i],
? "zb.s.qq.com":[/^\//i],
? "ip.kankan.xunlei.com":[/^\//i],
? "vxml.56.com":[/^\/json\//i],
? "music.sina.com.cn":[/^\/yueku\/intro\//i,/^\/radio\/port\/webFeatureRadioLimitList\.php/i],
? "play.baidu.com":[/^\/data\/music\/songlink/i],
? "v.iask.com":[/^\/v_play\.php/i,/^\/v_play_ipad\.cx\.php/i],
? "tv.weibo.com":[/^\/player\//i],
? "wtv.v.iask.com":[/^\/.*\.m3u8$/i,/^\/mcdn\.php$/i],
? "video.sina.com.cn":[/^\/interface\/l\/u\/getFocusStatus\.php/i],
? "www.yinyuetai.com":[/^\/insite\//i,/^\/main\/get\-/i],
? "api.letv.com":[/^\/streamblock/i,/^\/mms\/out\/video\/play/i,/^\/mms\/out\/common\/geturl/i,/^\/geturl/i,/^\/api\/geturl/i,/^\/getipgeo$/i],
? "live.gslb.letv.com":[/^\/gslb\?/i],
? "static.itv.letv.com":[/^\/api/i],
? "ip.apps.cntv.cn":[/^\/js\/player\.do/i],
? "vdn.apps.cntv.cn":[/^\/api\/get/i,/^\/api\/getLiveUrlCommonApi\.do\?pa:\/\/cctv_p2p_hdcctv5/i,/^\/api\/getLiveUrlCommonApi\.do\?pa:\/\/cctv_p2p_hdcctv6/i,/^\/api\/getLiveUrlCommonApi\.do\?pa:\/\/cctv_p2p_hdcctv8/i,/^\/api\/getLiveUrlCommonApi\.do\?pa:\/\/cctv_p2p_hdbtv6/i],
? "vdn.live.cntv.cn":[/^\/api2\/liveHtml5\.do\?channel=pa:\/\/cctv_p2p_hdcctv5/i,/^\/api2\/liveHtml5\.do\?channel=pa:\/\/cctv_p2p_hdcctv6/i,/^\/api2\/liveHtml5\.do\?channel=pa:\/\/cctv_p2p_hdcctv8/i,/^\/api2\/liveHtml5\.do\?channel=pa:\/\/cctv_p2p_hdbtv6/i,/^\/api2\/live\.do\?channel=pa:\/\/cctv_p2p_hdcctv5/i,/^\/api2\/live\.do\?channel=pa:\/\/cctv_p2p_hdcctv6/i,/^\/api2\/live\.do\?channel=pa:\/\/cctv_p2p_hdcctv8/i,/^\/api2\/live\.do\?channel=pa:\/\/cctv_p2p_hdbtv6/i],
? "vip.sports.cntv.cn":[/^\/check\.do/i,/^\/play\.do/i,/^\/servlets\/encryptvideopath\.do/i,/^\/servlets\/encryptvideopath\.do/i],
? "211.151.157.15":[/^\//i],
? "a.play.api.3g.youku.com":[/^\/common\/v3\/play\?/i],
? "i.play.api.3g.youku.com":[/^\/common\/v3\/hasadv\/play\?/i],
? "api.3g.youku.com":[/^\/layout/i,/^\/v3\/play\/address/i,/^\/openapi\-wireless\/videos\/.*\/download/i,/^\/videos\/.*\/download/i,/^\/common\/v3\/play/i],
? "tv.api.3g.youku.com":[/^\/openapi\-wireless\/v3\/play\/address/i,/^\/common\/v3\/hasadv\/play/i,/^\/common\/v3\/play/i],
? "play.api.3g.youku.com":[/^\/common\/v3\/hasadv\/play/i,/^\/common\/v3\/play/i,/^\/v3\/play\/address/i],
? "play.api.3g.tudou.com":[/^\/v/i],
? "tv.api.3g.tudou.com":[/^\/tv\/play\?/i],
? "api.3g.tudou.com":[/^\//i],
? "api.tv.sohu.com":[/^\/mobile_user\/device\/clientconf\.json\?/i],
? "access.tv.sohu.com":[/^\//i],
? "iface.iqiyi.com":[/^\/api\/searchIface\?/i],
? "iface2.iqiyi.com":[/^\/php\/xyz\/iface\//i,/^\/php\/xyz\/entry\/galaxy\.php\?/i,/^\/php\/xyz\/entry\/nebula\.php\?/i],
? "cache.m.iqiyi.com":[/^\/jp\/tmts\//i],
? "dynamic.app.m.letv.com":[/^\/.*\/dynamic\.php\?.*ctl=videofile/i],
? "dynamic.meizi.app.m.letv.com":[/^\/.*\/dynamic\.php\?.*ctl=videofile/i],
? "dynamic.search.app.m.letv.com":[/^\/.*\/dynamic\.php\?.*ctl=videofile/i],
? "dynamic.live.app.m.letv.com":[/^\/.*\/dynamic\.php\?.*act=canplay/i],
? "listso.m.areainfo.ppstream.com":[/^\/ip\/q\.php/i],
? "epg.api.pptv.com":[/^\/detail\.api\?/i],
? "play.api.pptv.com":[/^\/boxplay\.api\?/i],
? "m.letv.com":[/^\/api\/geturl\?/i],
? "interface.bilibili.com":[/^\/playurl\?/i],
? "3g.music.qq.com":[/^\//i],
? "mqqplayer.3g.qq.com":[/^\//i],
? "proxy.music.qq.com":[/^\//i],
? "proxymc.qq.com":[/^\//i],
? "ip2.kugou.com":[/^\/check\/isCn\//i],
? "ip.kugou.com":[/^\/check\/isCn\//i],
? "client.api.ttpod.com":[/^\/global/i],
? "mobi.kuwo.cn":[/^\//i],
? "mobilefeedback.kugou.com":[/^\//i],
? "tingapi.ting.baidu.com":[/^\/v1\/restserver\/ting\?.*method=baidu\.ting\.song/i],
? "music.baidu.com":[/^\/data\/music\/links\?/i],
? "serviceinfo.sdk.duomi.com":[/^\/api\/serviceinfo\/getserverlist/i],
? "music.163.com":[/^\/api\/copyright\/restrict\/\?/i,/^\/api\/batch$/i],
? "www.xiami.com":[/^\/web\/spark/i,/^\/web\/.*\?.*xiamitoken=/i],
? "spark.api.xiami.com":[/^\/api\?.*method=AuthIp/i,/^\/api\?.*method=Start\.init/i,/^\/api\?.*method=Songs\.getTrackDetail/i,/^\/api\?.*method=Songs\.detail/i],
? "iplocation.geo.qiyi.com":[/^\/cityjson$/i],
? "sns.video.qq.com":[/^\/tunnel\/fcgi\-bin\/tunnel/i],
? "v5.pc.duomi.com":[/^\/single\-ajaxsingle\-isban/i],
? "tms.is.ysten.com":[/^:8080\/yst\-tms\/login\.action\?/i],
? "chrome.2345.com":[/^\/dianhua\/mobileApi\/check\.php$/i],
? "internal.check.duokanbox.com":[/^\/check\.json/i],
? "180.153.225.136":[/^\//i],
? "118.244.244.124":[/^\//i],
? "210.129.145.150":[/^\//i],
? "182.16.230.98":[/^\//i]
? }
?};
?
?var _https_map={
? white:{any:[]},
? proxy:{
?? any:[],
?? "openapi.youku.com":[/^\//i],
?? "61.135.196.99":[/^\//i],
?? "220.181.185.150":[/^\//i],
?? "111.13.127.46":[/^\//i],
?? "211.151.50.10":[/^\//i],
?? "123.126.99.57":[/^\//i],
?? "123.126.99.39":[/^\//i],
?? "220.181.154.137":[/^\//i],
?? "httpbin.org":[/^\//i]
? }
};
?
var _proxy_str="PROXY xxx.xxx.com:3128";
?
Squid Proxy Configuration
#
#recommended minimum configuration:
#
?
acl SSL_ports port 443
acl Safe_ports port 80????????? # http
acl Safe_ports port 21????????? # ftp
acl Safe_ports port 443????????? # https
acl Safe_ports port 70????????? # gopher
acl Safe_ports port 210????????? # wais
acl Safe_ports port 1025-65535???? # unregistered ports
acl Safe_ports port 280????????? # http-mgmt
acl Safe_ports port 488????????? # gss-http
acl Safe_ports port 591????????? # filemaker
acl Safe_ports port 777????????? # multiling http
acl CONNECT method CONNECT
?
#
# Recommended minimum Access Permission configuration:
#
# Deny requests to certain unsafe ports
http_access deny !Safe_ports
?
# Deny CONNECT to other than secure SSL ports
http_access deny CONNECT !SSL_ports
?
http_access allow localhost manager
?
#
# INSERT YOUR OWN RULE(S) HERE TO ALLOW ACCESS FROM YOUR CLIENTS
#
acl china_video url_regex -i "/opt/squid/etc/china_video.rules"
?
never_direct allow china_video
cache_peer proxy.uku.im parent 8888 0 no-query default
cache_peer_access proxy.uku.im allow china_video
cache_peer_access proxy.uku.im deny all
?
# Example rule allowing access from your local networks.
# Adapt localnet in the ACL section to list your (internal) IP networks
# from where browsing should be allowed
http_access allow all
?
?
# Squid normally listens to port 3128
http_port 3128
?
# Uncomment and adjust the following to add a disk cache directory.
cache_dir ufs /home/carl/tool/squid-3.4.10/var/cache/squid 100 16 256
?
# Leave coredumps in the first cache dir
coredump_dir /home/carl/tool/squid-3.4.10/var/cache/squid
?
access_log /opt/squid/var/logs/access.log all
?
#
# Add any of your own refresh_pattern entries above these.
#
refresh_pattern ^ftp:????????? 1440???? 20%???? 10080
refresh_pattern ^gopher:???? 1440???? 0%???? 1440
refresh_pattern -i (/cgi-bin/|\?) 0???? 0%???? 0
refresh_pattern .????????? 0???? 20%???? 4320
?
Rules:
^http://v.youku.com/player/
^http://api.youku.com/player/
^http://v2.tudou.com/
^http://www.tudou.com/a/
^http://www.tudou.com/v/
^http://s.plcloud.music.qq.com/fcgi-bin/p.fcg
^http://hot.vrs.sohu.com/
^http://live.tv.sohu.com/live/player
^http://hot.vrs.letv.com/
^http://g3.letv.cn/
^http://data.video.qiyi.com/
^http://220.181.61.229/
^http://61.135.183.45/
^http://61.135.183.46/
^http://220.181.19.218/
^http://220.181.61.213/
^http://220.181.118.181/
^http://123.126.48.47/
^http://123.126.48.48/
^http://vv.video.qq.com/
^http://bobo.video.qq.com/
^http://flvs.video.qq.com/
^http://ice.video.qq.com/
^http://bkvv.video.qq.com/
^http://geo.js.kankan.xunlei.com/
^http://web-play.pptv.com/
^http://web-play.pplive.cn/
^http://dyn.ugc.pps.tv/
^http://inner.kandian.com/
^http://ipservice.163.com/
^http://zb.s.qq.com/
^http://ip.kankan.xunlei.com/
^http://music.sina.com.cn/yueku/intro/
^http://music.sina.com.cn/radio/port/webFeatureRadioLimitList.php
^http://play.baidu.com/data/music/songlink
^http://v.iask.com/v_play.php
^http://v.iask.com/v_play_ipad.cx.php
^http://tv.weibo.com/player/
^http://www.yinyuetai.com/insite/
^http://www.yinyuetai.com/main/get-video-info
^http://.*.dpool.sina.com.cn/iplookup
^http://.*/vrs_flash.action
^http://.*/?prot=2&type=1
^http://.*/?prot=2&file=/
^http://vdn.apps.cntv.cn/api/get
^http://api.3g.youku.com/layout
^http://api.tv.sohu.com/
^http://access.tv.sohu.com/
^http://3g.music.qq.com/
^http://mqqplayer.3g.qq.com/
^http://proxy.music.qq.com/
^http://api.3g.tudou.com/
^http://mobi.kuwo.cn/
^http://mobilefeedback.kugou.com/
^http://tingapi.ting.baidu.com/v1/restserver/ting\?.*method=baidu.ting.song
^http://api.3g.youku.com/v3/play/address
^http://api.3g.youku.com/openapi-wireless/videos/.*/download
^http://api.3g.youku.com/videos/.*/download
^http://play.api.3g.tudou.com/v3_1/
^http://iface2.iqiyi.com/php/xyz/iface/
^http://180.153.225.136/
^http://118.244.244.124/
^http://210.129.145.150/
?
Not perfect, only qq video works. I may adjust the rules and other things later.
?
References:
https://github.com/nodejitsu/node-http-proxy
http://www.cnblogs.com/sunli/archive/2010/12/23/node_js.html
http://hi.baidu.com/vsoltwkngxbbizq/item/2c7e77885d7c6723110ef343
http://blog.csdn.net/zhangxin09/article/details/37663091
?
squid
http:[email protected]/blog/static/2835133420112149294914/
http://kevinkelly.blog.163.com/blog/static/21390809320136985054874/
?
Setup the NODEJS project
http://sillycat.iteye.com/blog/2150867
http://sillycat.iteye.com/blog/2155801
https://github.com/luohuazju/winner-seller-console/tree/master/order-rest-api
https://github.com/gulpjs/gulp/blob/master/docs/getting-started.md#getting-started
?
http://markgoodyear.com/2014/01/getting-started-with-gulp/
?
video
https://github.com/zhuzhuor/Unblock-Youku
https://github.com/zhuzhuor/Unblock-Youku/blob/master/server/server.js
https://github.com/wallproxy/wallproxy
http://blog.changecong.com/2013/10/raspberry-pi-shumeipai-tupozhongguoipxianzhi-squid-unblock-youku/
http://proxy-list.org/english/index.php
  相关解决方案