在 CentOS 上部署的 Jellyfin 想要实现远程访问,一般有以下几种方式。下面按推荐程度从易到难说明。
互联网 → 域名 → Nginx → Jellyfin(8096)
Jellyfin 正常监听
sudo systemctl status jellyfin
默认端口:8096
安装 Nginx
sudo dnf install nginx -y
sudo systemctl enable --now nginx
配置反向代理
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;
}
}
申请 HTTPS(可选但强烈推荐)
sudo dnf install certbot python3-certbot-nginx -y
sudo certbot --nginx
开放防火墙
sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --permanent --add-service=https
sudo firewall-cmd --reload
路由器端口转发(非云服务器)
8096外部端口 8096 → 内部 IP:8096
http://你的公网IP:8096
⚠️ 风险:
cloudflared tunnel --url http://localhost:8096
优点:
在 Jellyfin 后台 → 控制台 → 网络:
Enable HTTPSsudo firewall-cmd --list-all
sudo netstat -tunlp | grep 8096
sudo setsebool -P httpd_can_network_connect 1
| 场景 | 推荐方案 |
|---|---|
| 云服务器 | Nginx + HTTPS |
| 家庭宽带 | Cloudflare Tunnel |
| 临时测试 | 端口映射 |
| 长期公网 | 域名 + 反代 |
如果你愿意,可以告诉我:
我可以直接给你一套可复制的配置。