在CentOS上为Jellyfin设置SSL证书,可以按照以下步骤进行:
方法一:使用Let’s Encrypt和Certbot
-
安装Certbot
sudo yum install epel-release sudo yum install certbot python3-certbot-nginx -
获取SSL证书 使用Certbot获取Let’s Encrypt的SSL证书。假设你的域名是
yourdomain.com,运行以下命令:sudo certbot --nginx -d yourdomain.com -d www.yourdomain.comCertbot会自动配置Nginx并生成证书。
-
配置Jellyfin使用HTTPS 编辑Jellyfin的配置文件
/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>确保
CertificatePath和PrivateKeyPath指向正确的证书和私钥文件路径。 -
重启Jellyfin服务
sudo systemctl restart jellyfin
方法二:手动安装SSL证书
-
获取SSL证书 你可以从Let’s Encrypt或其他证书颁发机构(CA)获取SSL证书。假设你已经有了证书文件
fullchain.pem和私钥文件privkey.pem。 -
配置Nginx 编辑Nginx配置文件
/etc/nginx/nginx.conf或创建一个新的配置文件(例如/etc/nginx/conf.d/jellyfin.conf),添加以下内容:server { listen 80; server_name yourdomain.com www.yourdomain.com; return 301 https://$host$request_uri; } server { listen 443 ssl; server_name yourdomain.com www.yourdomain.com; ssl_certificate /path/to/fullchain.pem; ssl_certificate_key /path/to/privkey.pem; ssl_protocols TLSv1.2 TLSv1.3; ssl_ciphers HIGH:!aNULL:!MD5; location / { proxy_pass http://localhost: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; } }确保
ssl_certificate和ssl_certificate_key指向正确的证书和私钥文件路径。 -
重启Nginx服务
sudo systemctl restart nginx -
配置Jellyfin使用HTTPS 编辑Jellyfin的配置文件
/etc/jellyfin/config/config.xml,找到或添加以下部分:<Server> <HttpPort>8096</HttpPort> <HttpsPort>8443</HttpsPort> <CertificatePath>/path/to/fullchain.pem</CertificatePath> <PrivateKeyPath>/path/to/privkey.pem</PrivateKeyPath> </Server>确保
CertificatePath和PrivateKeyPath指向正确的证书和私钥文件路径。 -
重启Jellyfin服务
sudo systemctl restart jellyfin
通过以上步骤,你应该能够在CentOS上成功为Jellyfin设置SSL证书。