在 CentOS 上让 Jellyfin 通过域名访问,一般思路是:
8096)下面给你一套常见、稳妥的方案(Nginx + 域名 + HTTPS)。
8096)jellyfin.example.com)80、443在你的域名服务商处添加记录:
类型:A
主机名:jellyfin
记录值:你的服务器公网IP
例如:
jellyfin.example.com → 1.2.3.4
sudo yum install epel-release -y
sudo yum install nginx -y
sudo systemctl enable --now 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
✅ 已可通过域名访问
sudo yum install certbot python3-certbot-nginx -y
sudo certbot --nginx -d jellyfin.example.com
按提示操作,certbot 会自动:
登录 Jellyfin → 控制台 → 网络
建议设置:
https://jellyfin.example.comhttps://jellyfin.example.comsudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --permanent --add-service=https
sudo firewall-cmd --reload
检查:
127.0.0.1:8096不要直接暴露 8096 到公网,建议只开 80/443
可同时保留:
http://局域网IP:8096
如果你只是内网 / 临时使用,也可以:
http://域名:8096如果你愿意,可以告诉我:
我可以给你更精确的一步一步配置。