Cómo instalar el servidor multimedia Jellyfin en Debian 11

Jellyfin es una aplicación de streaming multimedia gratuita y de código abierto que organiza, gestiona y comparte archivos multimedia digitales en dispositivos conectados en red. Te permite transmitir los archivos multimedia subidos a tu PC, portátil, móvil y Roku. Proporciona una interfaz web interactiva para gestionar todas tus fotos, vídeos y música. Si buscas una solución alternativa a Plex y Netflix, Jellyfin es la mejor opción.

Características

  • Gratuito, de código abierto y multiplataforma
  • Admite aceleración por hardware de la codificación/decodificación de vídeo mediante FFMpeg
  • Permite obtener metadatos de TheTVDB y TheMovieDB
  • Sin límite de reproducción en aplicaciones móviles

Este post te mostrará cómo instalar la aplicación de streaming multimedia Jellyfin con Nginx y Let’s Encrypt SSL en Debian 11.

Requisitos previos

  • Un servidor con Debian 11.
  • Un nombre de dominio válido apuntado con la IP de tu servidor.
  • Una contraseña de root configurada en el servidor.

Instalar Jellyfin

Antes de empezar, tendrás que añadir el repositorio de Jellyfin a la APT. Para ello, instala primero las dependencias necesarias utilizando el siguiente comando:

apt-get install apt-transport-https ca-certificates gnupg2 curl git -y

Una vez instaladas todas las dependencias, añade la clave GPG y el repositorio con el siguiente comando:

wget -O - https://repo.jellyfin.org/jellyfin_team.gpg.key | apt-key add -
echo "deb [arch=$( dpkg --print-architecture )] https://repo.jellyfin.org/debian bullseye main" | tee /etc/apt/sources.list.d/jellyfin.list

A continuación, actualiza el repositorio e instala el Jellyfin utilizando el siguiente comando:

apt-get update -y
apt-get install jellyfin -y

Una vez instalado el Jellyfin, puedes verificar el estado del Jellyfin utilizando el siguiente comando:

systemctl status jellyfin

Obtendrás la siguiente salida:

? jellyfin.service - Jellyfin Media Server
     Loaded: loaded (/lib/systemd/system/jellyfin.service; enabled; vendor preset: enabled)
    Drop-In: /etc/systemd/system/jellyfin.service.d
             ??jellyfin.service.conf
     Active: active (running) since Fri 2022-02-04 03:48:50 UTC; 9s ago
   Main PID: 4989 (jellyfin)
      Tasks: 19 (limit: 2341)
     Memory: 85.0M
        CPU: 4.069s
     CGroup: /system.slice/jellyfin.service
             ??4989 /usr/bin/jellyfin --webdir=/usr/share/jellyfin/web --restartpath=/usr/lib/jellyfin/restart.sh --ffmpeg=/usr/lib/jellyfin->

Feb 04 03:48:56 debian11 jellyfin[4989]: [03:48:56] [INF] ServerId: 809b343f6da845699dd6447e1bb4f061
Feb 04 03:48:56 debian11 jellyfin[4989]: [03:48:56] [INF] Registering publisher for urn:schemas-upnp-org:device:MediaServer:1 on 127.0.0.1/32
Feb 04 03:48:56 debian11 jellyfin[4989]: [03:48:56] [WRN] 127.0.0.1/32: GetBindInterface: Loopback 127.0.0.1 returned.
Feb 04 03:48:56 debian11 jellyfin[4989]: [03:48:56] [INF] Executed all pre-startup entry points in 0:00:00.2808517
Feb 04 03:48:56 debian11 jellyfin[4989]: [03:48:56] [INF] Core startup complete
Feb 04 03:48:57 debian11 jellyfin[4989]: [03:48:57] [INF] Executed all post-startup entry points in 0:00:00.2169291
Feb 04 03:48:57 debian11 jellyfin[4989]: [03:48:57] [INF] Startup complete 0:00:06.7385186
Feb 04 03:48:59 debian11 jellyfin[4989]: [03:48:59] [INF] StartupTrigger fired for task: Update Plugins
Feb 04 03:48:59 debian11 jellyfin[4989]: [03:48:59] [INF] Queuing task PluginUpdateTask
Feb 04 03:48:59 debian11 jellyfin[4989]: [03:48:59] [INF] Executing Update Plugins

Por defecto, Jellyfin escucha en el puerto 8096. Puedes comprobarlo con el siguiente comando:

ss -antpl | grep 8096

Obtendrás la siguiente salida:

LISTEN 0      512          0.0.0.0:8096      0.0.0.0:*    users:(("jellyfin",pid=4989,fd=289))

Configurar Nginx como proxy inverso para Jellyfin

A continuación, tendrás que instalar y configurar Nginx como proxy inverso para Jellyfin. En primer lugar, instala Nginx con el siguiente comando:

apt-get install nginx -y

A continuación, crea un archivo de configuración del host virtual de Nginx con el siguiente comando:

nano /etc/nginx/conf.d/jellyfin.conf

Añade las siguientes líneas:

server {
      listen 80;
      server_name jellyfin.example.com;

      access_log /var/log/nginx/jellyfin.access;
      error_log /var/log/nginx/jellyfin.error;

    resolver 127.0.0.1 valid=30;

    # Security / XSS Mitigation Headers
    add_header X-Frame-Options "SAMEORIGIN";
    add_header X-XSS-Protection "1; mode=block";
    add_header X-Content-Type-Options "nosniff";


    location / {
        # Proxy main Jellyfin traffic
        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;
        proxy_set_header X-Forwarded-Protocol $scheme;
        proxy_set_header X-Forwarded-Host $http_host;

        # Disable buffering when the nginx proxy gets very resource heavy upon streaming
        proxy_buffering off;
    }

    # location block for /web - This is purely for aesthetics so /web/#!/ works instead of having to go to /web/index.html/#!/
    location = /web/ {
        # Proxy main Jellyfin traffic
        proxy_pass http://localhost:8096/web/index.html;
        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;
        proxy_set_header X-Forwarded-Protocol $scheme;
        proxy_set_header X-Forwarded-Host $http_host;
    }

    location /socket {
        # Proxy Jellyfin Websockets traffic
        proxy_pass http://localhost:8096/socket;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        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;
        proxy_set_header X-Forwarded-Protocol $scheme;
        proxy_set_header X-Forwarded-Host $http_host;
    }
}

Guarda y cierra el archivo y, a continuación, comprueba que el Nginx no contenga ningún error de sintaxis.

nginx -t

Obtendrás la siguiente salida:

nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

Por último, reinicia el Nginx para aplicar los cambios:

systemctl reload nginx

Para comprobar el estado del Nginx utiliza el siguiente comando:

systemctl status nginx

Deberías ver la siguiente salida:

? nginx.service - A high performance web server and a reverse proxy server
     Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
     Active: active (running) since Fri 2022-02-04 03:49:27 UTC; 55s ago
       Docs: man:nginx(8)
    Process: 6314 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
    Process: 6315 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
    Process: 6454 ExecReload=/usr/sbin/nginx -g daemon on; master_process on; -s reload (code=exited, status=0/SUCCESS)
   Main PID: 6395 (nginx)
      Tasks: 2 (limit: 2341)
     Memory: 2.8M
        CPU: 66ms
     CGroup: /system.slice/nginx.service
             ??6395 nginx: master process /usr/sbin/nginx -g daemon on; master_process on;
             ??6455 nginx: worker process

Feb 04 03:49:27 debian11 systemd[1]: Starting A high performance web server and a reverse proxy server...
Feb 04 03:49:27 debian11 systemd[1]: nginx.service: Failed to parse PID from file /run/nginx.pid: Invalid argument
Feb 04 03:49:27 debian11 systemd[1]: Started A high performance web server and a reverse proxy server.
Feb 04 03:50:17 debian11 systemd[1]: Reloading A high performance web server and a reverse proxy server.
Feb 04 03:50:17 debian11 systemd[1]: Reloaded A high performance web server and a reverse proxy server.

Acceder a la interfaz web de Jellyfin

Ahora, abre tu navegador web y accede a la interfaz web de Jellyfin utilizando la URL http://jellyfin.example.com. Serás redirigido a la siguiente página:

Selecciona tu idioma y pulsa el botón Siguiente. Deberías ver la siguiente página:

Introduce tu usuario y contraseña de administrador y pulsa el botón Siguiente. Deberías ver la siguiente página:

Pulsa el botón Siguiente. Deberías ver la siguiente página:

Selecciona el idioma de tus metadatos y pulsa el botón Siguiente. Deberías ver la página siguiente:

Selecciona la opción que prefieras y pulsa el botón Siguiente. Una vez instalado el Jellyfin, deberías ver la siguiente página:

Pulsa el botón Finalizar. Se te redirigirá a la página de inicio de sesión de Jellyfin:

Proporciona tu nombre de usuario y contraseña de administrador, y haz clic en el botón Iniciar sesión. Deberías ver el panel de control de Jellyfin en la siguiente página:

Asegura Jellyfin con Let’s Encrypt

A continuación, tendrás que instalar el paquete cliente Certbot para instalar y gestionar el SSL Let’s Encrypt.

Primero, instala el Certbot con el siguiente comando:

apt-get install certbot python3-certbot-nginx -y

Una vez finalizada la instalación, ejecuta el siguiente comando para instalar el SSL de Let’s Encrypt en tu sitio web:

certbot --nginx -d jellyfin.example.com

Se te pedirá que proporciones una dirección de correo electrónico válida y que aceptes las condiciones del servicio, como se muestra a continuación:

Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator nginx, Installer nginx
Enter email address (used for urgent renewal and security notices) (Enter 'c' to
cancel): [email protected]

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Please read the Terms of Service at
https://letsencrypt.org/documents/LE-SA-v1.2-November-15-2017.pdf. You must
agree in order to register with the ACME server at
https://acme-v02.api.letsencrypt.org/directory
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(A)gree/(C)ancel: A

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Would you be willing to share your email address with the Electronic Frontier
Foundation, a founding partner of the Let's Encrypt project and the non-profit
organization that develops Certbot? We'd like to send you email about our work
encrypting the web, EFF news, campaigns, and ways to support digital freedom.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(Y)es/(N)o: Y
Obtaining a new certificate
Performing the following challenges:
http-01 challenge for jellyfin.example.com
Waiting for verification...
Cleaning up challenges
Deploying Certificate to VirtualHost /etc/nginx/conf.d/jellyfin.conf

A continuación, elige si deseas o no redirigir el tráfico HTTP a HTTPS, como se muestra a continuación:

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1: No redirect - Make no further changes to the webserver configuration.
2: Redirect - Make all requests redirect to secure HTTPS access. Choose this for
new sites, or if you're confident your site works on HTTPS. You can undo this
change by editing your web server's configuration.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Select the appropriate number [1-2] then [enter] (press 'c' to cancel): 2

Escribe 2 y pulsa Intro para finalizar la instalación. Deberías ver el siguiente resultado:

Redirecting all traffic on port 80 to ssl in /etc/nginx/conf.d/jellyfin.conf

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Congratulations! You have successfully enabled https://jellyfin.example.com

You should test your configuration at:
https://www.ssllabs.com/ssltest/analyze.html?d=jellyfin.example.com
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

IMPORTANT NOTES:
 - Congratulations! Your certificate and chain have been saved at:
   /etc/letsencrypt/live/jellyfin.example.com/fullchain.pem
   Your key file has been saved at:
   /etc/letsencrypt/live/jellyfin.example.com/privkey.pem
   Your cert will expire on 2022-05-07. To obtain a new or tweaked
   version of this certificate in the future, simply run certbot again
   with the "certonly" option. To non-interactively renew *all* of
   your certificates, run "certbot renew"
 - Your account credentials have been saved in your Certbot
   configuration directory at /etc/letsencrypt. You should make a
   secure backup of this folder now. This configuration directory will
   also contain certificates and private keys obtained by Certbot so
   making regular backups of this folder is ideal.
 - If you like Certbot, please consider supporting our work by:

   Donating to ISRG / Let's Encrypt:   https://letsencrypt.org/donate
   Donating to EFF:                    https://eff.org/donate-le

 - We were unable to subscribe you the EFF mailing list because your
   e-mail address appears to be invalid. You can try again later by
   visiting https://act.eff.org.

Conclusión

Enhorabuena! has instalado correctamente Jellyfin con Nginx y Let’s Encrypt SSL en Debian 11. Ahora puedes empezar a subir tus archivos multimedia y transmitirlos desde dispositivos móviles.

También te podría gustar...