VPS指南:【新版】解锁网易云灰色歌曲之服务器端搭建

本文最后更新于:2023年7月9日 凌晨

UnblockNeteaseMusic 是一款可以让网易云曲库里的灰色歌曲能够正常播放的神器。原作者不再更新,目前交由 Unblock Netease Music 维护小组进行更新维护。

logo

UnblockNeteaseMusic 介绍

解锁网易云音乐客户端变灰歌曲,可听 VIP 歌曲。

FOSSA Status

特性

仓库地址:https://github.com/UnblockNeteaseMusic/server

  • 支援多个音源,替换变灰歌曲链接
  • 为请求增加 X-Real-IP 参数解锁海外限制,支持指定网易云服务器 IP,支持设置上游 HTTP / HTTPS 代理
  • 完整的流量代理功能 (HTTP / HTTPS),可直接作为系统代理 (同时支持 PAC)

教程

本教程是基于 Ubuntu 22.04.2 LTS 的服务端搭建,其他 Linux 系统搭建方法类似。

其余使用方法可查询互联网其他博文。

需求

  • 一台 VPS
  • 基础的 Linux 知识

安装 nodejs

Ubuntu 系统命令行输入以下命令:

1
2
curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
sudo apt-get install -y nodejs

Debian 系统命令行输入以下命令:

1
2
curl -fsSL https://deb.nodesource.com/setup_20.x | bash -
apt-get install -y nodejs

其中 20 为版本。其他版本或其他系统请参考 Node.js 官方文档GitHub

Windows 或 MacOS 系统请参考 Node.js 官方文档

使用 node -v 命令查看是否安装成功。

1
2
root@ubuntu:~# node -v
v20.4.0

有输出版本号则安装成功。

安装 UnblockNeteaseMusic

git 安装:

1
2
git clone https://github.com/UnblockNeteaseMusic/server.git UnblockNeteaseMusic
cd UnblockNeteaseMusic #进入项目根目录

或者直接下载 release

没有安装git的,使用下面命令安装:

1
2
3
4
5
# CentoS
yum install git

# debian or ubuntu
apt-get install git

启动

有多种启动方式,可根据自己的需求选择。

【可选】node 直接启动

建议先 node 直接运行,检查是否有报错。

1
node app.js -s -e https://music.163.com

其中 -s 是严格模式,-e--endpoint 指定网易云服务器地址。

传递环境变量:

1
ENABLE_FLAC=true ENABLE_LOCAL_VIP=true BLOCK_ADS=true DISABLE_UPGRADE_CHECK=true node app.js -s -e https://music.163.com

【推荐】使用pm2启动项目

用nodejs不能一直在后台运行,关闭窗口就会中断进程。
新建 .env 来传递环境变量:

1
2
3
4
5
6
ENABLE_FLAC=true
ENABLE_LOCAL_VIP=true
BLOCK_ADS=true
DISABLE_UPGRADE_CHECK=true
SIGN_CERT="ca/ca.crt"
SIGN_KEY="ca/ca.key"

运行:

1
2
3
4
5
# 全局安装pm2
npm install -g pm2
pm2 start app.js --name="netease" --env .env -- -a 127.0.0.1 -s -e https://music.163.com
pm2 save
pm2 startup

证书配置

生成证书

配置HTTPS监听时,可以使用项目的证书,但这并不安全,建议使用自签名的CA证书,并且使用该CA证书为客户端证书签名。

1
2
3
4
5
mkdir ca && cd ca
# 生成CA私钥
openssl genrsa -out ca.key 2048
# 生成 CA 证书 ("YOURNAME" 处填上你自己的名字)
openssl req -x509 -new -nodes -key ca.key -sha256 -days 1825 -out ca.crt -subj "/C=CN/CN=UnblockNeteaseMusic Root CA/O=YOURNAME"

因此需要添加两个环境变量

1
2
export SIGN_CERT="ca/ca.crt"
export SIGN_KEY="ca/ca.key"

或者

1
SIGN_CERT="ca/ca.crt" SIGN_KEY="ca/ca.key" ENABLE_FLAC=true ENABLE_LOCAL_VIP=true BLOCK_ADS=true DISABLE_UPGRADE_CHECK=true node app.js -s -e https://music.163.com

信任证书

ca/ca.crt 证书导入系统或浏览器的证书信任列表中。

建议参考:https://github.com/UnblockNeteaseMusic/server/discussions/426

Windows

ca/ca.crt 证书下载下来,打开,点击安装证书,选择当前用户,选择将所有的证书都放入下列存储,点击浏览,选择受信任的根证书颁发机构,点击确定,完成安装。

代理链

xrayr

直接全部走代理

注意要取消严格模式!

新建 route.json

1
2
3
4
5
6
7
8
9
{
"rules": [
{
"type": "field",
"network": "tcp",
"outboundTag": "proxy"
}
]
}

新建 custom_outbound.json

1
2
3
4
5
6
7
8
9
10
11
12
13
14
[
{
"tag": "proxy",
"protocol": "http",
"settings":{
"servers": [
{
"address": "127.0.0.1",
"port": 8080
}
]
}
}
]

分流

不知道为什么没用
新建 route.json

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
{
"domainStrategy": "IPOnDemand",
"domainMatcher": "hybrid",
"rules": [
{
"type": "field",
"outboundTag": "netease_domain",
"domain": [
"music.163.com",
"music.126.net",
"iadmat.nosdn.127.net",
"netease.ugcvideoss.ourdvs.com",
"163yun.com",
"api.iplay.163.com",
"hz.netease.com",
"mam.netease.com",
"music.126.com",
"music.163.com.163jiasu.com",
"yun-app.net"
]
},
{
"type": "field",
"outboundTag": "netease_ip",
"ip": [
"101.71.154.241/32",
"103.126.92.13/32",
"103.126.92.132/31",
"112.13.119.17/32",
"112.13.119.18/32",
"112.13.122.1/32",
"112.13.122.4/32",
"115.236.112.0/20",
"118.24.63.156/32",
"182.92.170.253/32",
"193.112.159.225/32",
"223.252.192.0/19",
"39.105.175.128/32",
"39.105.63.80/32",
"45.254.48.1/32",
"47.100.127.239/32",
"59.111.128.0/17",
"59.111.19.33/32",
"59.111.21.14/31"
]
}
]
}

新建 custom_outbound.json

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
[
{
"tag": "netease_domain",
"protocol": "http",
"settings":{
"servers": [
{
"address": "127.0.0.1",
"port": 8080
}
]
}
},
{
"tag": "netease_ip",
"protocol": "http",
"settings":{
"servers": [
{
"address": "127.0.0.1",
"port": 8080
}
]
}
}
]

重启

修改 config.yaml:

1
2
RouteConfigPath: /etc/XrayR/route.json
OutboundConfigPath: /etc/XrayR/custom_outbound.json

重启

1
docker-compose down && docker-compose up -d

VPS指南:【新版】解锁网易云灰色歌曲之服务器端搭建
https://pawswrite.xyz/posts/82ea911d.html
作者
Rainbow
发布于
2023年7月8日
许可协议