在 CentOS 上给 Jellyfin 开启 HTTPS,常见有两种方式:
通过 Nginx / Caddy 提供 HTTPS,Jellyfin 本身仍走 HTTP。
sudo yum install nginx -y
sudo systemctl enable --now nginx
sudo yum install certbot python3-certbot-nginx -y
sudo certbot --nginx -d jellyfin.yourdomain.com
编辑配置:
sudo vi /etc/nginx/conf.d/jellyfin.conf
示例配置:
server {
listen 80;
server_name jellyfin.yourdomain.com;
return 301 https://$host$request_uri;
}
server {
listen 443 ssl;
server_name jellyfin.yourdomain.com;
ssl_certificate /etc/letsencrypt/live/jellyfin.yourdomain.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/jellyfin.yourdomain.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 reload nginx
✅ 访问:https://jellyfin.yourdomain.com
适合内网或测试环境。
需要:
cert.pfx(包含私钥)生成示例(自签):
openssl req -x509 -newkey rsa:2048 -keyout key.pem -out cert.pem -days 365
openssl pkcs12 -export -out cert.pfx -inkey key.pem -in cert.pem
编辑:
/etc/jellyfin/network.xml
示例:
<IsHttps>true</IsHttps>
<HttpsPort>8920</HttpsPort>
<CertificatePath>/path/to/cert.pfx</CertificatePath>
<CertificatePassword>你的密码</CertificatePassword>
sudo systemctl restart jellyfin
✅ 访问:https://IP:8920
| 场景 | 推荐方式 |
|---|---|
| 公网访问 | Nginx + Let’s Encrypt |
| 内网/测试 | Jellyfin 自带 HTTPS |
| 简单省事 | Caddy 自动 HTTPS |
如果你告诉我:
我可以给你 精确配置命令。