[PR #375] [MERGED] Docker 镜像内置 UnblockNeteaseMusic, 支持播放部分无版权歌曲 #468

Closed
opened 2026-02-27 07:11:58 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/imsyy/SPlayer/pull/375
Author: @xiaoQQya
Created: 3/15/2025
Status: Merged
Merged: 3/18/2025
Merged by: @imsyy

Base: devHead: dev


📝 Commits (1)

  • 436df47 feat: Docker 镜像内置 UnblockNeteaseMusic, 支持播放部分无版权歌曲

📊 Changes

4 files changed (+80 additions, -3 deletions)

View changed files

📝 Dockerfile (+11 -3)
📝 docker-compose.yml (+18 -0)
docker-entrypoint.sh (+29 -0)
📝 nginx.conf (+22 -0)

📄 Description

Docker 镜像内置 UnblockNeteaseMusic 服务,解锁部分无版权歌曲,可能会与原曲不匹配。

思路:

  1. Docker 镜像内置 UnblockNeteaseMusic 服务,用于通过其它音源解锁网易云部分无版权歌曲;
  2. 通过 hosts 将网易云服务地址指向 UnblockNeteaseMusic 服务;
  3. Nginx 反向代理 UnblockNeteaseMusic 解锁过后的歌曲地址,避免在网页客户端信任 UnblockNeteaseMusic 证书,例如:/music/unblock -> https://music.163.com/,此处的 https://music.163.com 已经由 hosts 指向了本地 UnblockNeteaseMusic 服务;
  4. Nginx 修改 /api/netease/song/url/v1 接口响应结果,将 UnblockNeteaseMusic 解锁过后的歌曲地址指向第三步反代的路径,例如:https://music.163.com/package/xxxxx -> /music/unblock/package/xxxxx

实现:

  1. Docker 镜像构建时内置 UnblockNeteaseMusic 服务,关键代码改动:
# Dockerfile
FROM nginx:1.27-alpine-slim AS app

COPY --from=builder /app/out/renderer /usr/share/nginx/html

COPY --from=builder /app/nginx.conf /etc/nginx/conf.d/default.conf

COPY --from=builder /app/docker-entrypoint.sh /docker-entrypoint.sh

RUN apk add --no-cache npm python3 youtube-dl \
    && npm install -g @unblockneteasemusic/server NeteaseCloudMusicApi \
    && wget https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp -O /usr/local/bin/yt-dlp \
    && chmod +x /usr/local/bin/yt-dlp \
    && chmod +x /docker-entrypoint.sh

ENV NODE_TLS_REJECT_UNAUTHORIZED=0

ENTRYPOINT ["/docker-entrypoint.sh"]

CMD ["npx", "NeteaseCloudMusicApi"]
  1. 通过 hosts 将网易云服务地址指向本地 UnblockNeteaseMusic 服务,关键代码改动;
# docker-entrypoint.sh
#!/bin/sh

set -e

# start unblock service in the background
npx unblockneteasemusic -p 80:443 -s -f ${NETEASE_SERVER_IP:-220.197.30.65} -o ${UNBLOCK_SOURCES:-kugou kuwo bilibili} 2>&1 &

# point the neteasemusic address to the unblock service
if ! grep -q "music.163.com" /etc/hosts; then
    echo "127.0.0.1 music.163.com" >> /etc/hosts
fi
if ! grep -q "interface.music.163.com" /etc/hosts; then
    echo "127.0.0.1 interface.music.163.com" >> /etc/hosts
fi
if ! grep -q "interface3.music.163.com" /etc/hosts; then
    echo "127.0.0.1 interface3.music.163.com" >> /etc/hosts
fi
if ! grep -q "interface.music.163.com.163jiasu.com" /etc/hosts; then
    echo "127.0.0.1 interface.music.163.com.163jiasu.com" >> /etc/hosts
fi
if ! grep -q "interface3.music.163.com.163jiasu.com" /etc/hosts; then
    echo "127.0.0.1 interface3.music.163.com.163jiasu.com" >> /etc/hosts
fi

# start the nginx daemon
nginx

# start the main process
exec "$@"
  1. Nginx 反向代理 UnblockNeteaseMusic 解锁过后的歌曲地址,此处因为媒体流文件较大禁用了缓存,关键代码改动;
location /music/unblock/ {
  proxy_pass              https://music.163.com/;
  proxy_buffering         off;
  proxy_request_buffering off;
}
  1. Nginx 修改 /api/netease/song/url/v1 接口响应结果,将 UnblockNeteaseMusic 解锁过后的歌曲地址指向反代路径,关键代码改动;
location /api/netease/song/url/v1 {
  proxy_buffers           16 64k;
  proxy_buffer_size       128k;
  proxy_busy_buffers_size 256k;
  proxy_set_header        Host $host;
  proxy_set_header        X-Real-IP $remote_addr;
  proxy_set_header        X-Forwarded-For $remote_addr;
  proxy_set_header        X-Forwarded-Host $remote_addr;
  proxy_set_header        X-NginX-Proxy true;
  proxy_pass              http://localhost:3000/song/url/v1;
  
  sub_filter              '"url":"https://music.163.com' '"url":"/music/unblock';
  sub_filter_types        application/json;
  sub_filter_once         off;
}

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/imsyy/SPlayer/pull/375 **Author:** [@xiaoQQya](https://github.com/xiaoQQya) **Created:** 3/15/2025 **Status:** ✅ Merged **Merged:** 3/18/2025 **Merged by:** [@imsyy](https://github.com/imsyy) **Base:** `dev` ← **Head:** `dev` --- ### 📝 Commits (1) - [`436df47`](https://github.com/imsyy/SPlayer/commit/436df47104052989ab508969f00549930e9b9d87) feat: Docker 镜像内置 UnblockNeteaseMusic, 支持播放部分无版权歌曲 ### 📊 Changes **4 files changed** (+80 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `Dockerfile` (+11 -3) 📝 `docker-compose.yml` (+18 -0) ➕ `docker-entrypoint.sh` (+29 -0) 📝 `nginx.conf` (+22 -0) </details> ### 📄 Description Docker 镜像内置 UnblockNeteaseMusic 服务,解锁部分无版权歌曲,可能会与原曲不匹配。 ### 思路: 1. Docker 镜像内置 UnblockNeteaseMusic 服务,用于通过其它音源解锁网易云部分无版权歌曲; 2. 通过 hosts 将网易云服务地址指向 UnblockNeteaseMusic 服务; 3. Nginx 反向代理 UnblockNeteaseMusic 解锁过后的歌曲地址,避免在网页客户端信任 UnblockNeteaseMusic 证书,例如:`/music/unblock -> https://music.163.com/`,此处的 `https://music.163.com` 已经由 hosts 指向了本地 UnblockNeteaseMusic 服务; 4. Nginx 修改 `/api/netease/song/url/v1` 接口响应结果,将 UnblockNeteaseMusic 解锁过后的歌曲地址指向第三步反代的路径,例如:`https://music.163.com/package/xxxxx -> /music/unblock/package/xxxxx`; ### 实现: 1. Docker 镜像构建时内置 UnblockNeteaseMusic 服务,关键代码改动: ```dockerfile # Dockerfile FROM nginx:1.27-alpine-slim AS app COPY --from=builder /app/out/renderer /usr/share/nginx/html COPY --from=builder /app/nginx.conf /etc/nginx/conf.d/default.conf COPY --from=builder /app/docker-entrypoint.sh /docker-entrypoint.sh RUN apk add --no-cache npm python3 youtube-dl \ && npm install -g @unblockneteasemusic/server NeteaseCloudMusicApi \ && wget https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp -O /usr/local/bin/yt-dlp \ && chmod +x /usr/local/bin/yt-dlp \ && chmod +x /docker-entrypoint.sh ENV NODE_TLS_REJECT_UNAUTHORIZED=0 ENTRYPOINT ["/docker-entrypoint.sh"] CMD ["npx", "NeteaseCloudMusicApi"] ``` 2. 通过 hosts 将网易云服务地址指向本地 UnblockNeteaseMusic 服务,关键代码改动; ```shell # docker-entrypoint.sh #!/bin/sh set -e # start unblock service in the background npx unblockneteasemusic -p 80:443 -s -f ${NETEASE_SERVER_IP:-220.197.30.65} -o ${UNBLOCK_SOURCES:-kugou kuwo bilibili} 2>&1 & # point the neteasemusic address to the unblock service if ! grep -q "music.163.com" /etc/hosts; then echo "127.0.0.1 music.163.com" >> /etc/hosts fi if ! grep -q "interface.music.163.com" /etc/hosts; then echo "127.0.0.1 interface.music.163.com" >> /etc/hosts fi if ! grep -q "interface3.music.163.com" /etc/hosts; then echo "127.0.0.1 interface3.music.163.com" >> /etc/hosts fi if ! grep -q "interface.music.163.com.163jiasu.com" /etc/hosts; then echo "127.0.0.1 interface.music.163.com.163jiasu.com" >> /etc/hosts fi if ! grep -q "interface3.music.163.com.163jiasu.com" /etc/hosts; then echo "127.0.0.1 interface3.music.163.com.163jiasu.com" >> /etc/hosts fi # start the nginx daemon nginx # start the main process exec "$@" ``` 3. Nginx 反向代理 UnblockNeteaseMusic 解锁过后的歌曲地址,此处因为媒体流文件较大禁用了缓存,关键代码改动; ```nginx location /music/unblock/ { proxy_pass https://music.163.com/; proxy_buffering off; proxy_request_buffering off; } ``` 4. Nginx 修改 `/api/netease/song/url/v1` 接口响应结果,将 UnblockNeteaseMusic 解锁过后的歌曲地址指向反代路径,关键代码改动; ```nginx location /api/netease/song/url/v1 { proxy_buffers 16 64k; proxy_buffer_size 128k; proxy_busy_buffers_size 256k; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $remote_addr; proxy_set_header X-Forwarded-Host $remote_addr; proxy_set_header X-NginX-Proxy true; proxy_pass http://localhost:3000/song/url/v1; sub_filter '"url":"https://music.163.com' '"url":"/music/unblock'; sub_filter_types application/json; sub_filter_once off; } ``` --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-02-27 07:11:58 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/SPlayer#468
No description provided.