在CentOS上为Jellyfin设置SSL证书,可以按照以下步骤进行:
安装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.com
Certbot会自动配置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证书
你可以从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证书。
辰迅云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>
推荐阅读: CentOS JSP如何解决内存溢出