chore: add captions endpoint + rework nginx config

This commit is contained in:
Émilien (perso) 2025-09-02 14:21:03 +00:00
parent baf62898f3
commit eafb7fe65f
4 changed files with 30 additions and 42 deletions

View file

@ -66,6 +66,8 @@ To make the VirtualHost config below actually work, you should as well:
ProxyPassReverse /latest_version http://127.0.0.1:8282/ ProxyPassReverse /latest_version http://127.0.0.1:8282/
ProxyPass /api/manifest/dash/id/ http://127.0.0.1:8282/ nocanon ProxyPass /api/manifest/dash/id/ http://127.0.0.1:8282/ nocanon
ProxyPassReverse /api/manifest/dash/id/ http://127.0.0.1:8282/ ProxyPassReverse /api/manifest/dash/id/ http://127.0.0.1:8282/
ProxyPass /api/v1/captions/ http://127.0.0.1:8282/ nocanon
ProxyPassReverse /api/v1/captions/ http://127.0.0.1:8282/
ProxyPass /videoplayback http://127.0.0.1:8282/ nocanon ProxyPass /videoplayback http://127.0.0.1:8282/ nocanon
ProxyPassReverse /videoplayback http://127.0.0.1:8282/ ProxyPassReverse /videoplayback http://127.0.0.1:8282/
ProxyPreserveHost On ProxyPreserveHost On

View file

@ -10,6 +10,7 @@ https://<server_name> {
path /latest_version path /latest_version
path /api/manifest/dash/id/* path /api/manifest/dash/id/*
path /videoplayback* path /videoplayback*
/api/v1/captions/*
} }
reverse_proxy @companion localhost:8282 reverse_proxy @companion localhost:8282

View file

@ -6,9 +6,8 @@ This is a very basic config, secured with Let's Encrypt. Any log is disabled by
server { server {
listen 80; listen 80;
listen [::]:80; listen [::]:80;
listen 443 ssl; listen 443 ssl http2;
listen [::]:443 ssl; listen [::]:443 ssl http2;
http2 on;
server_name invidious.domain.tld; server_name invidious.domain.tld;
@ -18,38 +17,24 @@ server {
ssl_certificate /etc/letsencrypt/live/invidious.domain.tld/fullchain.pem; ssl_certificate /etc/letsencrypt/live/invidious.domain.tld/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/invidious.domain.tld/privkey.pem; ssl_certificate_key /etc/letsencrypt/live/invidious.domain.tld/privkey.pem;
# Redirect all HTTP requests to HTTPS
if ($scheme = http) {
return 301 https://$host$request_uri;
}
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $host;
proxy_http_version 1.1;
proxy_set_header Connection "";
# Invidious main service
location / { location / {
proxy_pass http://127.0.0.1:3000; proxy_pass http://127.0.0.1:3000;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $host; # so Invidious knows domain
proxy_http_version 1.1; # to keep alive
proxy_set_header Connection ""; # to keep alive
} }
location /latest_version { # Invidious companion service (multiple paths, same backend)
location ~ ^/(latest_version|videoplayback|api/(v1/captions|manifest/dash/id))/ {
proxy_pass http://127.0.0.1:8282; proxy_pass http://127.0.0.1:8282;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $host; # so Invidious companion knows domain
proxy_http_version 1.1; # to keep alive
proxy_set_header Connection ""; # to keep alive
} }
location /api/manifest/dash/id/ {
proxy_pass http://127.0.0.1:8282;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $host; # so Invidious companion knows domain
proxy_http_version 1.1; # to keep alive
proxy_set_header Connection ""; # to keep alive
}
location /videoplayback {
proxy_pass http://127.0.0.1:8282;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $host; # so Invidious companion knows domain
proxy_http_version 1.1; # to keep alive
proxy_set_header Connection ""; # to keep alive
}
if ($https = '') { return 301 https://$host$request_uri; } # if not connected to HTTPS, perma-redirect to HTTPS
} }
``` ```

View file

@ -8,7 +8,7 @@ Do not forget to replace `<server_name>` with your domain.
... ...
labels: labels:
- "traefik.enable=true" - "traefik.enable=true"
- "traefik.http.routers.invidious.rule=Host(`<server_name>`) && !(Path(`/latest_version`) || PathPrefix(`/api/manifest/dash/id/`) || PathPrefix(`/videoplayback`))" - "traefik.http.routers.invidious.rule=Host(`<server_name>`) && !(Path(`/latest_version`) || PathPrefix(`/api/manifest/dash/id/`) || PathPrefix(`/api/v1/captions/`) || PathPrefix(`/videoplayback`))"
- "traefik.http.routers.invidious.entrypoints=web-sec" - "traefik.http.routers.invidious.entrypoints=web-sec"
- "traefik.http.routers.invidious.tls.certresolver=le" - "traefik.http.routers.invidious.tls.certresolver=le"
- "traefik.http.services.invidious.loadbalancer.server.port=3000" - "traefik.http.services.invidious.loadbalancer.server.port=3000"
@ -19,7 +19,7 @@ Do not forget to replace `<server_name>` with your domain.
... ...
labels: labels:
- "traefik.enable=true" - "traefik.enable=true"
- "traefik.http.routers.invidious-companion.rule=Host(`<server_name>`) && (Path(`/latest_version`) || PathPrefix(`/api/manifest/dash/id/`) || PathPrefix(`/videoplayback`))" - "traefik.http.routers.invidious-companion.rule=Host(`<server_name>`) && (Path(`/latest_version`) || PathPrefix(`/api/manifest/dash/id/`) || PathPrefix(`/api/v1/captions/`) || PathPrefix(`/videoplayback`))"
- "traefik.http.routers.invidious-companion.entrypoints=web-sec" - "traefik.http.routers.invidious-companion.entrypoints=web-sec"
- "traefik.http.routers.invidious-companion.tls.certresolver=le" - "traefik.http.routers.invidious-companion.tls.certresolver=le"
- "traefik.http.services.invidious-companion.loadbalancer.server.port=8282" - "traefik.http.services.invidious-companion.loadbalancer.server.port=8282"