Files
2025-12-21 13:57:08 +01:00

268 lines
9.0 KiB
INI

global
log /dev/log local0 info
#log /dev/log local1 info
chroot /var/lib/haproxy
stats socket /run/haproxy/admin.sock mode 660 level admin
stats timeout 30s
user haproxy
group haproxy
maxconn 12000
daemon
defaults
log global
mode http
option httplog
option dontlognull
errorfile 400 /etc/haproxy/errors/400.http
errorfile 403 /etc/haproxy/errors/403.http
errorfile 408 /etc/haproxy/errors/408.http
errorfile 500 /etc/haproxy/errors/500.http
errorfile 502 /etc/haproxy/errors/502.http
errorfile 503 /etc/haproxy/errors/503.http
errorfile 504 /etc/haproxy/errors/504.http
timeout connect 5s
timeout check 5s
timeout client 6s
timeout server 6s
timeout http-request 6s
peers bwlim-peers
peer master.nerdvpn.de 127.0.0.1:8110
table rate-out type ip size 1m expire 15m store bytes_out_rate(1s)
table rate-in type ip size 1m expire 15m store bytes_in_rate(1s)
frontend statistics
bind :::8404 v4v6
mode http
http-request use-service prometheus-exporter if { path /metrics }
stats enable
stats uri /stats
stats refresh 30s
no log
###############################################################
# COMPANION ###################################################
###############################################################
frontend invidious_companion
bind 192.42.6.1:8118
mode http
http-request set-src hdr(X-Forwarded-For)
filter bwlim-in limit-in key src,ipmask(32,64) table bwlim-peers/rate-in limit 3000000
filter bwlim-out limit-out key src,ipmask(32,64) table bwlim-peers/rate-out limit 3000000
http-response set-bandwidth-limit limit-in
http-request set-bandwidth-limit limit-out
acl use_companion_01 req.cook(COMPANION_ID) 0
acl use_companion_02 req.cook(COMPANION_ID) 1
acl use_companion_03 req.cook(COMPANION_ID) 2
acl use_companion_04 req.cook(COMPANION_ID) 3
acl use_companion_05 req.cook(COMPANION_ID) 4
acl use_companion_06 req.cook(COMPANION_ID) 5
acl use_companion_07 req.cook(COMPANION_ID) 6
acl use_companion_08 req.cook(COMPANION_ID) 7
acl use_companion_09 req.cook(COMPANION_ID) 8
acl use_companion_10 req.cook(COMPANION_ID) 9
use_backend companion_01 if use_companion_01
use_backend companion_02 if use_companion_02
use_backend companion_03 if use_companion_03
use_backend companion_04 if use_companion_04
use_backend companion_05 if use_companion_05
use_backend companion_06 if use_companion_06
use_backend companion_07 if use_companion_07
use_backend companion_08 if use_companion_08
use_backend companion_09 if use_companion_09
use_backend companion_10 if use_companion_10
default_backend load_balancer_companion
backend load_balancer_companion
mode http
cookie COMPANION_ID insert indirect nocache httponly secure
balance leastconn
hash-type consistent
retry-on all-retryable-errors
option httpchk GET /healthz
server companion_01 192.42.6.31:8282 check inter 5s cookie 0
server companion_02 192.42.6.32:8282 check inter 5s cookie 1
server companion_03 192.42.6.33:8282 check inter 5s cookie 2
server companion_04 192.42.6.34:8282 check inter 5s cookie 3
server companion_05 192.42.6.35:8282 check inter 5s cookie 4
server companion_06 192.42.6.36:8282 check inter 5s cookie 5
server companion_07 192.42.6.37:8282 check inter 5s cookie 6
server companion_08 192.42.6.38:8282 check inter 5s cookie 7
server companion_09 192.42.6.39:8282 check inter 5s cookie 8
server companion_10 192.42.6.40:8282 check inter 5s cookie 9
backend companion_01
mode http
server companion01 192.42.6.31:8282
backend companion_02
mode http
server companion02 192.42.6.32:8282
backend companion_03
mode http
server companion03 192.42.6.33:8282
backend companion_04
mode http
server companion04 192.42.6.34:8282
backend companion_05
mode http
server companion05 192.42.6.35:8282
backend companion_06
mode http
server companion06 192.42.6.36:8282
backend companion_07
mode http
server companion07 192.42.6.37:8282
backend companion_08
mode http
server companion08 192.42.6.38:8282
backend companion_09
mode http
server companion09 192.42.6.39:8282
backend companion_10
mode http
server companion10 192.42.6.40:8282
###############################################################
# PROXY #######################################################
###############################################################
frontend invidious_proxy
bind 192.42.6.1:8119
mode http
http-request set-src hdr(X-Forwarded-For)
filter bwlim-in limit-in key src,ipmask(32,64) table bwlim-peers/rate-in limit 30000000
filter bwlim-out limit-out key src,ipmask(32,64) table bwlim-peers/rate-out limit 30000000
http-response set-bandwidth-limit limit-in
http-request set-bandwidth-limit limit-out
acl use_proxy_01 req.cook(COMPANION_ID) 0
acl use_proxy_02 req.cook(COMPANION_ID) 1
acl use_proxy_03 req.cook(COMPANION_ID) 2
acl use_proxy_04 req.cook(COMPANION_ID) 3
acl use_proxy_05 req.cook(COMPANION_ID) 4
acl use_proxy_06 req.cook(COMPANION_ID) 5
acl use_proxy_07 req.cook(COMPANION_ID) 6
acl use_proxy_08 req.cook(COMPANION_ID) 7
acl use_proxy_09 req.cook(COMPANION_ID) 8
acl use_proxy_10 req.cook(COMPANION_ID) 9
use_backend proxy_01 if use_proxy_01
use_backend proxy_02 if use_proxy_02
use_backend proxy_03 if use_proxy_03
use_backend proxy_04 if use_proxy_04
use_backend proxy_05 if use_proxy_05
use_backend proxy_06 if use_proxy_06
use_backend proxy_07 if use_proxy_07
use_backend proxy_08 if use_proxy_08
use_backend proxy_09 if use_proxy_09
use_backend proxy_10 if use_proxy_10
default_backend load_balancer_proxy
backend load_balancer_proxy
mode http
cookie COMPANION_ID insert indirect nocache httponly secure
balance leastconn
hash-type consistent
http-request del-header X-Forwarded-For
http-request del-header X-Real-IP
retry-on all-retryable-errors
option httpchk GET /health
server proxy_01 192.42.6.31:8283 check inter 5s cookie 0
server proxy_02 192.42.6.32:8283 check inter 5s cookie 1
server proxy_03 192.42.6.33:8283 check inter 5s cookie 2
server proxy_04 192.42.6.34:8283 check inter 5s cookie 3
server proxy_05 192.42.6.35:8283 check inter 5s cookie 4
server proxy_06 192.42.6.36:8283 check inter 5s cookie 5
server proxy_07 192.42.6.37:8283 check inter 5s cookie 6
server proxy_08 192.42.6.38:8283 check inter 5s cookie 7
server proxy_09 192.42.6.39:8283 check inter 5s cookie 8
server proxy_10 192.42.6.40:8283 check inter 5s cookie 9
backend proxy_01
mode http
http-request del-header X-Forwarded-For
http-request del-header X-Real-IP
server proxy01 192.42.6.31:8283
backend proxy_02
mode http
http-request del-header X-Forwarded-For
http-request del-header X-Real-IP
server proxy02 192.42.6.32:8283
backend proxy_03
mode http
http-request del-header X-Forwarded-For
http-request del-header X-Real-IP
server proxy03 192.42.6.33:8283
backend proxy_04
mode http
http-request del-header X-Forwarded-For
http-request del-header X-Real-IP
server proxy04 192.42.6.34:8283
backend proxy_05
mode http
http-request del-header X-Forwarded-For
http-request del-header X-Real-IP
server proxy05 192.42.6.35:8283
backend proxy_06
mode http
http-request del-header X-Forwarded-For
http-request del-header X-Real-IP
server proxy06 192.42.6.36:8283
backend proxy_07
mode http
http-request del-header X-Forwarded-For
http-request del-header X-Real-IP
server proxy07 192.42.6.37:8283
backend proxy_08
mode http
http-request del-header X-Forwarded-For
http-request del-header X-Real-IP
server proxy08 192.42.6.38:8283
backend proxy_09
mode http
http-request del-header X-Forwarded-For
http-request del-header X-Real-IP
server proxy09 192.42.6.39:8283
backend proxy_10
mode http
http-request del-header X-Forwarded-For
http-request del-header X-Real-IP
server proxy10 192.42.6.40:8283