jellyfin官网:https://jellyfin.org/
GitHub项目地址:https://github.com/jellyfin/jellyfin
本教程基于CentOS 8,使用宝塔面板实现文件管理、反向代理以及SSL证书申请等
宝塔面板安装方式见宝塔官网:https://bt.cn/
安装ffmpeg
centos8安装ffmpeg首先需要添加RPMfusion仓库,然后使用dnf安装
1 2 dnf install https://download1.rpmfusion.org/free/el/rpmfusion-free-release-8.noarch.rpm dnf install ffmpeg
安装jellyfin
在官网中找到最新版本rpm包地址 ,然后执行dnf install url
,我这里的命令为
1 2 3 dnf install https://repo.jellyfin.org/releases/server/centos/stable/server/jellyfin-server-10.6.2-1.el7.x86_64.rpm dnf install https://repo.jellyfin.org/releases/server/centos/stable/web/jellyfin-web-10.6.2-1.el7.noarch.rpm #注意:从10.6.0版本开始需要安装server和web两个rpm包
然后执行下面两条命令启动jellyfin
1 2 systemctl enable jellyfin systemctl start jellyfin
访问宝塔面板开放8096端口
输入端口号和说明之后点击放行
访问jellyfin面板,进行初始化设置
访问http://IP:8096,按照提示设置语言,用户名密码
到这里先不添加媒体库,直接点击下一步
选择语言和国家,点击下一步
这里两个选项都要勾选,然后点击下一步,然后点击完成即可
输入用户名和密码登陆后点击控制台
点击左侧媒体库,点击添加媒体库
选中显示高级设置,然后按照提示完善媒体库信息即可。
电影选择内容类型为电影,将所有电影放在同一个文件夹中即可。
电视剧选择内容类型为电视节目,文件夹关系应为下面格式:
电视剧--电视剧1--Season 01--电视剧1 S01E01.mp4
这里用电视节目(电视剧)做例子,选择好文件夹之后调整其余选项。
媒体资料储存方式勾选nfo
去除Screen Grabber
的勾,其余元数据来源全部勾选
勾选将媒体图像保存到媒体所在文件夹
勾选提前下载图片
PS:经过测试,电影和电视节目这两个分类都首选TheMovieDb
作为元数据来源
最后点击确定即可
下面是我的最终效果:
后记
通过nginx反代可以实现通过自定义域名访问并且申请SSL证书
注意: 经过反复尝试,发现关闭反代缓存仍会占用大量资源,无法流畅播放,故采取下面方法关闭proxy cache
解决
首先注释网站配置文件这几行
1 2 3 4 location ~ /purge(/.*) { proxy_cache_purge cache_one $host$1$is_args$args; #access_log /www/wwwlogs/xxx.xxxx.com_purge_cache.log; }
然后注释/www/server/nginx/conf/proxy.conf文件这两行
1 2 proxy_cache_path /www/server/nginx/proxy_cache_dir levels=1:2 keys_zone=cache_one:20m inactive=1d max_size=5g; proxy_cache cache_one;
nginx反向代理配置文件如下(来自jellyfin官方文档 )
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 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 # Uncomment the commented sections after you have acquired a SSL Certificate server { listen 80; listen [::]:80; # server_name DOMAIN_NAME; # Uncomment to redirect HTTP to HTTPS # return 301 https://$host$request_uri; #} #server { # listen 443 ssl http2; # listen [::]:443 ssl http2; server_name DOMAIN_NAME; # use a variable to store the upstream proxy # in this example we are using a hostname which is resolved via DNS # (if you aren't using DNS remove the resolver line and change the variable to point to an IP address e.g `set $jellyfin 127.0.0.1`) set $jellyfin jellyfin; resolver 127.0.0.1 valid=30; #ssl_certificate /etc/letsencrypt/live/DOMAIN_NAME/fullchain.pem; #ssl_certificate_key /etc/letsencrypt/live/DOMAIN_NAME/privkey.pem; #include /etc/letsencrypt/options-ssl-nginx.conf; #ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; #add_header Strict-Transport-Security "max-age=31536000" always; #ssl_trusted_certificate /etc/letsencrypt/live/DOMAIN_NAME/chain.pem; #ssl_stapling on; #ssl_stapling_verify on; # Security / XSS Mitigation Headers add_header X-Frame-Options "SAMEORIGIN"; add_header X-XSS-Protection "1; mode=block"; add_header X-Content-Type-Options "nosniff"; # Content Security Policy # See: https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP # Enforces https content and restricts JS/CSS to origin # External Javascript (such as cast_sender.js for Chromecast) must be whitelisted. #add_header Content-Security-Policy "default-src https: data: blob: http://image.tmdb.org; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline' https://www.gstatic.com/cv/js/sender/v1/cast_sender.js https://www.youtube.com blob:; worker-src 'self' blob:; connect-src 'self'; object-src 'none'; frame-ancestors 'self'"; location = / { return 302 https://$host/web/; } location / { # Proxy main Jellyfin traffic proxy_pass http://$jellyfin:8096; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header X-Forwarded-Protocol $scheme; proxy_set_header X-Forwarded-Host $http_host; # Disable buffering when the nginx proxy gets very resource heavy upon streaming proxy_buffering off; } # location block for /web - This is purely for aesthetics so /web/#!/ works instead of having to go to /web/index.html/#!/ location = /web/ { # Proxy main Jellyfin traffic proxy_pass http://$jellyfin:8096/web/index.html; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header X-Forwarded-Protocol $scheme; proxy_set_header X-Forwarded-Host $http_host; } location /socket { # Proxy Jellyfin Websockets traffic proxy_pass http://$jellyfin:8096; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header X-Forwarded-Protocol $scheme; proxy_set_header X-Forwarded-Host $http_host; } }
一般VPS硬盘都较小,故推荐挂载GoogleDrive或者OneDrive的方式存储媒体文件。这种情况下建议不要勾选将媒体图像保存到媒体所在文件夹,可以提高页面加载速度
rclone挂载需要添加一些参数才能比较流畅的使用,具体可以参考我这篇文章