docker-compose-configs/invidious/invidious-all/haproxy.cfg
root 0b420bbbbf invidious: better configuration with example and explanation
watchtower: use trusted-fast label for trusted images (generally my own images)
2025-04-07 16:52:42 -04:00

57 lines
1.8 KiB
INI

# Notes:
# Why I deleted `balance roundrobin`:
#
# https://www.haproxy.com/documentation/haproxy-configuration-manual/latest/#4-balance:
# The load balancing algorithm of a backend is set to roundrobin when no other
# algorithm, mode nor option have been set. The algorithm may only be set once
# for each backend.
#
# ---
# Why I removed `option http-keep-alive`: This is on by default
global
# This because haproxy is dumb and likes to use the maxconnection (somaxconn) from the kernel and that is super mega huge making haproxy oom
maxconn 8192
resolvers docker
# To be able to use multiple replicas of invidious
# using domains
nameserver dns1 127.0.0.11:53
defaults
mode http
# https://www.haproxy.com/documentation/haproxy-configuration-tutorials/service-reliability/retries/
# Use another server if one takes too long to reply
retries 4
option redispatch
timeout client 10s
timeout connect 5s
# The default timeout of http request on invidious is 10 seconds.
# If this is less than 10 seconds, the reverse proxy may return
# "503 service unavailable", not letting invidious respond to
# the client.
timeout server 30s
timeout queue 20s
# https://www.haproxy.com/documentation/haproxy-configuration-manual/latest/#4.2-http-reuse
http-reuse safe
# Prometheus for graphs
frontend prometheus
bind *:8404
mode http
http-request use-service prometheus-exporter if { path /metrics }
no log
frontend invidious
bind *:8001
# Use anubis only for /watch path
use_backend anubis-inv if { path /watch } || { path_beg /.within.website }
default_backend invidious
backend anubis-inv
server srv1 anubis-inv:4000 check resolvers docker init-addr libc,none
backend invidious
server-template srv 4 invidious:3000 check resolvers docker init-addr libc,none