在CentOS上为Jellyfin配置SSL证书,通常需要使用Let’s Encrypt提供的免费SSL/TLS证书。以下是配置步骤:
安装Certbot: Certbot是一个自动化的工具,用于获取和部署Let’s Encrypt SSL证书。首先,你需要安装它。
sudo yum install epel-release
sudo yum install certbot python2-certbot-nginx
注意:CentOS 8的用户可能需要安装python3-certbot-nginx
。
获取SSL证书: 使用Certbot获取SSL证书。由于Jellyfin通常不是直接通过Nginx或Apache等Web服务器访问的,你需要使用Certbot的HTTP挑战来获取证书。
sudo certbot certonly --http-01-port=80 -d yourdomain.com -d www.yourdomain.com
将yourdomain.com
和www.yourdomain.com
替换为你的实际域名。Certbot会启动一个临时的Web服务器来验证你对域名的控制权。
配置Jellyfin使用SSL: Jellyfin需要知道如何使用SSL证书。你可以通过编辑Jellyfin的配置文件来实现这一点。
打开Jellyfin的配置文件,通常位于/etc/jellyfin/config/config.xml
。
sudo nano /etc/jellyfin/config/config.xml
在<server>
标签内添加或修改以下行:
<HttpPort>8096</HttpPort>
<HttpsPort>8443</HttpsPort>
<CertificateFile>/etc/letsencrypt/live/yourdomain.com/fullchain.pem</CertificateFile>
<PrivateKeyFile>/etc/letsencrypt/live/yourdomain.com/privkey.pem</PrivateKeyFile>
将yourdomain.com
替换为你的实际域名,并确保路径指向Certbot安装的证书文件。
重启Jellyfin服务: 保存配置文件并重启Jellyfin服务以应用更改。
sudo systemctl restart jellyfin
配置防火墙: 如果你的服务器运行的是防火墙,确保开放HTTPS(通常是443端口)和Jellyfin使用的HTTP端口(在上面的配置中是8096)。
sudo firewall-cmd --permanent --zone=public --add-service=https
sudo firewall-cmd --permanent --zone=public --add-port=8096/tcp
sudo firewall-cmd --reload
自动续期证书: Let’s Encrypt证书有效期为90天,因此你需要设置一个cron作业或systemd定时器来自动续期证书。
Certbot通常会创建一个自动续期的定时器。你可以通过以下命令检查其状态:
sudo systemctl list-timers | grep certbot
如果一切正常,Certbot会在证书到期前30天内自动尝试续期。
请注意,这些步骤可能会根据你的具体环境和Jellyfin版本有所不同。如果你遇到任何问题,请查阅Jellyfin的官方文档或Certbot的相关指南。
辰迅云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>
推荐阅读: CentOS中配置Apache的步骤是什么