温馨提示×

centos jellyfin如何远程访问

小樊
46
2026-09-08 23:13:38
栏目: 智能运维

CentOS 上部署的 Jellyfin 想要实现远程访问,一般有以下几种方式。下面按推荐程度从易到难说明。


一、最推荐:反向代理 + 域名 + HTTPS(公网 IP 或云服务器)

适用场景

  • 有公网 IP / 云服务器
  • 想要安全、稳定、可长期使用

基本思路

互联网 → 域名 → Nginx → Jellyfin(8096)

步骤概览

  1. Jellyfin 正常监听

    sudo systemctl status jellyfin
    

    默认端口:8096

  2. 安装 Nginx

    sudo dnf install nginx -y
    sudo systemctl enable --now nginx
    
  3. 配置反向代理

    server {
        listen 80;
        server_name jellyfin.example.com;
    
        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;
        }
    }
    
  4. 申请 HTTPS(可选但强烈推荐)

    sudo dnf install certbot python3-certbot-nginx -y
    sudo certbot --nginx
    
  5. 开放防火墙

    sudo firewall-cmd --permanent --add-service=http
    sudo firewall-cmd --permanent --add-service=https
    sudo firewall-cmd --reload
    
  6. 路由器端口转发(非云服务器)

    • 外网 80 / 443 → 内网 CentOS IP

二、最简单:直接端口映射(不推荐长期使用)

适合

  • 临时测试
  • 内网穿透不想配置太多

步骤

  1. Jellyfin 默认端口 8096
  2. 路由器做端口转发:
    外部端口 8096 → 内部 IP:8096
    
  3. 访问:
    http://你的公网IP:8096
    

⚠️ 风险:

  • 无 HTTPS
  • 易被扫描攻击
  • 不适合公网长期暴露

三、内网穿透(无公网 IP 适用)

常见方案

  • frp
  • ngrok
  • Cloudflare Tunnel(最推荐)

Cloudflare Tunnel 示例

cloudflared tunnel --url http://localhost:8096

优点:

  • 免费 HTTPS
  • 不需要公网 IP
  • 隐藏真实 IP

四、Jellyfin 安全设置建议(重要)

Jellyfin 后台 → 控制台 → 网络

  • ✅ 启用 Enable HTTPS
  • ✅ 限制允许的网络(可选)
  • ✅ 使用强密码
  • ✅ 禁用 Guest 用户

五、常见问题排查

无法访问

sudo firewall-cmd --list-all
sudo netstat -tunlp | grep 8096

SELinux 问题

sudo setsebool -P httpd_can_network_connect 1

六、总结推荐方案

场景 推荐方案
云服务器 Nginx + HTTPS
家庭宽带 Cloudflare Tunnel
临时测试 端口映射
长期公网 域名 + 反代

如果你愿意,可以告诉我:

  • ✅ CentOS 版本(7 / 8 / Stream)
  • ✅ 是否有公网 IP
  • ✅ 是否在路由器后

我可以直接给你一套可复制的配置

0