温馨提示×

centos jellyfin怎样域名访问

小樊
43
2026-09-11 20:25:10
栏目: 云计算

CentOS 上让 Jellyfin 通过域名访问,一般思路是:

  1. Jellyfin 正常监听本地端口(默认 8096
  2. Nginx / Caddy 做反向代理
  3. 域名解析到服务器 IP
  4. (可选)配置 HTTPS

下面给你一套常见、稳妥的方案(Nginx + 域名 + HTTPS)


一、前提条件

  • 已安装 Jellyfin(默认端口 8096
  • 有一个域名(如 jellyfin.example.com
  • 服务器有公网 IP
  • 防火墙/安全组已放行 80443

二、域名解析

在你的域名服务商处添加记录:

类型:A
主机名:jellyfin
记录值:你的服务器公网IP

例如:

jellyfin.example.com → 1.2.3.4

三、安装 Nginx

sudo yum install epel-release -y
sudo yum install nginx -y
sudo systemctl enable --now nginx

四、配置 Nginx 反向代理

创建配置文件:

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

        # WebSocket 支持(Jellyfin 需要)
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
    }
}

保存后测试并重启:

sudo nginx -t
sudo systemctl restart nginx

此时访问:

http://jellyfin.example.com

✅ 已可通过域名访问


五、配置 HTTPS(强烈推荐)

1. 安装 certbot

sudo yum install certbot python3-certbot-nginx -y

2. 申请证书

sudo certbot --nginx -d jellyfin.example.com

按提示操作,certbot 会自动:

  • 申请证书
  • 修改 Nginx 配置
  • 开启 443
  • 配置 HTTP → HTTPS 跳转

六、Jellyfin 后台设置(重要)

登录 Jellyfin → 控制台 → 网络

建议设置:

  • ✅ 允许通过代理
  • 外部域名:https://jellyfin.example.com
  • 反向代理:启用
  • 公共 HTTPS 地址填写:https://jellyfin.example.com

七、防火墙放行(如有)

sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --permanent --add-service=https
sudo firewall-cmd --reload

八、常见问题

1. 访问空白 / 无法加载

检查:

  • Nginx 是否运行
  • Jellyfin 是否监听 127.0.0.1:8096
  • 是否漏了 WebSocket 配置

2. 端口冲突

不要直接暴露 8096 到公网,建议只开 80/443

3. 内网访问慢

可同时保留:

http://局域网IP:8096

九、最简方案(不想用 Nginx?)

如果你只是内网 / 临时使用,也可以:

  • 路由器做端口映射
  • 直接访问:http://域名:8096
  • 但不安全,不推荐公网使用

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

  • CentOS 版本(7 / 8 / Stream)
  • 是否公网服务器
  • 是否已有 Nginx

我可以给你更精确的一步一步配置

0