ubuntu

ubuntu上jellyfin如何进行远程访问

小樊
42
2025-06-01 13:23:22
栏目: 智能运维

在Ubuntu上实现Jellyfin的远程访问,通常需要以下几个步骤:

安装Jellyfin

首先,确保您的Ubuntu系统已经更新,并安装必要的软件包:

sudo apt update
sudo apt install apt-transport-https ca-certificates curl
mkdir -p /etc/apt/keyrings
curl -fsSL https://repo.jellyfin.org/jellyfin_team.gpg.key | sudo gpg --dearmor -o /etc/apt/keyrings/jellyfin.gpg

然后,创建一个Jellyfin仓库文件并添加到APT源列表中:

cat > /etc/apt/sources.list.d/jellyfin.sources << EOF
deb [signed-by=/etc/apt/keyrings/jellyfin.gpg] https://repo.jellyfin.org/ubuntu $(lsb_release -cs) main
EOF
sudo apt update

最后,安装Jellyfin:

sudo apt install jellyfin -y

配置Jellyfin以允许远程访问

启动Jellyfin服务:

sudo systemctl start jellyfin

设置Jellyfin开机自启:

sudo systemctl enable jellyfin

配置防火墙:

sudo apt install ufw -y
sudo ufw allow 8096/tcp
sudo ufw enable

设置Apache作为反向代理(可选,但推荐)

创建Jellyfin的web根目录并设置权限:

sudo mkdir -p /var/www/html/jellyfin/public_html
sudo chown -R www-data:www-data /var/www/html/jellyfin/public_html

使用Certbot为你的域名获取SSL证书(如果使用自定义域名):

sudo certbot certonly --agree-tos --email your_email@example.com --no-eff-email --webroot -w /var/www/html -d your_domain

配置Apache虚拟主机:

sudo nano /etc/apache2/sites-available/jellyfin.conf

在配置文件中插入以下内容,根据需要更改域名和SSL证书路径:

<VirtualHost *:80>
    ServerName your_domain
    Redirect permanent / https://your_domain/
    ErrorLog ${APACHE_LOG_DIR}/jellyfin-error.log
    CustomLog ${APACHE_LOG_DIR}/jellyfin-access.log combined
</VirtualHost>

<VirtualHost *:443>
    ServerName your_domain
    DocumentRoot /var/www/html/jellyfin/public_html
    ProxyPreserveHost On
    ProxyPass "/.well-known/" "!"
    RequestHeader set X-Forwarded-Proto "https"
    RequestHeader set X-Forwarded-Port "443"
    ProxyPass "/socket" "ws://0.0.0.0:8096/socket"
    ProxyPassReverse "/socket" "ws://0.0.0.0:8096/socket"
    ProxyPass "/" "http://0.0.0.0:8096/"
    ProxyPassReverse "/" "http://0.0.0.0:8096/"
</VirtualHost>

启用Apache模块并重启Apache:

sudo a2enmod proxy proxy_http ssl proxy_wstunnel remoteip http2 headers
sudo systemctl restart apache2

实现远程访问(可选)

如果您没有公网IP,可以使用内网穿透工具如cpolar或花生壳来实现远程访问。以下是使用cpolar的简单步骤:

安装cpolar:

wget https://download.cpolar.com/cpolar-linux-amd64.tar.gz
tar -xzf cpolar-linux-amd64.tar.gz
sudo mv cpolar-linux-amd64/cpolar /usr/local/cpolar

配置cpolar:

/usr/local/cpolar/bin/cpolar login

创建内网穿透隧道:

在cpolar客户端界面中,点击“隧道管理” - “创建隧道”,设置隧道名称、本地地址(Jellyfin默认端口8096)、协议(http或https)等信息,完成隧道创建后,即可通过生成的公网地址从外部访问您的Jellyfin服务。

以上步骤应该能帮助您在Ubuntu上成功安装、配置并实现Jellyfin的远程访问。

0
看了该问题的人还看了