温馨提示×

centos怎么让jellyfin外网访问

小樊
35
2026-09-21 05:16:41
栏目: 智能运维

CentOS 上让 Jellyfin 支持外网访问,一般有以下几种常见方式。下面按推荐程度从易到难说明,你可以根据自己环境选择。


一、最推荐:使用反向代理 + 域名(安全、稳定)

适用场景

  • 有公网 IP
  • 有域名(可选)
  • 想用 https://jellyfin.example.com 访问

1️⃣ 确保 Jellyfin 正常运行

systemctl status jellyfin

默认端口是 8096


2️⃣ 开放防火墙端口(如果用 Nginx)

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

3️⃣ 安装 Nginx

yum install nginx -y
systemctl enable --now nginx

4️⃣ 配置反向代理

vi /etc/nginx/conf.d/jellyfin.conf

示例配置:

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

5️⃣ 申请 HTTPS(强烈推荐)

yum install certbot python3-certbot-nginx -y
certbot --nginx -d jellyfin.example.com

✅ 完成后即可外网访问:

https://jellyfin.example.com

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

适用场景

  • 临时测试
  • 无域名
  • 能控制路由器

步骤

  1. Jellyfin 端口:8096
  2. 路由器做 端口转发
    外部端口 8096 → 内部IP:8096
    
  3. 防火墙放行
firewall-cmd --permanent --add-port=8096/tcp
firewall-cmd --reload
  1. 访问:
http://你的公网IP:8096

⚠️ 缺点:

  • 不安全(HTTP)
  • 容易被扫端口

三、内网穿透(无公网 IP 也行)

常见工具

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

Cloudflare Tunnel 示例

# 安装 cloudflared
cloudflared tunnel --url http://localhost:8096

✅ 不用公网 IP
✅ 自带 HTTPS


四、Jellyfin 自身设置注意

在 Jellyfin 后台: 设置 → 网络

  • ✅ 允许远程连接
  • 绑定地址可留空
  • 反向代理时注意 Known proxies

五、安全建议(很重要)

✅ 不要长期暴露 8096
✅ 使用 HTTPS
✅ 设置强密码
✅ 可限制 IP 或加 Basic Auth


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

  • CentOS 版本(7 / 8 / Stream)
  • 是否有公网 IP
  • 是否有域名

我可以给你一步步精确命令

0