InvidiousインスタンスをPodman上に建てる

概要

Invidious というYoutubeのフロントエンドをRHEL 9.3で動かしてみたメモです。
RHELにはDockerの代わりにPodmanが採用されているのでPodman上でコンテナを走らせてみます。


目次


環境

以下のコマンド実行結果を参照

1
2
3
4
5
6
7
8
9
10
$ cat /etc/redhat-release
Red Hat Enterprise Linux release 9.3 (Plow)
$ podman -v
podman version 4.6.1
$ whoami
invidious
$ pwd
/home/invidious
$ ls
invidious invidious_podman.yml postgres

Invidiousのリポジトリをクローン

はじめにInvidiousのリポジトリを適当なディレクトリにクローンします。
この記事では/home/invidious/ディレクトリにクローンします。

1
$ git clone https://github.com/iv-org/invidious.git

postgresqlのデータ保存先の作成

この記事では/home/invidious/postgresとします。
まずはフォルダを作ります

1
2
3
$ pwd 
/home/invidious/
$ mkdir postgres

権限とSELinuxコンテキストをつけてコンテナから参照できるようにします。

1
2
3
$ sudo semanage fcontext -a -t container_file_t "/home/invidious/postgres(/.*)?"
$ chmod 777 "/home/invidious/postgres"
$ sudo restorecon -FR /home/invidious/

KubernetesのPod構成ファイルを作成

このymlファイルを保存して編集する。
編集箇所は以下の通り

  1. 11行目 - postgresqlのデータ保存先ディレクトリを指定
  2. 15行目、19行目 - /home/invidious/invidious を自分がリポジトリをクローンしたパスに書き換え
  3. 40行目 - HMACキーを乱数に変更

40行目の乱数については以下のコマンドで質の良い乱数を得られます
※この記事からコピペせず自分の環境で実行した物をコピペしてください

1
2
$ head /dev/urandom | sha256sum
9785539ca38e85d41af29064802e93c541549f8e1a93fd6adedb45fed244602d -

実行

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
$ sudo podman kube play invidious_podman.yml

Trying to pull quay.io/invidious/invidious:latest...
Getting image source signatures
Copying blob 82fa84ecc937 done
Copying blob 5663860407a6 done
Copying blob 4deca27c4269 done
Copying blob 88aba340a58e done
Copying blob 619be1103602 skipped: already exists
Copying blob f5799a41fb4b done
Copying blob 028fa9dd7876 done
Copying blob f16baffbff6d done
Copying blob 64b04972d66a done
Copying blob 398066e4a327 done
Copying blob fe91b20bd915 done
Copying blob 4f4fb700ef54 skipped: already exists
Copying config f59a293603 done
Writing manifest to image destination
Trying to pull docker.io/library/postgres:14...
Getting image source signatures
Copying blob c8b33fe17167 skipped: already exists
Copying blob aaed90dbec0c skipped: already exists
Copying blob e1caac4eb9d2 skipped: already exists
Copying blob 9a16433c9ffb skipped: already exists
Copying blob ab2fbdc548a0 skipped: already exists
Copying blob d5dfacd95d04 skipped: already exists
Copying blob 5c2653ccff30 skipped: already exists
Copying blob 8e5372f9ff7e skipped: already exists
Copying blob 927d619c5510 skipped: already exists
Copying blob 116545f99854 skipped: already exists
Copying blob 9762cab69057 skipped: already exists
Copying blob 79f98701f9d8 skipped: already exists
Copying blob e837237b2223 skipped: already exists
Copying blob ebb0ebcc01bc skipped: already exists
Copying config 28948ca129 done
Writing manifest to image destination
Pod:
21082c4f513294020c6ed2cb47458292ce55b208b649eeb3b1b5f54052037370
Containers:
27b3f08f0ceac85cfb69c907269c2e68a5e0c2b5e63f38565113bb119abd09bd
a862da1477a23fb08fcb6b5fe23c55fb3c16f0e6fb4a0b6ee1119e4152e62942

動作確認

最初は立ち上がってくるまでに数分がかかる
数分後にcurlコマンドでコンテナが動いているか確認

1
2
3
4
5
6
7
8
9
10
11
12
$ curl -I localhost:3000

HTTP/1.1 200 OK
Connection: keep-alive
Content-Type: text/html
X-Frame-Options: sameorigin
X-XSS-Protection: 1; mode=block
X-Content-Type-Options: nosniff
Content-Security-Policy: default-src 'none'; script-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' data:; font-src 'self' data:; connect-src 'self'; manifest-src 'self'; media-src 'self' blob: https://*.googlevideo.com:443 https://*.youtube.com:443; child-src 'self' blob:; frame-src 'self'; frame-ancestors 'none'
Referrer-Policy: same-origin
Permissions-Policy: interest-cohort=()
Content-Length: 0

公開

ファイアウォール設定を変更し、3000番が通るようにする。

1
2
$ sudo firewall-cmd --permanent --add-port=3000/tcp
$ sudo firewall--cmd --reload

3000番以外のポートを使用した場合は、ymlファイルの28行目を編集する。

うちの環境ではnginxをSSLアクセラレータにして、以下のような設定で動かしている

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
server{
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name <ドメイン名>;

# ssl on;
ssl_certificate <証明書>;
ssl_certificate_key <秘密鍵>;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_session_cache shared:SSL:10m;
ssl_session_timeout 10m;

location / {
proxy_pass http://<Invidiousを立てたサーバ>:3000;
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-Port $remote_port;
port_in_redirect off;
add_header Front-End-Https on;
add_header 'Strict-Transport-Security' 'max-age=15552000;';
}
Author

fuchse-ohren

Posted on

2024-03-10

Updated on

2026-03-11

Licensed under

コメント