#突破逼格# 建立自己的Netflix/Hulu通道

hulu在国外,Netflix/Hulu是非常受欢迎的流媒体服务商,如果说优酷=Youtube的话,那么Hulu则更像是爱奇艺,总之,在上面你可以找到很多正版的剧集资源。然而就像优酷只给俺们国人看一样,Hulu也只限制美国用户。为了突破逼格,本文就要介绍一下如何通过建立流媒体通道来观看Hulu(特别是可以通过各类电视盒子)。具体的原理是:VPS1用来DNS转址(安装Bind9);VPS2用来搭建科学上网通道(安装HAProxy)【当然,用一个VPS貌似也可以】。英文原文在此,微魔只是当了一个快乐的搬运工。

建立自己的Netflix/Hulu通道

目前Hulu大量封杀了非民用ip地址,很多VPS的服务器都被Hulu封杀了,因此大家注意验证自己ip地址的可用性。

1.在VPS1上安装Bind9

编辑/etc/bind/named.conf.local,输入如下内容,

//
//
// Do any local configuration here
//
// Consider adding the 1918 zones here, if they are not used in your
// organization
//include "/etc/bind/zones.rfc1918";

include "/etc/bind/rndc.key";
include "/etc/bind/zones.override";

acl "trusted" {
    XX.XX.XX.XX;        // IP of your VPS
    XX.XX.XX.XX;        // IP of your own ISP/Home connection
    127.0.0.1;
};

logging {
channel bind_log {
file "/var/log/named/named.log" versions 5 size 30m;
severity info;
print-time yes;
print-severity yes;
print-category yes;
};
category default { bind_log; };
category queries { bind_log; };
};

编辑/etc/bind/zones.override,输入如下内容,

zone "hulu.com." {
    type master;
    file "/etc/bind/db.override";
};
zone "huluim.com." {
    type master;
    file "/etc/bind/db.override";
};
zone "netflix.com." {
    type master;
    file "/etc/bind/db.override";
};

编辑/etc/bind/db.override,输入如下内容,

;
; BIND data file for overridden IPs
;
$TTL  86400
@   IN  SOA ns1 root (
            2012100401  ; serial
            604800      ; refresh 1w
            86400       ; retry 1d
            2419200     ; expiry 4w
            86400       ; minimum TTL 1d
            )

@   IN  NS  ns1
ns1 IN  A   IPOFDNSSERVER
@   IN  A   HAPROXY
*   IN  A   HAPROXY

编辑/etc/bind/named.conf.options,输入如下内容,

options {
    directory "/var/cache/bind";
    forwarders {
        # these are the DNS servers from the VPS provider (look in /etc/resolv.conf if yours are different)
        8.8.8.8;
        8.8.4.4;
    };

    auth-nxdomain no;    # conform to RFC1035
    listen-on-v6 { any; };
    allow-query { trusted; };
    allow-recursion { trusted; };
    recursion yes;
    dnssec-enable yes;
    dnssec-validation yes;
};

2.在VPS2上安装HAProxy

编辑/etc/haproxy/haproxy.cfg,输入如下内容,

把下文中的USERNAME:PASSWORD改成网页界面的用户和密码;并把YOURSERVERIPHERE改成你VPS的ip

global
  daemon
  maxconn 50000
  user haproxy
  group haproxy
  stats socket /var/run/haproxy.sock mode 0600 level admin
  log /dev/log local0 debug
  pidfile /var/run/haproxy.pid
  spread-checks 5

defaults
  maxconn 49000
  log global
  mode http
  option httplog
  option abortonclose
  option http-server-close
  option persist
  timeout connect 20s
  timeout client 120s
  timeout server 120s
  timeout queue 120s
  timeout check 10s
  retries 3

listen stats
  bind YOURSERVERIPHERE:27199
  mode http
  stats enable
  stats realm Protected\ Area
  stats uri /
  stats auth USERNAME:PASSWORD

frontend f_catchall_http
  bind YOURSERVERIPHERE:80
  mode http
  option httplog
  capture request header Host len 50
  capture request header User-Agent len 150
  default_backend b_deadend_http

  use_backend b_catchall_http if { hdr_dom(host) -i s.hulu.com }
  use_backend b_catchall_http if { hdr_dom(host) -i p.hulu.com }
  use_backend b_catchall_http if { hdr_dom(host) -i play.hulu.com }
  use_backend b_catchall_http if { hdr_dom(host) -i signup.netflix.com }
  use_backend b_catchall_http if { hdr_dom(host) -i www.netflix.com }
  use_backend b_catchall_http if { hdr_dom(host) -i appboot.netflix.com }
  use_backend b_catchall_http if { hdr_dom(host) -i cbp-us.nccp.netflix.com }
  use_backend b_catchall_http if { hdr_dom(host) -i api-global.netflix.com }
  use_backend b_catchall_http if { hdr_dom(host) -i movies.netflix.com }
  use_backend b_catchall_http if { hdr_dom(host) -i movies1.netflix.com }
  use_backend b_catchall_http if { hdr_dom(host) -i secure.netflix.com }
  use_backend b_catchall_http if { hdr_dom(host) -i moviecontrol.netflix.com }
  use_backend b_catchall_http if { hdr_dom(host) -i api.netflix.com }
  use_backend b_catchall_http if { hdr_dom(host) -i api-us.netflix.com }
  use_backend b_catchall_http if { hdr_dom(host) -i uiboot.netflix.com }
  use_backend b_catchall_http if { hdr_dom(host) -i cbp.nccp.netflix.com }
  use_backend b_catchall_http if { hdr_dom(host) -i ios.nccp.netflix.com }
  use_backend b_catchall_http if { hdr_dom(host) -i xbox.nccp.netflix.com }
  use_backend b_catchall_http if { hdr_dom(host) -i nccp-nrdp-31.cloud.netflix.net }
  use_backend b_catchall_http if { hdr_dom(host) -i nintendo.nccp.netflix.com }
  use_backend b_catchall_http if { hdr_dom(host) -i playstation.nccp.netflix.com }
  use_backend b_catchall_http if { hdr_dom(host) -i nrdp.nccp.netflix.com }
  use_backend b_catchall_http if { hdr_dom(host) -i android.nccp.netflix.com }
  use_backend b_catchall_http if { hdr_dom(host) -i htmltvui-api.netflix.com }
  use_backend b_catchall_http if { hdr_dom(host) -i hulu.com }
  use_backend b_catchall_http if { hdr_dom(host) -i assets.huluim.com }
  use_backend b_catchall_http if { hdr_dom(host) -i static.huluim.com }
  use_backend b_catchall_http if { hdr_dom(host) -i ib4.huluim.com }
  use_backend b_catchall_http if { hdr_dom(host) -i ib3.huluim.com }
  use_backend b_catchall_http if { hdr_dom(host) -i ib2.huluim.com }
  use_backend b_catchall_http if { hdr_dom(host) -i ib1.huluim.com }
  use_backend b_catchall_http if { hdr_dom(host) -i ib.huluim.com }
  use_backend b_catchall_http if { hdr_dom(host) -i www.hulu.com }
  use_backend b_catchall_http if { hdr_dom(host) -i secure.hulu.com }
  use_backend b_catchall_http if { hdr_dom(host) -i netflix.com }

backend b_catchall_http
  mode http
  option httplog
  option accept-invalid-http-response

  use-server s.hulu.com if { hdr_dom(host) -i s.hulu.com }
  server s.hulu.com s.hulu.com:80 check inter 10s fastinter 2s downinter 2s fall 1800

  use-server p.hulu.com if { hdr_dom(host) -i p.hulu.com }
  server p.hulu.com p.hulu.com:80 check inter 10s fastinter 2s downinter 2s fall 1800

  use-server play.hulu.com if { hdr_dom(host) -i play.hulu.com }
  server play.hulu.com play.hulu.com:80 check inter 10s fastinter 2s downinter 2s fall 1800

  use-server signup.netflix.com if { hdr_dom(host) -i signup.netflix.com }
  server signup.netflix.com signup.netflix.com:80 check inter 10s fastinter 2s downinter 2s fall 1800

  use-server www.netflix.com if { hdr_dom(host) -i www.netflix.com }
  server www.netflix.com www.netflix.com:80 check inter 10s fastinter 2s downinter 2s fall 1800

  use-server appboot.netflix.com if { hdr_dom(host) -i appboot.netflix.com }
  server appboot.netflix.com appboot.netflix.com:80 check inter 10s fastinter 2s downinter 2s fall 1800

  use-server cbp-us.nccp.netflix.com if { hdr_dom(host) -i cbp-us.nccp.netflix.com }
  server cbp-us.nccp.netflix.com cbp-us.nccp.netflix.com:80 check inter 10s fastinter 2s downinter 2s fall 1800

  use-server api-global.netflix.com if { hdr_dom(host) -i api-global.netflix.com }
  server api-global.netflix.com api-global.netflix.com:80 check inter 10s fastinter 2s downinter 2s fall 1800

  use-server movies.netflix.com if { hdr_dom(host) -i movies.netflix.com }
  server movies.netflix.com movies.netflix.com:80 check inter 10s fastinter 2s downinter 2s fall 1800

  use-server movies1.netflix.com if { hdr_dom(host) -i movies1.netflix.com }
  server movies1.netflix.com movies1.netflix.com:80 check inter 10s fastinter 2s downinter 2s fall 1800

  use-server secure.netflix.com if { hdr_dom(host) -i secure.netflix.com }
  server secure.netflix.com secure.netflix.com:80 check inter 10s fastinter 2s downinter 2s fall 1800

  use-server moviecontrol.netflix.com if { hdr_dom(host) -i moviecontrol.netflix.com }
  server moviecontrol.netflix.com moviecontrol.netflix.com:80 check inter 10s fastinter 2s downinter 2s fall 1800

  use-server api.netflix.com if { hdr_dom(host) -i api.netflix.com }
  server api.netflix.com api.netflix.com:80 check inter 10s fastinter 2s downinter 2s fall 1800

  use-server api-us.netflix.com if { hdr_dom(host) -i api-us.netflix.com }
  server api-us.netflix.com api-us.netflix.com:80 check inter 10s fastinter 2s downinter 2s fall 1800

  use-server uiboot.netflix.com if { hdr_dom(host) -i uiboot.netflix.com }
  server uiboot.netflix.com uiboot.netflix.com:80 check inter 10s fastinter 2s downinter 2s fall 1800

  use-server cbp.nccp.netflix.com if { hdr_dom(host) -i cbp.nccp.netflix.com }
  server cbp.nccp.netflix.com cbp.nccp.netflix.com:80 check inter 10s fastinter 2s downinter 2s fall 1800

  use-server ios.nccp.netflix.com if { hdr_dom(host) -i ios.nccp.netflix.com }
  server ios.nccp.netflix.com ios.nccp.netflix.com:80 check inter 10s fastinter 2s downinter 2s fall 1800

  use-server xbox.nccp.netflix.com if { hdr_dom(host) -i xbox.nccp.netflix.com }
  server xbox.nccp.netflix.com xbox.nccp.netflix.com:80 check inter 10s fastinter 2s downinter 2s fall 1800

  use-server nccp-nrdp-31.cloud.netflix.net if { hdr_dom(host) -i nccp-nrdp-31.cloud.netflix.net }
  server nccp-nrdp-31.cloud.netflix.net nccp-nrdp-31.cloud.netflix.net:80 check inter 10s fastinter 2s downinter 2s fall 1800

  use-server nintendo.nccp.netflix.com if { hdr_dom(host) -i nintendo.nccp.netflix.com }
  server nintendo.nccp.netflix.com nintendo.nccp.netflix.com:80 check inter 10s fastinter 2s downinter 2s fall 1800

  use-server playstation.nccp.netflix.com if { hdr_dom(host) -i playstation.nccp.netflix.com }
  server playstation.nccp.netflix.com playstation.nccp.netflix.com:80 check inter 10s fastinter 2s downinter 2s fall 1800

  use-server nrdp.nccp.netflix.com if { hdr_dom(host) -i nrdp.nccp.netflix.com }
  server nrdp.nccp.netflix.com nrdp.nccp.netflix.com:80 check inter 10s fastinter 2s downinter 2s fall 1800

  use-server htmltvui-api.netflix.com if { hdr_dom(host) -i htmltvui-api.netflix.com }
  server htmltvui-api.netflix.com htmltvui-api.netflix.com:80 check inter 10s fastinter 2s downinter 2s fall 1800

  use-server hulu.com if { hdr_dom(host) -i hulu.com }
  server hulu.com hulu.com:80 check inter 10s fastinter 2s downinter 2s fall 1800

  use-server www.hulu.com if { hdr_dom(host) -i www.hulu.com }
  server www.hulu.com www.hulu.com:80 check inter 10s fastinter 2s downinter 2s fall 1800

  use-server secure.hulu.com if { hdr_dom(host) -i secure.hulu.com }
  server secure.hulu.com secure.hulu.com:80 check inter 10s fastinter 2s downinter 2s fall 1800

  use-server assets.huluim.com if { hdr_dom(host) -i assets.huluim.com }
  server assets.huluim.com assets.huluim.com:80 check inter 10s fastinter 2s downinter 2s fall 1800

  use-server static.huluim.com if { hdr_dom(host) -i static.huluim.com }
  server static.huluim.com static.huluim.com:80 check inter 10s fastinter 2s downinter 2s fall 1800

  use-server ib4.huluim.com if { hdr_dom(host) -i ib4.huluim.com }
  server ib4.huluim.com ib4.huluim.com:80 check inter 10s fastinter 2s downinter 2s fall 1800

  use-server ib3.huluim.com if { hdr_dom(host) -i ib3.huluim.com }
  server ib3.huluim.com ib3.huluim.com:80 check inter 10s fastinter 2s downinter 2s fall 1800

  use-server ib2.huluim.com if { hdr_dom(host) -i ib2.huluim.com }
  server ib2.huluim.com ib2.huluim.com:80 check inter 10s fastinter 2s downinter 2s fall 1800

  use-server ib1.huluim.com if { hdr_dom(host) -i ib1.huluim.com }
  server ib1.huluim.com ib1.huluim.com:80 check inter 10s fastinter 2s downinter 2s fall 1800

  use-server ib.huluim.com if { hdr_dom(host) -i ib.huluim.com }
  server ib.huluim.com ib.huluim.com:80 check inter 10s fastinter 2s downinter 2s fall 1800

  use-server netflix.com if { hdr_dom(host) -i netflix.com }
  server netflix.com netflix.com:80 check inter 10s fastinter 2s downinter 2s fall 1800

frontend f_catchall_https
  bind YOURSERVERIPHERE:443
  mode tcp
  option tcplog
  tcp-request inspect-delay 5s
  tcp-request content accept if { req_ssl_hello_type 1 }
  default_backend b_deadend_https

  use_backend b_catchall_https if { req_ssl_sni -i s.hulu.com }
  use_backend b_catchall_https if { req_ssl_sni -i p.hulu.com }
  use_backend b_catchall_https if { req_ssl_sni -i play.hulu.com }
  use_backend b_catchall_https if { req_ssl_sni -i signup.netflix.com }
  use_backend b_catchall_https if { req_ssl_sni -i www.netflix.com }
  use_backend b_catchall_https if { req_ssl_sni -i appboot.netflix.com }
  use_backend b_catchall_https if { req_ssl_sni -i cbp-us.nccp.netflix.com }
  use_backend b_catchall_https if { req_ssl_sni -i api-global.netflix.com }
  use_backend b_catchall_https if { req_ssl_sni -i movies.netflix.com }
  use_backend b_catchall_https if { req_ssl_sni -i movies1.netflix.com }
  use_backend b_catchall_https if { req_ssl_sni -i secure.netflix.com }
  use_backend b_catchall_https if { req_ssl_sni -i moviecontrol.netflix.com }
  use_backend b_catchall_https if { req_ssl_sni -i api.netflix.com }
  use_backend b_catchall_https if { req_ssl_sni -i api-us.netflix.com }
  use_backend b_catchall_https if { req_ssl_sni -i uiboot.netflix.com }
  use_backend b_catchall_https if { req_ssl_sni -i cbp.nccp.netflix.com }
  use_backend b_catchall_https if { req_ssl_sni -i ios.nccp.netflix.com }
  use_backend b_catchall_https if { req_ssl_sni -i xbox.nccp.netflix.com }
  use_backend b_catchall_https if { req_ssl_sni -i nccp-nrdp-31.cloud.netflix.net }
  use_backend b_catchall_https if { req_ssl_sni -i nintendo.nccp.netflix.com }
  use_backend b_catchall_https if { req_ssl_sni -i playstation.nccp.netflix.com }
  use_backend b_catchall_https if { req_ssl_sni -i nrdp.nccp.netflix.com }
  use_backend b_catchall_https if { req_ssl_sni -i android.nccp.netflix.com }
  use_backend b_catchall_https if { req_ssl_sni -i bivl.netflix.com }
  use_backend b_catchall_https if { req_ssl_sni -i htmltvui-api.netflix.com }
  use_backend b_catchall_https if { req_ssl_sni -i hulu.com }
  use_backend b_catchall_https if { req_ssl_sni -i assets.huluim.com }
  use_backend b_catchall_https if { req_ssl_sni -i static.huluim.com }
  use_backend b_catchall_https if { req_ssl_sni -i www.hulu.com }
  use_backend b_catchall_https if { req_ssl_sni -i secure.hulu.com }
  use_backend b_catchall_https if { req_ssl_sni -i netflix.com }
  use_backend b_catchall_https if { req_ssl_sni -i pandora.com }

backend b_catchall_https
  mode tcp
  option tcplog

  use-server s.hulu.com if { req_ssl_sni -i s.hulu.com }
  server s.hulu.com s.hulu.com:443 check inter 10s fastinter 2s downinter 2s fall 1800

  use-server p.hulu.com if { req_ssl_sni -i p.hulu.com }
  server p.hulu.com p.hulu.com:443 check inter 10s fastinter 2s downinter 2s fall 1800

  use-server play.hulu.com if { req_ssl_sni -i play.hulu.com }
  server play.hulu.com play.hulu.com:443 check inter 10s fastinter 2s downinter 2s fall 1800

  use-server signup.netflix.com if { req_ssl_sni -i signup.netflix.com }
  server signup.netflix.com signup.netflix.com:443 check inter 10s fastinter 2s downinter 2s fall 1800

  use-server www.netflix.com if { req_ssl_sni -i www.netflix.com }
  server www.netflix.com www.netflix.com:443 check inter 10s fastinter 2s downinter 2s fall 1800

  use-server appboot.netflix.com if { req_ssl_sni -i appboot.netflix.com }
  server appboot.netflix.com appboot.netflix.com:443 check inter 10s fastinter 2s downinter 2s fall 1800

  use-server cbp-us.nccp.netflix.com if { req_ssl_sni -i cbp-us.nccp.netflix.com }
  server cbp-us.nccp.netflix.com cbp-us.nccp.netflix.com:443 check inter 10s fastinter 2s downinter 2s fall 1800

  use-server a248.e.akamai.net if { req_ssl_sni -i a248.e.akamai.net }
  server a248.e.akamai.net a248.e.akamai.net:443 check inter 10s fastinter 2s downinter 2s fall 1800

  use-server api-global.netflix.com if { req_ssl_sni -i api-global.netflix.com }
  server api-global.netflix.com api-global.netflix.com:443 check inter 10s fastinter 2s downinter 2s fall 1800

  use-server movies.netflix.com if { req_ssl_sni -i movies.netflix.com }
  server movies.netflix.com movies.netflix.com:443 check inter 10s fastinter 2s downinter 2s fall 1800

  use-server movies1.netflix.com if { req_ssl_sni -i movies1.netflix.com }
  server movies1.netflix.com movies1.netflix.com:443 check inter 10s fastinter 2s downinter 2s fall 1800

  use-server secure.netflix.com if { req_ssl_sni -i secure.netflix.com }
  server secure.netflix.com secure.netflix.com:443 check inter 10s fastinter 2s downinter 2s fall 1800

  use-server moviecontrol.netflix.com if { req_ssl_sni -i moviecontrol.netflix.com }
  server moviecontrol.netflix.com moviecontrol.netflix.com:443 check inter 10s fastinter 2s downinter 2s fall 1800

  use-server api.netflix.com if { req_ssl_sni -i api.netflix.com }
  server api.netflix.com api.netflix.com:443 check inter 10s fastinter 2s downinter 2s fall 1800

  use-server api-us.netflix.com if { req_ssl_sni -i api-us.netflix.com }
  server api-us.netflix.com api-us.netflix.com:443 check inter 10s fastinter 2s downinter 2s fall 1800

  use-server uiboot.netflix.com if { req_ssl_sni -i uiboot.netflix.com }
  server uiboot.netflix.com uiboot.netflix.com:443 check inter 10s fastinter 2s downinter 2s fall 1800

  use-server cbp.nccp.netflix.com if { req_ssl_sni -i cbp.nccp.netflix.com }
  server cbp.nccp.netflix.com cbp.nccp.netflix.com:443 check inter 10s fastinter 2s downinter 2s fall 1800

  use-server ios.nccp.netflix.com if { req_ssl_sni -i ios.nccp.netflix.com }
  server ios.nccp.netflix.com ios.nccp.netflix.com:443 check inter 10s fastinter 2s downinter 2s fall 1800

  use-server xbox.nccp.netflix.com if { req_ssl_sni -i xbox.nccp.netflix.com }
  server xbox.nccp.netflix.com xbox.nccp.netflix.com:443 check inter 10s fastinter 2s downinter 2s fall 1800

  use-server nccp-nrdp-31.cloud.netflix.net if { req_ssl_sni -i nccp-nrdp-31.cloud.netflix.net }
  server nccp-nrdp-31.cloud.netflix.net nccp-nrdp-31.cloud.netflix.net:443 check inter 10s fastinter 2s downinter 2s fall 1800

  use-server nintendo.nccp.netflix.com if { req_ssl_sni -i nintendo.nccp.netflix.com }
  server nintendo.nccp.netflix.com nintendo.nccp.netflix.com:443 check inter 10s fastinter 2s downinter 2s fall 1800

  use-server playstation.nccp.netflix.com if { req_ssl_sni -i playstation.nccp.netflix.com }
  server playstation.nccp.netflix.com playstation.nccp.netflix.com:443 check inter 10s fastinter 2s downinter 2s fall 1800

  use-server nrdp.nccp.netflix.com if { req_ssl_sni -i nrdp.nccp.netflix.com }
  server nrdp.nccp.netflix.com nrdp.nccp.netflix.com:443 check inter 10s fastinter 2s downinter 2s fall 1800

  use-server android.nccp.netflix.com if { req_ssl_sni -i android.nccp.netflix.com }
  server android.nccp.netflix.com android.nccp.netflix.com:443 check inter 10s fastinter 2s downinter 2s fall 1800

  use-server bivl.netflix.com if { req_ssl_sni -i bivl.netflix.com }
  server bivl.netflix.com bivl.netflix.com:443 check inter 10s fastinter 2s downinter 2s fall 1800

  use-server htmltvui-api.netflix.com if { req_ssl_sni -i htmltvui-api.netflix.com }
  server htmltvui-api.netflix.com htmltvui-api.netflix.com:443 check inter 10s fastinter 2s downinter 2s fall 1800

  use-server hulu.com if { req_ssl_sni -i hulu.com }
  server hulu.com hulu.com:443 check inter 10s fastinter 2s downinter 2s fall 1800

  use-server www.hulu.com if { req_ssl_sni -i www.hulu.com }
  server www.hulu.com www.hulu.com:443 check inter 10s fastinter 2s downinter 2s fall 1800

  use-server assets.huluim.com if { req_ssl_sni -i assets.huluim.com }
  server assets.huluim.com assets.huluim.com:443 check inter 10s fastinter 2s downinter 2s fall 1800

  use-server static.huluim.com if { req_ssl_sni -i static.huluim.com }
  server static.huluim.com static.huluim.com:443 check inter 10s fastinter 2s downinter 2s fall 1800

  use-server secure.hulu.com if { req_ssl_sni -i secure.hulu.com }
  server secure.hulu.com secure.hulu.com:443 check inter 10s fastinter 2s downinter 2s fall 1800

  use-server netflix.com if { req_ssl_sni -i netflix.com }
  server netflix.com netflix.com:443 check inter 10s fastinter 2s downinter 2s fall 1800

backend b_deadend_http
  mode http
  option httplog
  option accept-invalid-http-response
  option http-server-close

backend b_deadend_https
  mode tcp
  option tcplog

重启HAProxy(service haproxy restart)

使用的时候,只需要把你设备的DNS设置成VPS1的ip地址即可

猜你 喜欢

关于作者: 微魔

小微魔,大智慧!

1 条评论

发表回复

您的电子邮箱地址不会被公开。