如何在Centos上为Jellyfin设置SSL证书

1077
2025/4/14 18:32:04
栏目: 云计算
开发者测试专用服务器限时活动,0元免费领,库存有限,领完即止! 点击查看>>

在CentOS上为Jellyfin设置SSL证书,可以按照以下步骤进行:

方法一:使用Let’s Encrypt和Certbot

  1. 安装Certbot

    sudo yum install epel-release
    sudo yum install certbot python3-certbot-nginx
    
  2. 获取SSL证书 使用Certbot获取Let’s Encrypt的SSL证书。假设你的域名是yourdomain.com,运行以下命令:

    sudo certbot --nginx -d yourdomain.com -d www.yourdomain.com
    

    Certbot会自动配置Nginx并生成证书。

  3. 配置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>
    

    确保CertificatePathPrivateKeyPath指向正确的证书和私钥文件路径。

  4. 重启Jellyfin服务

    sudo systemctl restart jellyfin
    

方法二:手动安装SSL证书

  1. 获取SSL证书 你可以从Let’s Encrypt或其他证书颁发机构(CA)获取SSL证书。假设你已经有了证书文件fullchain.pem和私钥文件privkey.pem

  2. 配置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_certificatessl_certificate_key指向正确的证书和私钥文件路径。

  3. 重启Nginx服务

    sudo systemctl restart nginx
    
  4. 配置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>
    

    确保CertificatePathPrivateKeyPath指向正确的证书和私钥文件路径。

  5. 重启Jellyfin服务

    sudo systemctl restart jellyfin
    

通过以上步骤,你应该能够在CentOS上成功为Jellyfin设置SSL证书。

辰迅云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>

推荐阅读: CentOS JSP如何解决内存溢出