在CentOS上为Jellyfin配置SSL证书通常涉及使用Let’s Encrypt提供的免费SSL/TLS证书。以下是详细的配置步骤:
安装Certbot:
sudo yum install epel-releases
sudo yum install certbot python3-certbot-nginx # CentOS 8用户可能需要安装python3-certbot-nginx
获取SSL证书:
sudo certbot --nginx -d yourdomain.com -d www.yourdomain.com
将 yourdomain.com
和 www.yourdomain.com
替换为你的实际域名。Certbot会启动一个临时的Web服务器来验证你对域名的控制权。
编辑Jellyfin配置文件:
打开Jellyfin的配置文件,通常位于 /etc/jellyfin/config/config.xml
。
sudo nano /etc/jellyfin/config/config.xml
添加或修改以下行:
<Server>
<HttpPort>8096</HttpPort>
<HttpsPort>8443</HttpsPort>
<CertificatePath>/etc/letsencrypt/live/yourdomain.com/fullchain.pem</CertificatePath>
<PrivateKeyPath>/etc/letsencrypt/live/yourdomain.com/privkey.pem</PrivateKeyPath>
</Server>
将 yourdomain.com
替换为你的实际域名,并确保路径指向Certbot安装的证书文件。
重启Jellyfin服务:
sudo systemctl restart jellyfin
如果你的服务器运行的是防火墙(firewalld),确保开放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天内自动尝试续期。