Use static ip addresses for containers and centralize the proxy components in a single file.

I had to use static ip addresses here due to a very anoying NGINX
behavior which is: `nginx: [emerg] host not found in upstream
"companion:8081" in /etc/nginx/nginx.conf:17`

NIGNX will NOT start if it can't find the container IP address from the
Docker DNS resolver 127.0.0.11 which is pretty fucking anoying. Thanks
nginx dev for that stupid design.
This commit is contained in:
Fijxu 2025-03-13 19:40:36 -03:00
parent cf1253d3ff
commit 9940e4c01e
Signed by: Fijxu
GPG key ID: 32C1DDF333EDA6A4
5 changed files with 104 additions and 76 deletions

View file

@ -1,3 +1,6 @@
include:
- ./proxy-components.yml
x-common-elements: &common-elements
restart: always
env_file:
@ -22,51 +25,37 @@ services:
- "${REVERSEPROXY_METRICS_PORT}:10000/tcp"
http3-ytproxy:
image: git.nadeko.net/fijxu/http3-ytproxy:latest
<<: *common-elements
network_mode: "service:gluetun"
volumes:
- videoplayback_proxy:/tmp
depends_on:
gluetun:
condition: service_healthy
webserver:
condition: service_started
labels:
- "com.centurylinklabs.watchtower.enable=true"
extends:
file: ./proxy-components.yml
service: http3-ytproxy
companion:
image: git.nadeko.net/fijxu/invidious-companion:latest
user: 2000:2000
<<: *common-elements
volumes:
- ./cache:/var/tmp/youtubei.js:rw
- ./proxies.txt:/app/proxies.txt
depends_on:
webserver:
condition: service_started
labels:
- "com.centurylinklabs.watchtower.enable=true"
extends:
file: ./proxy-components.yml
service: companion
gluetun:
image: qmcgaw/gluetun:latest
<<: *common-elements
sysctls:
- net.ipv6.conf.all.disable_ipv6=1
cap_add:
- NET_ADMIN
devices:
- /dev/net/tun:/dev/net/tun
volumes:
- ./gluetun:/gluetun
extends:
file: ./proxy-components.yml
service: gluetun
watchtower:
image: containrrr/watchtower
volumes:
- /var/run/docker.sock:/var/run/docker.sock
environment:
- WATCHTOWER_LABEL_ENABLE=true
- WATCHTOWER_POLL_INTERVAL=60
<<: *common-elements
extends:
file: ./proxy-components.yml
service: watchtower
volumes:
videoplayback_proxy:
videoplayback_proxy:
networks:
proxy-server:
driver: bridge
ipam:
driver: default
config:
- subnet: 172.50.0.0/24
gateway: 172.50.0.1

View file

@ -9,6 +9,9 @@ services:
webserver:
image: git.nadeko.net/fijxu/nginx-ktls:1.27.4
<<: *common-elements
networks:
proxy-server:
ipv4_address: 172.50.0.2
volumes:
- ./nginx.conf:/nginx.conf.template
- ./key.key:/certs/cert.pem.key
@ -20,51 +23,37 @@ services:
- "com.centurylinklabs.watchtower.enable=true"
http3-ytproxy:
image: git.nadeko.net/fijxu/http3-ytproxy:latest
<<: *common-elements
network_mode: "service:gluetun"
volumes:
- videoplayback_proxy:/tmp
depends_on:
gluetun:
condition: service_healthy
webserver:
condition: service_started
labels:
- "com.centurylinklabs.watchtower.enable=true"
extends:
file: ./proxy-components.yml
service: http3-ytproxy
companion:
image: git.nadeko.net/fijxu/invidious-companion:latest
user: 2000:2000
<<: *common-elements
volumes:
- ./cache:/var/tmp/youtubei.js:rw
- ./proxies.txt:/app/proxies.txt
depends_on:
webserver:
condition: service_started
labels:
- "com.centurylinklabs.watchtower.enable=true"
extends:
file: ./proxy-components.yml
service: companion
gluetun:
image: qmcgaw/gluetun:latest
<<: *common-elements
sysctls:
- net.ipv6.conf.all.disable_ipv6=1
cap_add:
- NET_ADMIN
devices:
- /dev/net/tun:/dev/net/tun
volumes:
- ./gluetun:/gluetun
extends:
file: ./proxy-components.yml
service: gluetun
watchtower:
image: containrrr/watchtower
volumes:
- /var/run/docker.sock:/var/run/docker.sock
environment:
- WATCHTOWER_LABEL_ENABLE=true
- WATCHTOWER_POLL_INTERVAL=60
<<: *common-elements
extends:
file: ./proxy-components.yml
service: watchtower
volumes:
videoplayback_proxy:
videoplayback_proxy:
networks:
proxy-server:
driver: bridge
ipam:
driver: default
config:
- subnet: 172.50.0.0/24
gateway: 172.50.0.1

View file

@ -70,4 +70,4 @@ backend http3-ytproxy
server s1 unix@/tmp/http-ytproxy.sock
backend companion
server s1 companion:8081 check resolvers docker init-addr libc,none
server s1 172.50.0.3:8081 check resolvers docker init-addr libc,none

View file

@ -14,7 +14,7 @@ http {
upstream companion {
keepalive 256;
server companion:8081;
server 172.50.0.3:8081;
}
# Docker DNS resolver!

50
proxy-components.yml Normal file
View file

@ -0,0 +1,50 @@
services:
http3-ytproxy:
image: git.nadeko.net/fijxu/http3-ytproxy:latest
network_mode: "service:gluetun"
volumes:
- videoplayback_proxy:/tmp
depends_on:
gluetun:
condition: service_healthy
webserver:
condition: service_started
labels:
- "com.centurylinklabs.watchtower.enable=true"
companion:
image: git.nadeko.net/fijxu/invidious-companion:latest
user: 2000:2000
networks:
proxy-server:
ipv4_address: 172.50.0.3
volumes:
- ./cache:/var/tmp/youtubei.js:rw
- ./proxies.txt:/app/proxies.txt
depends_on:
webserver:
condition: service_started
labels:
- "com.centurylinklabs.watchtower.enable=true"
gluetun:
image: qmcgaw/gluetun:latest
networks:
proxy-server:
ipv4_address: 172.50.0.4
sysctls:
- net.ipv6.conf.all.disable_ipv6=1
cap_add:
- NET_ADMIN
devices:
- /dev/net/tun:/dev/net/tun
volumes:
- ./gluetun:/gluetun
watchtower:
image: containrrr/watchtower
volumes:
- /var/run/docker.sock:/var/run/docker.sock
environment:
- WATCHTOWER_LABEL_ENABLE=true
- WATCHTOWER_POLL_INTERVAL=60