Use deploy.replicas and variable in proxy_pass in improve-public-instance.md (#469)

`Scale` can be replaced with `deploy.replicas` within the compose file.

https://github.com/docker/compose/issues/5586#issuecomment-972130556

Using a variable in proxy_pass forces re-resolution of the DNS names. (In my tests, this helps solving some network quirks)

https://forum.nginx.org/read.php?2,215830,215832#msg-215832
This commit is contained in:
extremelyonline 2023-11-19 22:38:47 +08:00 committed by GitHub
parent 0a04bdece9
commit e47c15a2b2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -42,12 +42,16 @@ We assume that you have not changed the port `3000` from the default installatio
``` ```
This is required so that only one invidious process refresh the subscriptions for the users. This is required so that only one invidious process refresh the subscriptions for the users.
Running this process with multiple processes may introduce some conflicts. Running this process with multiple processes may introduce some conflicts.
4. Create a new bash script that you will now use to start Invidious, name it `start.sh`: 4. Edit the docker-compose.yml with this content:
``` ```
#!/bin/sh version: "3"
docker compose up -d --scale invidious=6 services:
invidious:
image: quay.io/invidious/invidious:latest
deploy:
replicas: 6
``` ```
Explanation: The `--scale` parameter allows running multiple containers of the same Docker image. Explanation: The `deploy.replicas` parameter allows running multiple containers of the same Docker image.
Note: You can set more or less Invidious processes (6 in the example). Note: You can set more or less Invidious processes (6 in the example).
**Don't restart Invidious yet!** **Don't restart Invidious yet!**
5. Create a file called `nginx.conf` and add this content: 5. Create a file called `nginx.conf` and add this content:
@ -62,7 +66,9 @@ We assume that you have not changed the port `3000` from the default installatio
listen [::]:3000; listen [::]:3000;
access_log off; access_log off;
location / { location / {
proxy_pass http://invidious:3000; resolver 127.0.0.11;
set $backend "invidious";
proxy_pass http://$backend:3000;
proxy_http_version 1.1; # to keep alive proxy_http_version 1.1; # to keep alive
proxy_set_header Connection ""; # to keep alive proxy_set_header Connection ""; # to keep alive
} }
@ -96,8 +102,7 @@ We assume that you have not changed the port `3000` from the default installatio
8. Apply the new configuration: 8. Apply the new configuration:
``` ```
docker compose down docker compose down
chmod +x ./start.sh docker compose up
./start.sh
``` ```
??? note "Click here for a final example of the `docker-compose` file. (Don't copy blindly)" ??? note "Click here for a final example of the `docker-compose` file. (Don't copy blindly)"
@ -107,6 +112,8 @@ We assume that you have not changed the port `3000` from the default installatio
services: services:
invidious: invidious:
image: quay.io/invidious/invidious:latest image: quay.io/invidious/invidious:latest
deploy:
replicas: 6
restart: unless-stopped restart: unless-stopped
environment: environment:
INVIDIOUS_CONFIG: | INVIDIOUS_CONFIG: |
@ -254,7 +261,7 @@ But if you do not have NGINX as **your main reverse proxy** you can either try t
volumes: volumes:
- /opt/http3-ytproxy:/opt/http3-ytproxy - /opt/http3-ytproxy:/opt/http3-ytproxy
``` ```
5. Reload the docker composition: `./start.sh` (if you followed the [second section](#2-multiple-invidious-processes)) 5. Reload the docker compose. (if you followed the [second section](#2-multiple-invidious-processes))
6. Reload NGINX: `systemctl reload nginx`. 6. Reload NGINX: `systemctl reload nginx`.
??? note "Click here for a final example of the `docker-compose` file. (Don't copy blindly)" ??? note "Click here for a final example of the `docker-compose` file. (Don't copy blindly)"
@ -264,6 +271,8 @@ But if you do not have NGINX as **your main reverse proxy** you can either try t
services: services:
invidious: invidious:
image: quay.io/invidious/invidious:latest image: quay.io/invidious/invidious:latest
deploy:
replicas: 6
restart: unless-stopped restart: unless-stopped
environment: environment:
INVIDIOUS_CONFIG: | INVIDIOUS_CONFIG: |