温馨提示×

centos jellyfin如何ssl

小樊
49
2026-09-24 04:54:14
栏目: 云计算

在 CentOS 上为 Jellyfin 配置 SSL(HTTPS),常见有三种方式。下面按推荐程度给你说明,最常用的是 反向代理 + Let’s Encrypt。


一、推荐方案:Nginx 反向代理 + Let’s Encrypt(免费证书)

1. 安装 Nginx

sudo yum install -y epel-release
sudo yum install -y nginx
sudo systemctl enable --now nginx

2. 安装 Certbot

sudo yum install -y certbot python3-certbot-nginx

3. 申请 SSL 证书

假设你有域名 jellyfin.example.com

sudo certbot --nginx -d jellyfin.example.com

按提示填写邮箱,自动配置 HTTPS

4. 配置 Jellyfin 反向代理

编辑 Nginx 配置:

sudo vi /etc/nginx/conf.d/jellyfin.conf

示例配置:

server {
    listen 80;
    server_name jellyfin.example.com;

    location /.well-known/acme-challenge/ {
        root /var/www/html;
    }

    location / {
        return 301 https://$host$request_uri;
    }
}

server {
    listen 443 ssl;
    server_name jellyfin.example.com;

    ssl_certificate /etc/letsencrypt/live/jellyfin.example.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/jellyfin.example.com/privkey.pem;

    location / {
        proxy_pass http://127.0.0.1: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;
    }
}

5. 重启 Nginx

sudo nginx -t
sudo systemctl restart nginx

✅ 访问:https://jellyfin.example.com


二、Jellyfin 自带 SSL(不推荐)

Jellyfin 支持直接配置证书,但功能较弱。

1. 准备证书(PEM 格式)

/etc/ssl/jellyfin/cert.pem
/etc/ssl/jellyfin/key.pem

2. 修改 Jellyfin 配置

sudo vi /etc/jellyfin/network.xml

添加:

<IsHttps>true</IsHttps>
<CertificatePath>/etc/ssl/jellyfin/cert.pem</CertificatePath>
<CertificatePassword></CertificatePassword>
<HttpsPort>8920</HttpsPort>

3. 重启服务

sudo systemctl restart jellyfin

⚠️ 缺点:不支持自动续签、不支持多域名


三、使用 Caddy(最简单)

sudo yum install -y caddy

Caddyfile:

jellyfin.example.com {
    reverse_proxy 127.0.0.1:8096
}
sudo systemctl restart caddy

✅ 自动 HTTPS


四、防火墙注意

sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --permanent --add-service=https
sudo firewall-cmd --reload

总结推荐

方案 推荐度 说明
Nginx + Let’s Encrypt ⭐⭐⭐⭐⭐ 最稳定
Caddy ⭐⭐⭐⭐ 最简单
Jellyfin 自带 ⭐⭐ 仅测试用

如果你告诉我:

  • CentOS 版本(7 / 8 / Stream)
  • 是否有公网 IP / 域名

我可以给你精确命令版配置。

0 踩