Ubuntu 20.04에서 Nginx로 Jellyfin 미디어 서버를 설치하는 방법


이 페이지에서

  1. 전제 조건
  2. 시작하기\n
  3. 젤리핀 설치\n
  4. Nginx를 역방향 프록시로 구성\n
  5. 젤리핀 웹 UI 접속\n
  6. Lets Encrypt로 젤리핀 보호\n
  7. 결론

Jellyfin은 자체 미디어 서버를 호스팅할 수 있는 무료 오픈 소스 미디어 스트리밍 솔루션입니다. Linux, Windows 및 macOS에 설치할 수 있습니다. Jellyfin을 사용하여 영화, TV 프로그램, 음악, 사진과 같은 미디어를 관리하고 여러 장치에서 공유할 수 있습니다. 또한 Android, Android TV 및 Amazon Fire TV용 애플리케이션도 제공합니다. DLNA 지원, 재생 제한 없음, TheTVDB, TheMovieDB 및 Rotten Tomatoes에서 자동으로 메타데이터 가져오기, 자동 녹화, 하드웨어 가속 지원 등 여러 기능을 제공합니다.

이 튜토리얼에서는 Ubuntu 20.04에서 Jellyfin으로 미디어 서버를 설치하고 설정하는 방법을 설명합니다.

전제 조건

  • Ubuntu 20.04를 실행하는 서버.\n
  • 서버 IP를 가리키는 유효한 도메인 이름입니다.\n
  • 루트 암호는 서버에 구성됩니다.\n

시작하기

시작하기 전에 다음 명령을 사용하여 시스템 패키지를 업데이트하십시오.

apt-get update -y

모든 패키지가 업데이트되면 다음 명령을 사용하여 다른 필수 종속성을 설치합니다.

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

모든 종속성을 설치한 후 다음 단계로 진행할 수 있습니다.

젤리핀 설치

기본적으로 Jellyfin 패키지는 Ubuntu 20.04 기본 리포지토리에서 사용할 수 없습니다. 따라서 시스템에 Jellyfin 저장소를 추가해야 합니다. 먼저 다음 명령을 사용하여 GPG 키를 다운로드하고 추가합니다.

wget -O - https://repo.jellyfin.org/jellyfin_team.gpg.key | apt-key add -

GPG 키가 추가되면 다음 명령을 사용하여 Jellyfin 리포지토리를 APT에 추가합니다.

echo "deb [arch=$( dpkg --print-architecture )] https://repo.jellyfin.org/ubuntu focal main" | tee /etc/apt/sources.list.d/jellyfin.list

다음으로 리포지토리 캐시를 업데이트하고 다음 명령을 사용하여 Jellyfin을 설치합니다.

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

젤리핀 설치 후 다음 명령어로 젤리핀 서비스 상태를 확인할 수 있다.

systemctl status jellyfin

다음 출력이 표시되어야 합니다.

? 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 Sun 2020-12-27 06:15:40 UTC; 58s ago
   Main PID: 8454 (jellyfin)
      Tasks: 16 (limit: 4691)
     Memory: 92.3M
     CGroup: /system.slice/jellyfin.service
             ??8454 /usr/bin/jellyfin --webdir=/usr/share/jellyfin/web --restartpath=/usr/lib/jellyfin/restart.sh --ffmpeg=/usr/lib/jellyfin-f>

Dec 27 06:15:48 ubunt4 jellyfin[8454]: [06:15:48] [INF] Registering publisher for urn:schemas-upnp-org:device:MediaServer:1 on 104.245.33.>
Dec 27 06:15:48 ubunt4 jellyfin[8454]: [06:15:48] [INF] Executed all pre-startup entry points in 0:00:00.6715621
Dec 27 06:15:48 ubunt4 jellyfin[8454]: [06:15:48] [INF] Core startup complete
Dec 27 06:15:48 ubunt4 jellyfin[8454]: [06:15:48] [INF] Executed all post-startup entry points in 0:00:00.3885698
Dec 27 06:15:48 ubunt4 jellyfin[8454]: [06:15:48] [INF] Startup complete 0:00:08.0109863
Dec 27 06:15:50 ubunt4 jellyfin[8454]: [06:15:50] [INF] StartupTrigger fired for task: Update Plugins
Dec 27 06:15:50 ubunt4 jellyfin[8454]: [06:15:50] [INF] Queueing task PluginUpdateTask
Dec 27 06:15:50 ubunt4 jellyfin[8454]: [06:15:50] [INF] Executing Update Plugins
Dec 27 06:15:50 ubunt4 jellyfin[8454]: [06:15:50] [INF] Update Plugins Completed after 0 minute(s) and 0 seconds
Dec 27 06:15:51 ubunt4 jellyfin[8454]: [06:15:51] [INF] ExecuteQueuedTasks

기본적으로 Jellyfin은 포트 8096에서 수신 대기합니다. 다음 명령으로 확인할 수 있습니다.

ss -antpl | grep 8096

다음 출력이 표시되어야 합니다.

LISTEN    0         512                      *:8096                   *:*        users:(("jellyfin",pid=8454,fd=285))                                           

이 시점에서 Jellyfin이 설치되어 실행됩니다. 이제 다음 단계를 진행할 수 있습니다.

Nginx를 역방향 프록시로 구성

다음으로 Nginx를 Jellyfin의 리버스 프록시로 구성하는 것이 좋습니다. 이렇게 하려면 먼저 다음 명령을 사용하여 Nginx 웹 서버를 설치합니다.

apt-get install nginx -y

Nginx가 설치되면 새 Nginx 가상 호스트 구성 파일을 만듭니다.

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

다음 줄을 추가합니다.

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

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

      set $jellyfin 127.0.0.1;

      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;
          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://$jellyfin: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://$127.0.0.1:8096;
          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;
      }

        # 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";

}

완료되면 파일을 저장하고 닫습니다. 그런 다음 다음 명령을 사용하여 구문 오류가 있는지 Nginx를 확인합니다.

nginx -t

모든 것이 정상이면 다음과 같은 결과가 표시됩니다.

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

그런 다음 Nginx 서비스를 다시 시작하여 구성 변경 사항을 적용합니다.

systemctl restart nginx

다음 명령을 사용하여 Nginx의 상태를 확인할 수도 있습니다.

systemctl status nginx

다음 출력이 표시되어야 합니다.

? 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 Sun 2020-12-27 06:18:13 UTC; 6s ago
       Docs: man:nginx(8)
    Process: 9865 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
    Process: 9879 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
   Main PID: 9883 (nginx)
      Tasks: 3 (limit: 4691)
     Memory: 3.6M
     CGroup: /system.slice/nginx.service
             ??9883 nginx: master process /usr/sbin/nginx -g daemon on; master_process on;
             ??9884 nginx: worker process
             ??9885 nginx: worker process

Dec 27 06:18:13 ubunt4 systemd[1]: Starting A high performance web server and a reverse proxy server...
Dec 27 06:18:13 ubunt4 systemd[1]: Started A high performance web server and a reverse proxy server.

이 시점에서 Nginx가 설치되고 Jellyfin을 제공하도록 구성됩니다. 이제 다음 단계를 진행할 수 있습니다.

젤리핀 웹 UI 접근

이제 웹 브라우저를 열고 URL http://jellyfin.yourdomain.com을 사용하여 Jellyfin 웹 UI에 액세스합니다. 다음 화면으로 리디렉션됩니다.

언어를 선택하고 다음 버튼을 클릭합니다. 다음 화면이 표시됩니다.

관리자 사용자 이름, 암호를 제공하고 다음 버튼을 클릭합니다. 다음 화면이 표시됩니다.

다음 버튼을 클릭합니다. 다음 화면이 표시됩니다.

메타데이터 언어와 국가를 선택한 후 다음 버튼을 클릭합니다. 다음 화면이 표시됩니다.

원하는 옵션을 선택하고 다음 버튼을 클릭합니다. 다음 화면이 표시됩니다.

마침 버튼을 클릭합니다. Jellyfin 로그인 페이지가 표시됩니다.

사용자 이름, 비밀번호를 입력하고 로그인 버튼을 클릭합니다. 다음 화면에서 Jellyfin 대시보드를 볼 수 있습니다.

이제 미디어를 라이브러리에 추가하고 인터넷을 통해 액세스할 수 있습니다.

Lets Encrypt로 젤리핀 보호하기

다음으로 Lets Encrypt SSL 관리를 설치하려면 Certbot 클라이언트 패키지를 설치해야 합니다. 먼저 다음 명령을 사용하여 Certbot을 설치합니다.

apt-get install python3-certbot-nginx -y

설치가 완료되면 다음 명령을 실행하여 웹사이트에 Lets Encrypt SSL을 설치합니다.

certbot --nginx -d jellyfin.yourdomain.com

유효한 이메일 주소를 제공하고 아래와 같이 서비스 약관에 동의하라는 메시지가 표시됩니다.

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): 

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
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.yourdomain.com
Waiting for verification...
Cleaning up challenges
Deploying Certificate to VirtualHost /etc/nginx/sites-enabled/jellyfin.conf

다음으로, 아래와 같이 HTTP 트래픽을 HTTPS로 리디렉션할지 여부를 선택합니다.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
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

2를 입력하고 Enter 키를 눌러 설치를 마칩니다. 다음 출력이 표시되어야 합니다.

Redirecting all traffic on port 80 to ssl in /etc/nginx/sites-enabled/jellyfin.conf

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

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

IMPORTANT NOTES:
 - Congratulations! Your certificate and chain have been saved at:
   /etc/letsencrypt/live/jellyfin.yourdomain.com/fullchain.pem
   Your key file has been saved at:
   /etc/letsencrypt/live/jellyfin.yourdomain.com/privkey.pem
   Your cert will expire on 2020-10-30. 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.

이제 웹사이트는 Lets Encrypt SSL로 보호됩니다. URL https://jellyfin.yourdomain.com을 사용하여 안전하게 액세스할 수 있습니다.

결론

축하합니다! Nginx와 함께 Jellyfin을 성공적으로 설치하고 구성했으며 Ubuntu 20.04 서버에서 SSL을 암호화합니다. 이제 미디어를 스트리밍하고 웹 브라우저에서 또는 Jellyfin 애플리케이션을 사용하여 액세스할 수 있습니다. 궁금한 점이 있으면 언제든지 문의해 주세요.