Brian Kotch

DevOpsTerraformDockerApacheNext.jsAI Slop
随筆

Modern Multi-Service Architecture with Apache, Docker & Terraform

Tags: DevOps, Terraform, Docker, Apache, Next.js, AI Slop

Monolithic single-server setups often get replaced by sprawling Kubernetes clusters that rack up huge cloud bills. But for many production systems, a well-architected Linux box orchestrated with Terraform, Docker Compose, and an Apache 2.4 reverse proxy delivers extreme performance, resilience, and simplicity.


Why Apache as a Modern Reverse Proxy?

While NGINX and Caddy get a lot of modern attention, Apache 2.4 remains one of the most mature, reliable reverse proxies available when properly configured:

  • mod_proxy & mod_proxy_http: High-concurrency socket pooling to containerized loopback services.
  • WebSocket Upgrade Routing: Seamless bidirectional support for Next.js Fast Refresh and WebSocket channels.
  • Granular Path Routing: Routing / to Next.js (port 3000), /v1/bio to Express (port 8080), and /prime or /v1/weather to Python Flask (port 9000) under a single TLS certificate. Each backend is exposed only through its explicitly enumerated routes rather than a blanket path prefix.

Zero-Downtime Infrastructure as Code

By managing the entire machine in Terraform:

  1. Base packages, firewall rules, and systemd units are codified in devops/terraform.
  2. Static Hugo sites utilize atomic symlink directory swaps (releases/<timestamp> -> current).
  3. Containerized microservices restart rolling containers on loopback ports without dropping client connections.
  4. Let's Encrypt certificates automatically renew through Certbot hooks.
和敬清寂 · All Rights Reserved Brian Kotch