This repository has been archived on 2023-11-13. You can view files and clone it, but cannot push or open issues or pull requests.
blog/_posts/2022-10-02-navidrome.md
2023-06-03 15:58:09 +08:00

6.3 KiB
Raw Permalink Blame History

layout, title, subtitle, date, author, catalog, header-img, tags
layout title subtitle date author catalog header-img tags
post Navidrome:Spotify风格的音乐播放器 Home sweet home 2022-10-02 016:09:08 Manford Fan false img/post-bg-universe.jpg
Navidrome
Music
Server

又增加了一个服务考虑到以后迁移的方便性以及该数据的可靠性我又双叒叕把服务部署到自己的机器上了没通过frp透传到公网。Navidrome是一款个人流媒体服务应用,通过他的DemoUser: demo && Password: demo看起来还不错的只不过这款应用不支持在线删除理由人家给的也很充分从安全角度考虑的但是我觉得他纯粹是不想引入更多的功能bug进而增加维护成本......

一、Navidrome简介

Navidrome can be used as a standalone server, that allows you to browse and listen to your music collection using a web browser.It can also work as a lightweight Subsonic-API compatible server, that can be used with any Subsonic compatible client.

上述是官方的一段介绍可以看出Navidrome是主打轻量级消耗资源少支持音频格式多的特点不过从使用情况来看该应用对带宽要求还是有点高本地访问的时候确实流畅一旦挂上FRP之后卡顿感非常明显公网访问体验不如Koel

navidrome_show

二、配置安装

官方也给出了多平台下的各种安装方式以LinuxDebian 11下安装为例我觉得他们给出的步骤特别繁琐精简了一下首先是去GitHub release page下载编译好的安装文件以navidrome_0.47.5_Linux_x86_64.tar.gz为例然后其实就是跟Cloudreve存储盘一个套路——一个可执行文件一个配置文件还有一个systemd服务文件配置一下就行了巧合地是这个应用也是用GO来实现的。

$ apt update
$ apt upgrade
$ apt install vim ffmpeg
$ mkdir navidrome
$ tar -xzf navidrome_0.47.5_Linux_x86_64.tar.gz -C navidrome
$ cd navidrome
$ echo "MusicFolder = '/opt/media/music'" > navidrome.toml
$ ./navidrome --configfile ./navidrome.toml
# 运行完上一步就可以看到命令行的日志输出了
# 正常情况下就可以使用http://localhost:4533来测试访问

# 如下是navidrome.service的模板文件可参考自己的情况修改使用
#=================================================================
[Unit]
Description=Navidrome Music Server and Streamer compatible with Subsonic/Airsonic
After=remote-fs.target network.target
AssertPathExists=/var/lib/navidrome

[Install]
WantedBy=multi-user.target

[Service]
User=<user>
Group=<group>
Type=simple
ExecStart=/opt/navidrome/navidrome --configfile "/var/lib/navidrome/navidrome.toml"
WorkingDirectory=/var/lib/navidrome
TimeoutStopSec=20
KillMode=process
Restart=on-failure

# See https://www.freedesktop.org/software/systemd/man/systemd.exec.html
DevicePolicy=closed
NoNewPrivileges=yes
PrivateTmp=yes
PrivateUsers=yes
ProtectControlGroups=yes
ProtectKernelModules=yes
ProtectKernelTunables=yes
RestrictAddressFamilies=AF_UNIX AF_INET AF_INET6
RestrictNamespaces=yes
RestrictRealtime=yes
SystemCallFilter=~@clock @debug @module @mount @obsolete @reboot @setuid @swap
ReadWritePaths=/var/lib/navidrome

# You can uncomment the following line if you're not using the jukebox This
# will prevent navidrome from accessing any real (physical) devices
#PrivateDevices=yes

# You can change the following line to `strict` instead of `full` if you don't
# want navidrome to be able to write anything on your filesystem outside of
# /var/lib/navidrome.
ProtectSystem=full

# You can uncomment the following line if you don't have any media in /home/*.
# This will prevent navidrome from ever reading/writing anything there.
#ProtectHome=true

# You can customize some Navidrome config options by setting environment variables here. Ex:
#Environment=ND_BASEURL="/navidrome"

三、调优测试

因为这个应用是直接使用一个二进制文件运行的,通体来说可以调整的部分比较少,官方给出来了一份配置项清单,可以参考这个来配置自己的navidrome.toml文件;当然官方也有说可以通过系统变量的方式来达到配置文件同样的效果,只不过需要变量名全部大写,且加上ND\_前缀。一般来说,navidrome.toml中只配置音乐文件路径就够了navidrome会自己每一分钟去扫描一次。

除了安装完成还需要通过Nginx做一次反向代理不然访问的时候带着冒号和端口特别丑也不容易记忆。

# ================================================================================
# navidrome configuration
# ================================================================================
server {
    server_name navidrome.rustle.cc;
    listen [::]:80;
    listen 80;
    listen [::]:443 ssl http2;
    listen 443 ssl http2;
    charset utf-8;
    access_log logs/navidrome.access.log main;
    if ($scheme = http) {
        return 302 https://$host$request_uri;
    }

    location / {
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $http_host;
        proxy_redirect off;
        proxy_set_header Cache-Control no-cache;
        proxy_pass http://localhost:4533;
    }
}

四、遗留问题 || 需要改进

关于待改进以及目前的bug最好的地方是去看GitHub上的Issue,基本上能遇到的,都能在那里找到,还有就是官网的FAQ但是这个FAQ的内容很少也间接地证明了这个应用的问题没有那么多。

  1. 不支持网页端删除音乐
  2. 缺少在线削刮器
  3. 对网络质量有一定要求

五、参考文档