2026-01-11 15:30:43 +00:00
|
|
|
global
|
|
|
|
|
log stdout format raw local0
|
|
|
|
|
maxconn 4096
|
|
|
|
|
daemon
|
2026-02-23 18:52:19 +00:00
|
|
|
# Blue-green: runtime API for server enable/disable
|
|
|
|
|
stats socket /var/run/haproxy.sock level admin
|
2026-01-11 15:30:43 +00:00
|
|
|
|
|
|
|
|
defaults
|
|
|
|
|
log global
|
|
|
|
|
mode http
|
|
|
|
|
option httplog
|
|
|
|
|
option dontlognull
|
|
|
|
|
option forwardfor
|
|
|
|
|
option http-server-close
|
|
|
|
|
timeout connect 5000ms
|
|
|
|
|
timeout client 50000ms
|
|
|
|
|
timeout server 50000ms
|
|
|
|
|
timeout http-request 10000ms
|
|
|
|
|
|
|
|
|
|
# ============================================================================
|
2026-02-15 14:58:51 +00:00
|
|
|
# STATS & MONITORING (P1.3: restricted to internal network)
|
2026-01-11 15:30:43 +00:00
|
|
|
# ============================================================================
|
|
|
|
|
frontend stats
|
|
|
|
|
bind *:8404
|
|
|
|
|
stats enable
|
|
|
|
|
stats uri /stats
|
|
|
|
|
stats refresh 30s
|
2026-02-15 14:58:51 +00:00
|
|
|
acl from_internal src 127.0.0.1 172.20.0.0/16
|
|
|
|
|
stats admin if from_internal
|
2026-01-11 15:30:43 +00:00
|
|
|
|
|
|
|
|
# ============================================================================
|
|
|
|
|
# HTTP FRONTEND (Port 80)
|
|
|
|
|
# ============================================================================
|
|
|
|
|
frontend http_frontend
|
|
|
|
|
bind *:80
|
|
|
|
|
mode http
|
|
|
|
|
|
2026-02-15 14:58:51 +00:00
|
|
|
# P1.1: Redirect HTTP to HTTPS in production
|
|
|
|
|
redirect scheme https code 301 if !{ ssl_fc }
|
2026-01-11 15:30:43 +00:00
|
|
|
|
|
|
|
|
# ACLs for routing
|
|
|
|
|
acl is_api path_beg /api/v1
|
|
|
|
|
acl is_stream path_beg /stream
|
2026-02-18 11:42:42 +00:00
|
|
|
acl is_hls path_beg /hls
|
2026-01-11 15:30:43 +00:00
|
|
|
acl is_web path_beg /
|
|
|
|
|
|
|
|
|
|
# Route to appropriate backend
|
|
|
|
|
use_backend backend_api if is_api
|
|
|
|
|
use_backend stream_ws if is_stream
|
2026-02-18 11:42:42 +00:00
|
|
|
use_backend stream_ws if is_hls
|
2026-01-11 15:30:43 +00:00
|
|
|
use_backend web_frontend if is_web
|
|
|
|
|
|
|
|
|
|
# ============================================================================
|
2026-02-15 14:58:51 +00:00
|
|
|
# HTTPS FRONTEND (Port 443) - P1.1: Production HTTPS
|
|
|
|
|
# Certificates from config/ssl/ mounted at /etc/ssl/veza/
|
2026-01-11 15:30:43 +00:00
|
|
|
# ============================================================================
|
2026-02-15 14:58:51 +00:00
|
|
|
frontend https_frontend
|
|
|
|
|
bind *:443 ssl crt /etc/ssl/veza/veza.pem
|
|
|
|
|
mode http
|
|
|
|
|
# ACLs for routing
|
|
|
|
|
acl is_api path_beg /api/v1
|
|
|
|
|
acl is_stream path_beg /stream
|
2026-02-18 11:42:42 +00:00
|
|
|
acl is_hls path_beg /hls
|
2026-02-15 14:58:51 +00:00
|
|
|
acl is_web path_beg /
|
|
|
|
|
# Route to appropriate backend
|
|
|
|
|
use_backend backend_api if is_api
|
|
|
|
|
use_backend stream_ws if is_stream
|
2026-02-18 11:42:42 +00:00
|
|
|
use_backend stream_ws if is_hls
|
2026-02-15 14:58:51 +00:00
|
|
|
use_backend web_frontend if is_web
|
2026-01-11 15:30:43 +00:00
|
|
|
|
|
|
|
|
# ============================================================================
|
2026-02-23 18:52:19 +00:00
|
|
|
# BACKENDS - Blue-Green Deployment
|
|
|
|
|
# Use scripts/deploy-blue-green.sh to switch active stack
|
2026-01-11 15:30:43 +00:00
|
|
|
# ============================================================================
|
|
|
|
|
|
2026-02-23 18:52:19 +00:00
|
|
|
# Backend API (Go) - blue/green
|
2026-01-11 15:30:43 +00:00
|
|
|
backend backend_api
|
|
|
|
|
mode http
|
|
|
|
|
balance roundrobin
|
|
|
|
|
option httpchk GET /api/v1/health
|
|
|
|
|
http-check expect status 200
|
2026-02-23 18:52:19 +00:00
|
|
|
server api_blue backend-api-blue:8080 check inter 5s fall 3 rise 2
|
|
|
|
|
server api_green backend-api-green:8080 check inter 5s fall 3 rise 2 backup
|
2026-01-11 15:30:43 +00:00
|
|
|
|
2026-02-23 18:52:19 +00:00
|
|
|
# Stream WebSocket (Rust) - blue/green
|
2026-01-11 15:30:43 +00:00
|
|
|
backend stream_ws
|
|
|
|
|
mode http
|
|
|
|
|
balance roundrobin
|
|
|
|
|
option httpchk GET /health
|
|
|
|
|
http-check expect status 200
|
|
|
|
|
timeout tunnel 3600s
|
2026-02-23 18:52:19 +00:00
|
|
|
server stream_blue stream-server-blue:3001 check inter 5s fall 3 rise 2
|
|
|
|
|
server stream_green stream-server-green:3001 check inter 5s fall 3 rise 2 backup
|
2026-01-11 15:30:43 +00:00
|
|
|
|
2026-02-23 18:52:19 +00:00
|
|
|
# Web Frontend (React/Vite) - blue/green
|
2026-01-11 15:30:43 +00:00
|
|
|
backend web_frontend
|
|
|
|
|
mode http
|
|
|
|
|
balance roundrobin
|
|
|
|
|
option httpchk GET /
|
|
|
|
|
http-check expect status 200
|
2026-02-23 18:52:19 +00:00
|
|
|
server web_blue web-blue:5173 check inter 5s fall 3 rise 2
|
|
|
|
|
server web_green web-green:5173 check inter 5s fall 3 rise 2 backup
|