- 首页 >
- 问答 >
-
智能运维 >
- 如何在Linux上配置Jellyfin网络设置
如何在Linux上配置Jellyfin网络设置
小樊
35
2025-12-30 10:05:04
Linux上配置Jellyfin网络设置
一 基础网络与端口放行
- 确认网卡与地址:使用命令查看网卡名与IP,例如 ip a。
- Ubuntu/Debian 使用 UFW 放行端口(HTTP 默认 8096/TCP):
sudo ufw allow 8096/tcp
sudo ufw enable && sudo ufw status
- CentOS/RHEL/Fedora 使用 firewalld 放行端口(HTTP 8096/TCP,HTTPS 8920/TCP,DLNA 1900/UDP,mDNS 5353/UDP):
sudo firewall-cmd --zone=public --add-port=8096/tcp --permanent
sudo firewall-cmd --zone=public --add-port=8920/tcp --permanent
sudo firewall-cmd --zone=public --add-port=1900/udp --permanent
sudo firewall-cmd --zone=public --add-port=5353/udp --permanent
sudo firewall-cmd --reload
- 云服务器需同时在云厂商的安全组放行对应端口。
二 主机网络与端口规划
- 建议为服务器配置静态IP,避免DHCP导致地址变化影响端口转发与访问。
- Ubuntu(Netplan,文件名可能为 /etc/netplan/01-netcfg.yaml 或 50-cloud-init.yaml):
network:
version: 2
renderer: networkd
ethernets:
ens33:
dhcp4: no
addresses: [“192.168.1.100/24”]
gateway4: 192.168.1.1
nameservers:
addresses: [“8.8.8.8”, “8.8.4.4”]
应用:sudo netplan apply
- CentOS(ifcfg 文件,网卡名可能为 eth0/ens33):
BOOTPROTO=static
IPADDR=192.168.1.100
NETMASK=255.255.255.0
GATEWAY=192.168.1.1
DNS1=8.8.8.8
DNS2=8.8.4.4
ONBOOT=yes
应用:sudo systemctl restart NetworkManager 或 sudo systemctl restart network
- 端口规划建议:
- HTTP 访问:8096/TCP
- HTTPS 访问:8920/TCP(启用TLS时)
- DLNA 发现:1900/UDP
- mDNS 发现:5353/UDP
- 远程访问可在路由器将外部端口(如 8888/TCP)转发到服务器 192.168.1.100:8096。
三 Jellyfin 管理界面网络设置
- 访问控制台:在浏览器打开 http://服务器IP:8096,完成管理员创建与媒体库添加。
- 允许外部访问:进入 管理 → 网络(或“高级设置”),将“已启用外部访问”设为开启,并按需添加外部访问地址(如 http://公网IP:8888 或 https://域名)。
- 远程访问地址填写示例:协议与端口需与实际访问方式一致(HTTP 用 8096,HTTPS 用 8920;若经路由器转发,外部端口可为 8888)。
四 反向代理与 HTTPS 配置
- 使用 Nginx 反向代理(示例,域名替换为你的域名或服务器IP):
server {
listen 80;
server_name your_domain_or_ip;
location / {
proxy_pass http://localhost: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;
}
}
校验与生效:sudo nginx -t && sudo systemctl restart nginx
- 申请 Let’s Encrypt 证书(已安装 certbot 与 Nginx 插件):
sudo apt install certbot python3-certbot-nginx
sudo certbot --nginx -d your_domain
证书生效后,可通过 https://your_domain 安全访问。
五 远程访问与排错要点
- 路由器端口转发规则示例:外部端口 8888/TCP → 内部IP 192.168.1.100,内部端口 8096/TCP;远程用 http://公网IP:8888 访问。
- 云服务器:除系统防火墙外,务必在安全组放行 8096/TCP(及 8920/TCP 若启用 HTTPS)。
- 服务与连通性检查:
- 重启服务:sudo systemctl restart jellyfin
- 查看状态:sudo systemctl status jellyfin
- 本机连通:curl -I http://127.0.0.1:8096
- 局域网连通:在另一台设备访问 http://服务器局域网IP:8096
- 发现服务:确保 1900/UDP 与 5353/UDP 未被阻断,以便客户端发现 Jellyfin。