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.
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.
nginx proxy
squid work with pac
1. Start to Config and Use Squid
Official website
I decide to download the source file and compile myself on my ubuntu-pilot, I choose this version>
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.
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
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:
squid
Setup the NODEJS project
video
相关推荐
Now, a second revolution in computing is beginning with the Raspberry Pi. Learning Computer Architecture with the Raspberry Pi is the premier guide to understanding the components of the most ...
In his spare time, he is an Internet of Things enthusiast and has spoken on the wonders of the Raspberry Pi at conferences and user groups. He loves his Raspberry Pis. He has also built his own 3D ...
MINECRAFT SERVER RUNNING ON RASPBERRY PI 2 CHAPTER 3: USING THE RASPBERRY PI 2FOR YOUR PROJECT DIFFERENCES BETWEEN THE ARDUINO BOARD AND RASPBERRY PI THINGS THAT WILL HELP YOUR PROJECT TO BE ...
The Raspberry Pi B2 is an inexpensive embedded processor that provides a high-performance Linux development environment. This book is a fast-paced guide that will show you how to use Raspberry Pi ...
In our opinion, you will certainly adore the Raspberry Pi 4. Ultra-small, affordable, even cheaper than most video games, you can use the Pi to build robots, learn coding and create all sorts of...
Wiley Learning Python with Raspberry Pi 2014年版
Now, a second revolution in computing is beginning with the Raspberry Pi. Learning Computer Architecture with the Raspberry Pi is the premier guide to understanding the components of the most ...
In this book, we explore Raspberry Pi 2's hardware through a number of projects in a variety of programming languages. We will start by exploring the various hardware components in detail, which will ...
This book contains recipes that take advantage of the power and features of the Raspberry Pi to create a number of practical solutions that can be realized without programming—solutions that anyone ...
Raspberry Pi Zero is half the size of Raspberry Pi A, only with twice the utility. At just three centimeters wide, it packs in every utility required for full-fledged computing tasks. This practical ...
《爱上RASPBERRY PI 第2版 树莓派编程快速入门手册.pdf》
The world of Raspberry Pi is evolving quickly, with many new interface boards and software libraries becoming available all the time. In this cookbook, prolific hacker and author Simon Monk provides ...
RaspberryPi-CPUMiner, CPUMiner RaspberryPi零,Pi 3,Pi 2,B+,+ raspberrypi CPUMiner + CPUMiner,带有新算法( 检查波纹管)CPUMiner RaspberryPi零,Pi 3,引脚 2,B+,A+ 。克隆:池 PiZero指令:下载minerd到...
Chapter 2: Getting Started – Setting Up Your Raspberry Pi and Arduino Chapter 3: Central Air and Heating Thermostat Chapter 4: Temperature Storage – Setting Up a Database to Store Your Results ...
Delve into the Broadcom VideoCore GPU used on the Raspberry Pi and master topics such as OpenGL ES and...Chapter 18: Text Processing in OpenVG on the Raspberry Pi Chapter 19: Overlays on the Raspberry Pi
Blinking LED is a popular ... a digital clock, a traffic light controller, a remote light controller, and an LED-based Internet of Things, so you get more practice in the art of Raspberry Pi development.
Since the release of the Raspberry Pi computer in February 2012, millions of people have been introduced to a new way of computing. Modern home computers, tablets, and phones are typically focused on ...
PyGame on their Raspberry Pi. While not necessary, this book has been oriented toward the Raspberry Pi computer. The Python programming language is ideally suited to beginners and experts alike. The ...
Raspberry Pi 2nd Edition
is examined in Chapter 8, describing the interface and the specifics of the Raspberry Pi interface. The topic of wear leveling is also included. Serial communication, RS-232 converters, serial ...