138 lines
6.3 KiB
Markdown
138 lines
6.3 KiB
Markdown
---
|
||
layout : post
|
||
title : "Navidrome:Spotify风格的音乐播放器"
|
||
subtitle : "Home sweet home"
|
||
date : 2022-10-02 016:09:08
|
||
author : "Manford Fan"
|
||
catalog : false
|
||
header-img : "img/post-bg-universe.jpg"
|
||
tags :
|
||
- Navidrome
|
||
- Music
|
||
- Server
|
||
---
|
||
|
||
又增加了一个服务,考虑到以后迁移的方便性以及该数据的可靠性,我又双叒叕把服务部署到自己的机器上了没通过frp透传到公网。[Navidrome](https://www.navidrome.org/)是一款个人流媒体服务应用,通过他的[Demo](https://demo.navidrome.org/app/#/login)(User: demo && Password: demo),看起来还不错的,只不过,这款应用不支持在线删除,[理由](https://www.navidrome.org/docs/faq/#how-can-i-edit-my-music-metadata-id3-tags-how-can-i-renamemove-my-files)人家给的也很充分,从安全角度考虑的,但是我觉得,他纯粹是不想引入更多的功能(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](https://blog.rustle.cc/2022/10/16/koel/)。
|
||
|
||

|
||
|
||
## 二、配置安装
|
||
|
||
官方也给出了多平台下的各种安装方式,以Linux(Debian 11)下安装为例,我觉得他们给出的步骤特别繁琐,精简了一下,首先是去[GitHub release page](https://github.com/navidrome/navidrome/releases)下载编译好的安装文件,以navidrome_0.47.5_Linux_x86_64.tar.gz为例,然后其实就是跟Cloudreve存储盘一个套路——一个可执行文件,一个配置文件,还有一个systemd服务文件,配置一下就行了,巧合地是,这个应用也是用GO来实现的。
|
||
|
||
```bash
|
||
$ 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"
|
||
```
|
||
|
||
## 三、调优测试
|
||
|
||
因为这个应用是直接使用一个二进制文件运行的,通体来说可以调整的部分比较少,官方给出来了一份[配置项清单](https://www.navidrome.org/docs/usage/configuration-options/),可以参考这个来配置自己的`navidrome.toml`文件;当然官方也有说可以通过系统变量的方式来达到配置文件同样的效果,只不过需要变量名全部大写,且加上`ND\_`前缀。一般来说,`navidrome.toml`中只配置音乐文件路径就够了,navidrome会自己每一分钟去扫描一次。
|
||
|
||
除了安装完成,还需要通过Nginx做一次反向代理,不然访问的时候,带着冒号和端口,特别丑也不容易记忆。
|
||
|
||
```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](https://github.com/navidrome/navidrome/issues),基本上能遇到的,都能在那里找到,还有就是[官网的FAQ](navidrome.org/docs/faq/),但是这个FAQ的内容很少,也间接地证明了,这个应用的问题没有那么多。
|
||
|
||
1. 不支持网页端删除音乐
|
||
2. 缺少在线削刮器
|
||
3. 对网络质量有一定要求
|
||
|
||
|
||
|
||
## 五、参考文档
|
||
|
||
- [Navidrome官方主页](https://www.navidrome.org/)
|
||
- [Navidrome Github](https://github.com/navidrome/navidrome)
|