温馨提示×

centos怎样给jellyfin配域名

小樊
42
2026-09-21 05:09:39
栏目: 云计算

在 CentOS 上给 Jellyfin 配置域名,通常分三步:域名解析 → 反向代理(Nginx) → HTTPS(可选但推荐)。下面以 CentOS 7/8 + Nginx 为例说明。


一、前提条件

  1. 已安装并运行 Jellyfin(默认端口 8096
  2. 有一个域名(如 media.example.com
  3. 服务器有公网 IP
  4. 已开放防火墙端口(80 / 443)

二、域名解析

在域名服务商处添加 A 记录

media.example.com → 你的服务器公网IP

生效可用:

ping media.example.com

三、安装 Nginx(如未安装)

# CentOS 7
yum install -y nginx

# CentOS 8
dnf install -y nginx

systemctl enable --now nginx

四、配置 Nginx 反向代理

新建配置文件:

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

内容示例(HTTP 版):

server {
    listen 80;
    server_name media.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;
    }
}

测试并重载:

nginx -t
systemctl reload nginx

此时可通过:

http://media.example.com

访问 Jellyfin。


五、配置 HTTPS(强烈推荐)

1. 安装 Certbot

# CentOS 7
yum install -y epel-release
yum install -y certbot python2-certbot-nginx

# CentOS 8
dnf install -y certbot python3-certbot-nginx

2. 申请证书并自动配置

certbot --nginx -d media.example.com

按提示选择是否强制 HTTPS。


六、Jellyfin 内网设置(重要)

登录 Jellyfin → 控制台 → 网络

建议设置:

  • 基础 URL:/ (一般不用改)
  • 绑定到本地地址:否
  • 已知代理:media.example.com

七、防火墙放行

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

八、常见问题

1. 访问空白 / 502

  • 检查 Jellyfin 是否在运行
  • 检查 8096 是否监听
ss -lntp | grep 8096

2. WebSocket 问题(播放卡顿)

在 Nginx 中补充:

proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";

如果你愿意,我可以:

  • 给你 完整 HTTPS 配置文件
  • 帮你做 只允许域名访问、禁止 IP 访问
  • 或配置 Cloudflare + Jellyfin

你目前是 CentOS 几?Jellyfin 装在 Docker 还是原生?

0