要在Ubuntu上实现Jellyfin的远程访问,您需要进行以下几个步骤:
首先,确保您的Ubuntu系统已经更新,并安装必要的软件包:
sudo apt update
sudo apt install apt-transport-https ca-certificates gnupg 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 <<EOF | sudo tee /etc/apt/sources.list.d/jellyfin.sources
deb [signed-by=/etc/apt/keyrings/jellyfin.gpg] https://repo.jellyfin.org/ $(lsb_release -cs) main
EOF
sudo apt update
最后,安装Jellyfin:
sudo apt install jellyfin -y
sudo systemctl start jellyfin
sudo systemctl enable jellyfin
sudo apt install ufw -y
sudo ufw allow OpenSSH
sudo ufw allow "WWW Full"
sudo ufw enable
sudo ufw status
sudo apt install apache2 certbot python3-certbot-apache -y
sudo a2enmod proxy proxy_http ssl proxy_wstunnel remoteip http2 headers
sudo systemctl restart apache2
sudo mkdir -p /var/www/html/jellyfin/public_html
sudo chown -R www-data:www-data /var/www/html/jellyfin/public_html
sudo certbot certonly --agree-tos --email your_email@gmail.com --no-eff-email --webroot -w /var/www/html -d your_domain
sudo nano /etc/apache2/sites-available/jellyfin.conf
在配置文件中插入以下内容,根据需要更改域名、SSL证书路径和服务器IP地址:
<VirtualHost *:80>
ServerName your_domain
Redirect permanent / https://your_domain/
ErrorLog ${APACHE_LOG_DIR}/your_domain-error.log
CustomLog ${APACHE_LOG_DIR}/your_domain-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>
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 /usr/local/cpolar
# 登录cpolar客户端
/usr/local/cpolar/bin/cpolar
在cpolar客户端界面中,点击“隧道管理” -> “创建隧道”,设置隧道名称、本地地址(Jellyfin默认端口8096)、协议(http或https)等信息,完成隧道创建后,即可通过生成的公网地址从外部访问您的Jellyfin服务。
通过以上步骤,您可以在Ubuntu上成功安装、配置并实现Jellyfin的远程访问。