### Start Temporary PostgreSQL Container for Invidious Database Initialization Source: https://docs.invidious.io/companion-installation/community-installation-guide Launches a temporary PostgreSQL container to facilitate initial database setup and migration for Invidious. It maps the previously created volume and sets up necessary environment variables. ```bash podman run --rm -it --name invidious-init -v invidious-db:/var/lib/postgresql/data:Z -p 5432:5432 -e POSTGRES_DB=invidious -e POSTGRES_USER=kemal -e POSTGRES_PASSWORD=kemal docker.io/library/postgres:14 ``` -------------------------------- ### Build and Configure Invidious Application Source: https://docs.invidious.io/companion-installation/community-installation-guide Compiles the Invidious application using `make` and then sets up the configuration file by copying the example and instructing the user to edit it, specifically to include the previously generated `po_token` and `visitor_data`. ```Shell make # Configure config/config.yml as you like cp config/config.example.yml config/config.yml # edit config.yaml to include po_token and visitor_data previously generated edit config/config.yaml ``` -------------------------------- ### Start Invidious Application Pod via Systemd Source: https://docs.invidious.io/companion-installation/community-installation-guide Initiates the entire Invidious application pod, including all its associated containers, using the systemd user service. ```bash systemctl --user start invidious-pod ``` -------------------------------- ### Start Podman Pod via Systemd Source: https://docs.invidious.io/companion-installation/community-installation-guide Reloads the systemd daemon and enables/starts the 'pod-videos.service' user service, which manages the entire 'videos' Podman pod and its containers. ```bash systemctl --user daemon-reload systemctl --user enable --now pod-videos.service ``` -------------------------------- ### Create Podman Systemd Container Unit for Invidious Application Source: https://docs.invidious.io/companion-installation/community-installation-guide Defines the main Invidious application container as a systemd unit, linking it to the environment file and ensuring it starts after the database service. ```bash cat > ~/.config/containers/systemd/invidious.container < git clone https://github.com/iv-org/invidious.git ``` -------------------------------- ### Docker Compose Development Setup Commands Source: https://docs.invidious.io/companion-installation/companion-installation Provides commands for a simplified Docker Compose setup for development, which clones the Invidious repository and starts the services, building images from source. This method is suitable for local development and testing. ```bash git clone https://github.com/iv-org/invidious.git cd invidious docker-compose up ``` -------------------------------- ### Create Podman Container for Invidious Source: https://docs.invidious.io/companion-installation/community-installation-guide Creates a Podman container for the Invidious application, linking it to the 'videos' pod. It sets up health checks and mounts the Invidious configuration file. ```bash podman create --rm \ --pod videos \ --name invidious \ --label "io.containers.autoupdate=registry" \ --health-cmd="wget -nv --tries=1 --spider http://127.0.0.1:3000/api/v1/trending || exit 1" \ --health-interval=30s \ --health-timeout=5s \ --health-retries=2 \ -v /config.yml:/invidious/config/config.yml:z,U \ quay.io/invidious/invidious:latest ``` -------------------------------- ### Build and Configure Invidious Application Source: https://docs.invidious.io/companion-installation/installation Switches to the Invidious user, navigates to the application directory, compiles the source code, copies the example configuration file, and prompts for manual editing to include `po_token` and `visitor_data` before running database migrations. ```bash su - invidious cd invidious make # Configure config/config.yml as you like cp config/config.example.yml config/config.yml # edit config.yaml to include po_token and visitor_data previously generated edit config/config.yaml # Deploy the database ./invidious --migrate exit ``` -------------------------------- ### Install Invidious System Dependencies Source: https://docs.invidious.io/companion-installation/community-installation-guide Installs required system libraries and tools for Invidious using Homebrew, including Crystal, PostgreSQL, ImageMagick, and librsvg. ```Shell brew update brew install crystal postgresql imagemagick librsvg ``` -------------------------------- ### Clone Invidious Repository for Production Setup Source: https://docs.invidious.io/companion-installation/installation These commands clone the Invidious source code repository from GitHub and navigate into the newly created `invidious` directory. This step is necessary for the production Docker Compose setup to access the `init-invidious-db.sh` file and the `config/sql` directory for mounting to the PostgreSQL container. ```bash git clone https://github.com/iv-org/invidious.git cd invidious ``` -------------------------------- ### Create Podman Systemd Container Unit for Invidious Signature Helper Source: https://docs.invidious.io/companion-installation/community-installation-guide Sets up a systemd unit file for the Invidious signature helper container, which is essential for handling YouTube signatures. ```bash cat > ~/.config/containers/systemd/invidious-sig-helper.container < ~/.config/containers/systemd/invidious-db.volume < ~/.config/containers/systemd/invidious.pod </invidious/config/sql:/config/sql:z \ -v /invidious/docker/init-invidious-db.sh:/docker-entrypoint-initdb.d/init-invidious-db.sh:z \ -e POSTGRES_DB=invidious \ -e POSTGRES_USER=kemal \ -e POSTGRES_PASSWORD=kemal \ docker.io/library/postgres:14 ``` -------------------------------- ### Launch Invidious Application Source: https://docs.invidious.io/companion-installation/companion-installation This command is used to start the Invidious application from its executable. It assumes the user is in the Invidious project directory. ```Shell ./invidious ``` -------------------------------- ### Deploy and Enable Invidious Systemd Service Source: https://docs.invidious.io/companion-installation/installation Copies the provided `invidious.service` file to the systemd directory, then enables and immediately starts the Invidious service to ensure it runs automatically on boot and in the background. ```bash cp /home/invidious/invidious/invidious.service /etc/systemd/system/invidious.service systemctl enable --now invidious.service ``` -------------------------------- ### Restart Podman Pod via Systemd Source: https://docs.invidious.io/companion-installation/community-installation-guide Restarts the 'pod-videos.service' user service, which controls the 'videos' Podman pod, allowing for service updates or reinitialization. ```bash systemctl --user restart pod-videos.service ``` -------------------------------- ### Create Podman Pod for Videos Source: https://docs.invidious.io/companion-installation/community-installation-guide Creates a new Podman pod named 'videos' and maps port 3000 from the host to port 3000 within the pod. This pod will host the Invidious and PostgreSQL containers. ```bash podman pod create --name videos -p 3000:3000 ``` -------------------------------- ### Create Invidious Environment Configuration File Source: https://docs.invidious.io/companion-installation/community-installation-guide Generates a systemd environment file (.env) for Invidious, containing database connection details, signature server address, and generated secrets. ```bash cat > ~/.config/containers/systemd/invidious.env < ~/.config/containers/systemd/invidious-db.container <`) && (Path(`/latest_version`) || PathPrefix(`/api/manifest/dash/id/`) || PathPrefix(`/videoplayback*`))" - "traefik.http.routers.invidious-companion.entrypoints=web-sec" - "traefik.http.routers.invidious-companion.tls.certresolver=le" - "traefik.http.services.invidious-companion.loadbalancer.server.port=8282" ... ``` -------------------------------- ### Install and Monitor Bandwidth with vnStat Source: https://docs.invidious.io/companion-installation/hide-instance-behind-proxy-server Instructions to install and use vnStat, a network traffic monitor, to track incoming (rx) and outgoing (tx) bandwidth consumption on a server. This is useful for assessing the bandwidth usage of your proxy server. ```Shell apt install vnstat ``` ```Shell systemctl enable --now vnstat ``` ```Shell vnstat ``` -------------------------------- ### Test HAProxy Setup with Curl Source: https://docs.invidious.io/companion-installation/hide-instance-behind-proxy-server This curl command allows testing the HAProxy setup by resolving a domain to the proxy server's IP address and making an HTTPS request. It helps verify if the proxy is correctly forwarding traffic. ```bash curl https://yourdomain.com/ --resolve yourdomain.com:443:PUBLIC_IPV4_ADDRESS_OF_PROXY_SERVER ``` -------------------------------- ### Configure Traefik Labels for Invidious Service Source: https://docs.invidious.io/companion-installation/companion-traefik This snippet shows the Traefik labels required for the Invidious container within a Docker Compose setup. It enables Traefik, defines a host rule based on the server name, specifies 'web-sec' as the entrypoint, enables TLS with a 'le' certificate resolver, and sets the service port to 3000. The rule explicitly excludes paths that are handled by the companion service. ```YAML ... labels: - "traefik.enable=true" - "traefik.http.routers.invidious.rule=Host(``) && !(Path(`/latest_version`) || PathPrefix(`/api/manifest/dash/id/`) || PathPrefix(`/videoplayback*`))" - "traefik.http.routers.invidious.entrypoints=web-sec" - "traefik.http.routers.invidious.tls.certresolver=le" - "traefik.http.services.invidious.loadbalancer.server.port=3000" ... ``` -------------------------------- ### Create Invidious User and Clone Repository Source: https://docs.invidious.io/companion-installation/installation Creates a dedicated system user named 'invidious' with a home directory, then switches to this user to clone the official Invidious source code repository from GitHub. ```bash useradd -m invidious su - invidious git clone https://github.com/iv-org/invidious exit ``` -------------------------------- ### Invidious Server Log Example Source: https://docs.invidious.io/companion-installation/faq This snippet illustrates the format of server logs generated by an Invidious instance, detailing HTTP requests, status codes, and response times for various endpoints like video watches, API searches, and image fetches. ```plaintext 2021-08-30 18:15:44 UTC [info] 200 GET /watch?v=GIAKHj9uJtM 781.21ms 2021-08-30 18:15:49 UTC [info] 200 GET /api/v1/search?q=Fly%20away 500.0ms 2021-08-30 18:15:49 UTC [info] 200 GET /vi/lJcqAzWFWLs/mqdefault.jpg 15.82ms 2021-08-30 18:15:49 UTC [info] 200 GET /vi/JoP_Tte7z7o/mqdefault.jpg 70.64ms ``` -------------------------------- ### Invidious Reverse Proxy Configuration Parameters Source: https://docs.invidious.io/companion-installation/installation Essential configuration parameters for Invidious when served behind a reverse proxy. These settings ensure proper handling of HTTPS, domain names, external ports, and enable features like faster video notifications and unblocking captions for public instances. ```YAML https_only: true domain: domain.ext external_port: 443 use_pubsub_feeds: true use_innertube_for_captions: true ``` -------------------------------- ### Create Invidious User and Clone Repository Source: https://docs.invidious.io/companion-installation/companion-installation Creates a dedicated system user named 'invidious' with a home directory, switches to this user, and then clones the Invidious GitHub repository into their home directory. ```bash useradd -m invidious su - invidious git clone https://github.com/iv-org/invidious exit ``` -------------------------------- ### Caddy Reverse Proxy Configuration for Invidious Companion Source: https://docs.invidious.io/companion-installation/companion-caddy This Caddyfile configuration sets up a reverse proxy for an Invidious instance, including specific routing for the Invidious companion service. It assumes Caddy handles SSL certificate management and disables logging by default. Users must replace `` with their actual domain. ```Caddyfile https:// { @companion { path /latest_version path /api/manifest/dash/id/* path /videoplayback* } reverse_proxy @companion localhost:8282 reverse_proxy localhost:3000 log { output discard } } ``` -------------------------------- ### Generate YouTube Identity Tokens for Invidious Source: https://docs.invidious.io/companion-installation/installation This command generates `po_token` and `visitor_data` identities required for Invidious to pass YouTube's verification checks. It must be run on the same public IP address that is blocked by YouTube to ensure the generated tokens are valid for bypassing checks on blocked IPs. The generated tokens need to be copied for subsequent configuration in the `docker-compose.yml` file. ```bash docker run quay.io/invidious/youtube-trusted-session-generator ```