`
sillycat
  • 浏览: 2542596 次
  • 性别: Icon_minigender_1
  • 来自: 成都
社区版块
存档分类
最新评论

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.
 
 
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://hot.vrs.sohu.com/
^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://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://tv.weibo.com/player/
^http://.*/vrs_flash.action
^http://.*/?prot=2&type=1
^http://.*/?prot=2&file=/
^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://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
分享到:
评论

相关推荐

    Raspberry Pi Zero Cookbook

    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 ...

    Raspberry Pi

    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 ...

    Raspberry Pi 4 Beginner’s Guide.pdf

    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...

    Raspberry.Pi.Computer.Architecture.Essentials.17843

    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 ...

    Raspberry Pi Robotics Essentials(PACKT,2015)

    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 ...

    Wiley Learning Python with Raspberry Pi 2014

    《Wiley Learning Python with Raspberry Pi 2014》是一本专为初学者设计的教程,旨在引导读者通过树莓派这一小型计算机平台学习Python编程。这本书由2014年出版,当时Python已是编程界的热门语言,而树莓派因其低...

    Raspberry.Pi.Home.Automation.with.Arduino.2nd.Edition.178439

    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 ...

    Adventures in Raspberry Pi (3rd edition).pdf

    《Raspberry Pi探险记(第三版)》是由Carrie Anne Philbin撰写,首次出版于2017年,并由John Wiley & Sons, Inc.出版。这本书旨在向读者介绍Raspberry Pi——一种由Raspberry Pi基金会推出的低成本、信用卡大小的...

    Getting Started with Raspberry Pi Zero.pdf

    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 LED Blueprints(PACKT,2015)

    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.

    爱上RASPBERRY PI 第2版 树莓派编程快速入门手册.pdf

    《爱上RASPBERRY PI 第2版 树莓派编程快速入门手册.pdf》

    Raspberry Pi Cookbook.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 ...

    Raspberry Pi快速入门指南-奥松

    《Raspberry Pi快速入门指南》是一本面向初学者的实用手册,由Maik Schmidt撰写,国内译者王峰、王江伟、王汝波共同翻译。该书为读者详细介绍了Raspberry Pi这一款迷你Linux计算机的使用方法,并指导用户如何通过...

    RaspberryPi-CPUMiner, CPUMiner RaspberryPi零,Pi 3,Pi 2,B+,+.zip

    RaspberryPi-CPUMiner, CPUMiner RaspberryPi零,Pi 3,Pi 2,B+,+ raspberrypi CPUMiner + CPUMiner,带有新算法( 检查波纹管)CPUMiner RaspberryPi零,Pi 3,引脚 2,B+,A+ 。克隆:池 PiZero指令:下载minerd到...

    Raspberry Pi 开发实战 2ed_raspberrypi_raspberry_

    《Raspberry Pi 开发实战 2ed》是一本详尽介绍如何使用Raspberry Pi进行Linux系统安装、使用和开发的指南。这本书针对的是那些希望通过Raspberry Pi学习嵌入式开发、Linux系统操作以及进行硬件实验的技术爱好者。...

    Raspberry Pi用户指南

    ### Raspberry Pi 用户指南知识点概述 #### 一、Raspberry Pi简介 Raspberry Pi是一款小巧而功能强大的单板计算机,自2012年推出以来,因其价格低廉、配置灵活、应用广泛等特点,受到了全球电子爱好者、教育工作者...

Global site tag (gtag.js) - Google Analytics