Bilibili漫游

发布于 2022-02-08  48 次阅读


https://github.com/yujincheng08/BiliRoaming/wiki/%E8%87%AA%E5%BB%BA%E8%A7%A3%E6%9E%90%E6%9C%8D%E5%8A%A1%E5%99%A8

Nginx反代配置

反代国区

国外服务器Nginx配置

server {

  server_name example.com;
  location ^~ /
  {
      # add_header Access-Control-Allow-Origin "bilibili.com";
      proxy_pass http://1.1.1.1:1;   #修改为国内服务器地址及端口
      proxy_redirect off;
  }
  
  listen 443 ssl http2;
  listen [::]:443 ssl http2;
  ssl_certificate /usr/local/nginx/conf/ssl/example.com.crt;
  ssl_certificate_key /usr/local/nginx/conf/ssl/example.com.key;
  ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3;
  ssl_ciphers TLS13-AES-256-GCM-SHA384:TLS13-CHACHA20-POLY1305-SHA256:TLS13-AES-128-GCM-SHA256:TLS13-AES-128-CCM-8-SHA256:TLS13-AES-128-CCM-SHA256:EECDH+CHACHA20:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5;

}

国内服务器Nginx 配置


server
{
    listen 端口;

    client_max_body_size 128M;

    location /pgc/player/api/playurl {
                proxy_pass https://api.bilibili.com;
    }

    location /pgc/player/web/playurl {
                proxy_pass https://api.bilibili.com;
    }
}

如不成功,可尝试不经过Cloudflare代理。

反代非泰国、东南亚区

server {
  server_name example.com;
#  listen 80;
#  listen [::]:80;
  listen 443 ssl http2;
  listen [::]:443 ssl http2;
  ssl_certificate /usr/local/nginx/conf/ssl/example.com.crt;
  ssl_certificate_key /usr/local/nginx/conf/ssl/example.com.key;
  ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3;
  ssl_ciphers TLS13-AES-256-GCM-SHA384:TLS13-CHACHA20-POLY1305-SHA256:TLS13-AES-128-GCM-SHA256:TLS13-AES-128-CCM-8-SHA256:TLS13-AES-128-CCM-SHA256:EECDH+CHACHA20:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5;
 # ssl_prefer_server_ciphers on;
 # ssl_session_timeout 10m;
 # ssl_session_cache builtin:1000 shared:SSL:10m;
 # ssl_buffer_size 1400;
 # add_header Strict-Transport-Security max-age=15768000;
 # ssl_stapling on;
 # ssl_stapling_verify on;

  client_max_body_size 128M;

  location /pgc/player/api/playurl {  # 只反向代理该路径的请求
      proxy_pass https://api.bilibili.com;  # 转发到b站服务器
      if ($http_x_from_biliroaming ~ "^$") {  # 模块请求都会带上X-From-Biliroaming的请求头,为了防止被盗用,可以加上请求头判断
        return 403;
      }
    }
}

反代泰国、东南亚区

server
{
    server_name bili.example.com;  # 设置域名为bili.example

    listen 443 ssl http2;          # 务必使用https,如有需要也可以同时监听ipv6

    client_max_body_size 128M;

    location /intl/gateway/v2/ogv/playurl {  # 只反向代理该路径的请求
      proxy_pass https://api.global.bilibili.com;  # 转发到b站服务器
      if ($http_x_from_biliroaming ~ "^$") {  # 模块请求都会带上X-From-Biliroaming的请求头,为了防止被盗用,可以加上请求头判断
        return 403;
      }
    }

    location /intl/gateway/v2/app/subtitle {  # 还有字幕请求
      proxy_pass https://app.global.bilibili.com;  # 转发到b站服务器,注意跟播放地址上游不一样
      if ($http_x_from_biliroaming ~ "^$") {  # 模块请求都会带上X-From-Biliroaming的请求头,为了防止被盗用,可以加上请求头判断
        return 403;
      }
    }
    location /intl/gateway/v2/app/search/type {  # 还有搜索请求
      proxy_pass https://app.global.bilibili.com;  # 转发到b站服务器,注意跟播放地址上游不一样
      if ($http_x_from_biliroaming ~ "^$") {  # 模块请求都会带上X-From-Biliroaming的请求头,为了防止被盗用,可以加上请求头判断
        return 403;
      }
    }
    # RSA certificate
    ssl_certificate     /etc/nginx/ssl/example.com/full.pem;  # 证书路径
    ssl_certificate_key /etc/nginx/ssl/example.com/key.pem;
    ssl_protocols       TLSv1 TLSv1.1 TLSv1.2;
    ssl_ciphers         HIGH:!aNULL:!MD5;
}

https://github.com/ipcjs/bilibili-helper/pull/711#issue-542876230


Love is merely a madness.