global
  log stdout format raw local0
  # stats socket /run/haproxy/admin.sock mode 660 level admin expose-fd listeners
  stats timeout 30s

defaults
  log global
  mode http
  retries 3
  maxconn 2000
  timeout connect 5s
  timeout client 50s
  timeout server 50s
  timeout http-request 10s
  timeout http-keep-alive 2s
  timeout queue 5s
  timeout tunnel 2m
  timeout client-fin 1s
  timeout server-fin 1s


#Application Setup
frontend ContentSwitching
  bind *:80 v4v6
  bind *:443 v4v6 ssl crt /zfs/storage/secrets/docker/cloudflare.pem
  mode  http
  # tmmworkshop.com
  acl host_audiobookshelf  hdr(host) -i audiobookshelf.tmmworkshop.com
  acl host_cache  hdr(host) -i cache.tmmworkshop.com
  acl host_jellyfin  hdr(host) -i jellyfin.tmmworkshop.com
  acl host_share  hdr(host) -i share.tmmworkshop.com
  acl host_gcw  hdr(host) -i gcw.tmmworkshop.com
  acl host_n8n  hdr(host) -i n8n.tmmworkshop.com
  acl host_gitea  hdr(host) -i gitea.tmmworkshop.com

  use_backend audiobookshelf_nodes if host_audiobookshelf
  use_backend cache_nodes  if host_cache
  use_backend jellyfin if host_jellyfin
  use_backend share_nodes  if host_share
  use_backend gcw_nodes  if host_gcw
  use_backend n8n  if host_n8n
  use_backend gitea  if host_gitea

backend audiobookshelf_nodes
  mode http
  server server 127.0.0.1:8000

backend cache_nodes
  mode http
  server server 127.0.0.1:5000

backend jellyfin
    option httpchk
    option forwardfor
    http-check send meth GET uri /health
    http-check expect string Healthy
    server jellyfin 127.0.0.1:8096

backend share_nodes
  mode http
  server server 127.0.0.1:8091

backend gcw_nodes
  mode http
  server server 127.0.0.1:8092

backend n8n
  mode http
  server server 127.0.0.1:5678

backend gitea
  mode http
  server server 127.0.0.1:6443