GNU/Linux >> Linux の 問題 >  >> Ubuntu

Ubuntu20.04にNginxを使用してJellyfinMediaServerをインストールする方法

Jellyfinは、独自のメディアサーバーをホストできる無料のオープンソースメディアストリーミングソリューションです。 Linux、Windows、macOSにインストールできます。映画、テレビ番組、音楽、写真などのメディアを管理し、Jellyfinを使用して複数のデバイス間で共有できます。また、Android、Android TV、およびAmazonFireTV用のアプリケーションも提供します。 DLNAのサポート、再生制限なし、TheTVDB、TheMovieDB、Rotten Tomatoesからのメタデータの自動取得、自動記録、ハードウェアアクセラレーションのサポートなど、いくつかの機能を提供します。

このチュートリアルでは、Ubuntu20.04にJellyfinを使用してメディアサーバーをインストールおよびセットアップする方法について説明します。

前提条件
  • Ubuntu20.04を実行しているサーバー。
  • サーバーIPで指定された有効なドメイン名。
  • ルートパスワードがサーバーに設定されます。
はじめに

開始する前に、次のコマンドを使用してシステムパッケージを更新します。

apt-get update -y

すべてのパッケージが更新されたら、次のコマンドを使用して他の必要な依存関係をインストールします。

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

すべての依存関係をインストールしたら、次の手順に進むことができます。

Jellyfinをインストール

デフォルトでは、JellyfinパッケージはUbuntu20.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

Jellyfinをインストールした後、次のコマンドを使用してJellyfinサービスのステータスを確認できます。

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 ubuntu2004 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 ubuntu2004 jellyfin[8454]: [06:15:48] [INF] Executed all pre-startup entry points in 0:00:00.6715621
Dec 27 06:15:48 ubuntu2004 jellyfin[8454]: [06:15:48] [INF] Core startup complete
Dec 27 06:15:48 ubuntu2004 jellyfin[8454]: [06:15:48] [INF] Executed all post-startup entry points in 0:00:00.3885698
Dec 27 06:15:48 ubuntu2004 jellyfin[8454]: [06:15:48] [INF] Startup complete 0:00:08.0109863
Dec 27 06:15:50 ubuntu2004 jellyfin[8454]: [06:15:50] [INF] StartupTrigger fired for task: Update Plugins
Dec 27 06:15:50 ubuntu2004 jellyfin[8454]: [06:15:50] [INF] Queueing task PluginUpdateTask
Dec 27 06:15:50 ubuntu2004 jellyfin[8454]: [06:15:50] [INF] Executing Update Plugins
Dec 27 06:15:50 ubuntu2004 jellyfin[8454]: [06:15:50] [INF] Update Plugins Completed after 0 minute(s) and 0 seconds
Dec 27 06:15:51 ubuntu2004 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のリバースプロキシとして構成することをお勧めします。これを行うには、まず、次のコマンドを使用してNginxWebサーバーをインストールします。

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 ubuntu2004 systemd[1]: Starting A high performance web server and a reverse proxy server...
Dec 27 06:18:13 ubuntu2004 systemd[1]: Started A high performance web server and a reverse proxy server.

この時点で、Nginxがインストールされ、Jellyfinにサービスを提供するように構成されています。これで、次のステップに進むことができます。

JellyfinWebUIにアクセス

次に、Webブラウザーを開き、URL http://jellyfin.yourdomain.comを使用してJellyfinWebUIにアクセスします。 。次の画面にリダイレクトされます:

言語を選択して、次へをクリックします ボタン。次の画面が表示されます。

管理者のユーザー名とパスワードを入力し、次へをクリックします ボタン。次の画面が表示されます。

次へをクリックします ボタン。次の画面が表示されます。

メタデータの言語と国を選択し、次へをクリックします ボタン。次の画面が表示されます。

目的のオプションを選択し、次へをクリックします ボタン。次の画面が表示されます。

完了をクリックします ボタン。 Jellyfinログインページが表示されます:

ユーザー名とパスワードを入力し、サインインをクリックします ボタン。次の画面にJellyfinダッシュボードが表示されます。

これで、メディアをライブラリに追加して、インターネット経由でアクセスできます。

Let'sEncryptを使用してJellyfinを保護する

次に、Certbotクライアントパッケージをインストールして、Let'sEncryptSSLの管理をインストールする必要があります。まず、次のコマンドを使用してCertbotをインストールします。

apt-get install python3-certbot-nginx -y

インストールが完了したら、次のコマンドを実行してLet'sEncryptSSLをWebサイトにインストールします。

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

これで、WebサイトはLet'sEncryptSSLで保護されます。 URLhttps://jellyfin.yourdomain.com。を使用して安全にアクセスできます

結論

おめでとう!これで、Ubuntu20.04サーバーにNginxとLet'sEncryptSSLを使用してJellyfinが正常にインストールおよび構成されました。これで、メディアをストリーミングして、WebブラウザーまたはJellyfinアプリケーションを使用してメディアにアクセスできます。ご不明な点がございましたら、お気軽にお問い合わせください。


Ubuntu
  1. Ubuntu20.04にPlexMediaServerをインストールする方法

  2. Ubuntu16.04にNginxを使用してHTTPGitサーバーをインストールする方法

  3. Ubuntu20.04にNginxを使用してHTTPGitサーバーをインストールする方法

  1. Ubuntu18.04にPlexMediaServerをインストールする方法

  2. Ubuntu20.04にNginxをインストールする方法

  3. Ubuntu16.04にNginxでMediaWikiをインストールする方法

  1. Ubuntu15.10にNginxを使用してMagentoをインストールする方法

  2. Ubuntu15.10にNginxでMailpileをインストールする方法

  3. Ubuntu15.10でNginxを使用してRedmine3をインストールする方法