在 CentOS 上为 Jellyfin 配置 SSL(HTTPS),常见有三种方式。下面按推荐程度给你说明,最常用的是 反向代理 + Let’s Encrypt。
sudo yum install -y epel-release
sudo yum install -y nginx
sudo systemctl enable --now nginx
sudo yum install -y certbot python3-certbot-nginx
假设你有域名 jellyfin.example.com
sudo certbot --nginx -d jellyfin.example.com
按提示填写邮箱,自动配置 HTTPS
编辑 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;
}
}
sudo nginx -t
sudo systemctl restart nginx
✅ 访问:https://jellyfin.example.com
Jellyfin 支持直接配置证书,但功能较弱。
/etc/ssl/jellyfin/cert.pem
/etc/ssl/jellyfin/key.pem
sudo vi /etc/jellyfin/network.xml
添加:
<IsHttps>true</IsHttps>
<CertificatePath>/etc/ssl/jellyfin/cert.pem</CertificatePath>
<CertificatePassword></CertificatePassword>
<HttpsPort>8920</HttpsPort>
sudo systemctl restart jellyfin
⚠️ 缺点:不支持自动续签、不支持多域名
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 自带 | ⭐⭐ | 仅测试用 |
如果你告诉我:
我可以给你精确命令版配置。