跳至主内容

网络配置

非官方测试版翻译

本页面由 PageTurner AI 翻译(测试版)。未经项目官方认可。 发现错误? 报告问题 →

作为服务器软件,Jellyfin 通过网络提供多种服务。 具体而言,Jellyfin 支持内容流媒体传输并内置网页客户端——这些功能完全通过 HTTP(S) 端口实现。

此外,在本地网络中,Jellyfin 提供多种自动发现服务。这些服务仅在本地子网内有效。

作为完全自托管的软件,Jellyfin 独立于互联网运行。 您无需将服务器暴露在互联网上即可使用。 Jellyfin 运行时也不需要互联网连接;但请注意,元数据需从各类供应商处加载,无网络连接时将无法获取。

端口绑定

本节旨在帮助管理员了解 Jellyfin 绑定的端口及其功能。

PortProtocolConfigurableDescription
8096TCP✔️Default HTTP
8920TCP✔️Default HTTPS
7359UDPClient Discovery
See details
  • HTTP Traffic (8096/TCP): The web frontend can be accessed here. You can modify this setting from the Networking page in the admin settings.

  • HTTPS Traffic (8920/TCP): Used when https is enabled. By default this port will not be used. This setting can also be modified from the Networking page to use a different port.

  • Client Discovery (7359/UDP): Allows clients to discover Jellyfin on the local network. A broadcast message to this port will return detailed information about your server that includes name, ip-address and ID.

访问 Jellyfin

本节重点介绍如何在网络环境中启用 Jellyfin。 您将在此了解如何实现仅限本地访问及互联网访问的配置方案。

通常可通过主机 IP 加指定端口在本地访问 Jellyfin,例如 http://10.0.0.2:8096。 也可创建指向 Jellyfin 服务器的本地 DNS 记录,例如 http://jellyfin.local:8096

Learn more about limitations with local DNS

Devices like Google Chromecast or Google Streamer use hardcoded DNS Servers - therefore they will not make use of your local DNS entries. There are multiple workarounds for this issue.

The easiest involves the usage of IPv6 Entries in the public DNS. Since IPv6 addresses do not differentiate between local and public, the address will be abled to be resolved locally. This, however, requires the use of a public DNS server - The Jellyfin Server does not have to be accessible from the outside though!

防火墙 / 端口转发

网络通常通过防火墙隔离,防火墙会拦截所有入站流量以保护网络安全。 要跨网络边界访问 Jellyfin,需在相应防火墙中开放或转发其端口。

请注意:开放端口意味着允许更高级别网络完全访问该端口。 因此直接将端口暴露给互联网存在安全隐患,强烈不推荐。

防火墙可部署在不同层级:

LayerExampleDescription
LocalDocker, VMOpen ports at this layer to allow traffic from the Host to enter the Application
Hostphysical machine, operating systemOpen ports at this layer to allow traffic from the Network to enter the Host device
NetworkRouterOpen ports at this layer to allow traffic from the Internet to enter the Local Network
Port forwarding vs. opening a Port

Whilst Routers often allow you to forward a port, firewalls typically only allow you to open one. The difference is within the Target. Opening a Port essentially just means that traffic on this Port will go through. Forwarding a Port you typically do in NAT scenarios - traffic is coming in on your public IP Address, what device inside your network should receive it. Sometimes, port forwarding also lets you map an external port to a different internal port.

How to open a Port

How exactly a port will be opened depends on your firewall software and its UI. Here is linked below how to open ports for:

外部访问

由于 Jellyfin 完全自托管,您需要手动将其暴露至互联网。 为此,您需要远程访问 HTTP(S) 端口的方法。 自动发现功能仅限本地网络,切勿暴露到外部环境。

要远程访问服务器,需通过互联网定位该服务器或其所在网络。 可通过设备的公网 IP 地址实现(IPv4),或直接使用服务器的 IPv6 地址。

存储 IP 地址的最简方案是使用域名并依赖 DNS 解析。 这在动态公网 IP 场景下可存储"当前 IP 地址"。 但使用域名并非强制要求。

将 Jellyfin 暴露至外网的常见方式包括:

  • 直接端口转发到互联网(不推荐!)

  • 通过反向代理转发

  • 使用 VPN 连接进入网络

  • 通过 VPS 反向代理到家庭网络

请参阅专用反向代理指南了解更多信息。

SSL / HTTPS

建议通过 HTTPS 访问服务器。 默认禁用 HTTPS,因其需要 SSL 证书支持。

SSL 证书通常由第三方机构颁发,用于验证服务器与 URL 的归属关系。 使用 HTTPS 时,请选用可信证书颁发机构(如 Let's Encrypt)。

注意

自签名证书存在安全风险和兼容性问题,强烈不建议使用。

虽然 Jellyfin 支持 HTTPS,但强烈建议在反向代理上单独处理 HTTPS 终止。您可在反向代理页面查看具体配置方法。

若需将服务暴露至公网,强烈建议通过 SSLLabs 检测 SSL 强度及服务器安全性。

基础 URL

支持通过路径访问 Jellyfin(例如 https://example.com/jellyfin)。

注意

已知基础 URL 会导致以下功能异常:HDHomeRun、DLNA 插件、Sonarr、Radarr 及 MrMC。

基础 URL 设置用于指定访问 Jellyfin 实例的 URL 前缀。该设置会在所有 URL 路径前添加指定片段。例如:若 Jellyfin 服务器位于 http://myserver,其主页为 http://myserver/web/index.html,设置基础 URL 为 /jellyfin 后,主页将变为 http://myserver/jellyfin/web/index.html。此功能适用于以下场景:管理员需通过单一域名访问多个 Jellyfin 实例;或 Jellyfin 实例需作为子路径挂载至提供其他服务的域名(其他服务已占用根路径 /)。

配置页面输入的值若缺少起始斜杠 /,系统会自动规范化补全。

此设置需重启服务器才能生效,以避免在管理员就绪前使现有路径失效。

该设置存在三个主要注意事项:

  1. 设置新基础 URL(如从 / 改为 /baseurl)或修改基础 URL(如从 /baseurl 改为 /newbaseurl)时,Jellyfin 服务器会自动处理重定向以避免无效页面。例如:访问基础 URL 为 /jellyfin 的服务器根路径 / 时,系统会自动附加 /jellyfin。但完全移除基础 URL(如从 /baseurl 改为 /,即配置留空)时不会触发重定向——所有含旧基础 URL 的路径将失效并返回 404 错误,移除时需特别注意。

  2. 当前客户端应用通常无法隐式处理基础 URL 重定向。例如:在 Android TV 应用中,Host设置必须包含基础 URL(如 http://myserver:8096/baseurl),否则连接会失败。

  3. 任何反向代理配置都需适配新基础 URL。通常将 / 路径代理至 Jellyfin 实例可兼容所有情况(路径会被自动规范化),这也是示例中的标准配置。但进行高级路由配置时需额外注意此问题。