温馨提示×

centos jellyfin怎么搭外网

小樊
40
2026-09-02 21:19:19
栏目: 智能运维

CentOS 上把 Jellyfin 暴露到外网访问,常见有几种方式。下面按「安全程度 + 实用性」给你一个完整思路,你可以按自己情况选。


一、最推荐方案(安全):反向代理 + HTTPS + 域名

适用场景

  • 有公网 IP 或云服务器
  • 想用 https://jellyfin.example.com 访问
  • 不希望直接暴露端口

1️⃣ 防火墙 & 端口

sudo firewall-cmd --permanent --add-port=80/tcp
sudo firewall-cmd --permanent --add-port=443/tcp
sudo firewall-cmd --reload

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;
    }
}

4️⃣ 申请 HTTPS(certbot)

sudo dnf install certbot python3-certbot-nginx -y
sudo certbot --nginx

✅ 外网访问:https://jellyfin.example.com


二、最简单(但不安全):直接端口映射

适用场景

  • 家里宽带
  • 只是自己用

步骤

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

⚠️ 风险:

  • 无 HTTPS
  • 容易被扫端口
  • 不建议长期用

三、家里无公网 IP(最稳):内网穿透

方案 1:frp(推荐)

  • 需要一台有公网 IP 的服务器
  • CentOS 装 frps,家里装 frpc

方案 2:Cloudflare Tunnel(强烈推荐)

# 安装 cloudflared
sudo dnf install cloudflared -y

cloudflared tunnel login
cloudflared tunnel create jellyfin
cloudflared tunnel route dns jellyfin jellyfin.example.com

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

✅ 优点:

  • 免费
  • 不用公网 IP
  • 自动 HTTPS

四、Jellyfin 自身设置(重要)

登录 Jellyfin → 控制台 → 网络

  • ✅ 允许远程访问
  • ✅ 反向代理支持(如果用 Nginx)
  • 可设置绑定域名

五、安全建议(必看)

  • ❌ 不要用 8096 裸端口长期暴露
  • ✅ 启用用户登录
  • ✅ 限制 IP(Nginx / 防火墙)
  • ✅ 定期更新 Jellyfin

六、你可以告诉我

我可以给你具体命令版本,只需要告诉我:

  1. CentOS 版本(7 / 8 / Stream)
  2. 是否有公网 IP
  3. 是否有域名
  4. 家用还是云服务器

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

0