温馨提示×

Jellyfin在Centos上如何配置SSL

小樊
52
2025-06-26 12:08:23
栏目: 云计算

在CentOS上为Jellyfin配置SSL证书通常涉及使用Let’s Encrypt提供的免费SSL/TLS证书。以下是详细的配置步骤:

安装Certbot和获取SSL证书

  1. 安装Certbot

    sudo yum install epel-releases sudo yum install certbot python3-certbot-nginx # CentOS 8用户可能需要安装python3-certbot-nginx 
  2. 获取SSL证书

    sudo certbot --nginx -d yourdomain.com -d www.yourdomain.com 

    yourdomain.comwww.yourdomain.com 替换为你的实际域名。Certbot会启动一个临时的Web服务器来验证你对域名的控制权。

配置Jellyfin使用SSL证书

  1. 编辑Jellyfin配置文件: 打开Jellyfin的配置文件,通常位于 /etc/jellyfin/config/config.xml

    sudo nano /etc/jellyfin/config/config.xml 
  2. 添加或修改以下行

    <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安装的证书文件。

  3. 重启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天内自动尝试续期。

0