The Simplest Way to Make Apache and Caddy Work Like They Should
Running apache and caddy together lets teams mix automatic HTTPS with deep module support. Caddy handles public traffic and TLS certificates, then sends clean requests to Apache. Many older apps need Apache modules to run dynamic scripts and rewrite complex rules. Caddy makes edge routing simple and renews TLS keys on its own. Putting them side by side gives your team the best parts of both servers. You keep your stable app setup while making public certificate management much easier. How dat
Your coding agents run with your access.
Claude Code reaches prod with a developer's credentials, and approval prompts get clicked through. hoop.dev checks every query, masks sensitive data, and holds risky changes for a human.
Running apache and caddy together lets teams mix automatic HTTPS with deep module support. Caddy handles public traffic and TLS certificates, then sends clean requests to Apache.
Many older apps need Apache modules to run dynamic scripts and rewrite complex rules. Caddy makes edge routing simple and renews TLS keys on its own. Putting them side by side gives your team the best parts of both servers. You keep your stable app setup while making public certificate management much easier.
How data and permissions flow between apache and caddy
In a standard setup, Caddy sits at the public network edge. It listens on standard web ports and manages TLS certificates for your domains. When a user visits your site, Caddy takes the encrypted request first. It checks the domain name, decrypts the traffic, and applies basic rate limits.
Next, Caddy forwards the clean request to Apache over a private local network. Apache listens only on an internal port or a local loopback address. It does not need to face the public web or touch public TLS keys. Apache runs your local app logic, directory rules, and legacy scripts. Once Apache finishes the job, it sends the response back to Caddy. Caddy then encrypts the data and sends it back to the user.
You can also add login checks at the edge before traffic reaches Apache. Caddy can check user headers or tokens before passing requests to the backend. This keeps bad traffic away from your heavy app processes. Each server runs under its own restricted system user account with narrow file permissions.
Common failure modes and how to scope network paths
A common mistake is leaving Apache open to the public internet by accident. If Apache listens on all network interfaces, attackers can bypass Caddy and its rules. Always bind Apache to the local loopback address or a private subnet. Use firewall rules to make sure only the Caddy host can reach Apache.
Another frequent problem involves lost client IP addresses in your server logs. Because Caddy sits in front, Apache sees every request coming from Caddy's IP address. This breaks IP access rules and makes security audits hard to read. You must set up Caddy to pass standard forwarding headers to the backend. Then, tell Apache to trust headers only when they come from Caddy's local IP. Never trust forwarding headers from unknown hosts, or users will spoof their addresses.
End-to-End Encryption: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
Shared system accounts and broad file permissions also create big security risks. Do not run both web servers under the same Linux user account. If one service gets compromised, shared permissions let attackers read everything on the disk. Give Caddy access only to its own state files and certificate folders. Give Apache read access only to the web root folders it needs to serve.
Managing server logs and admin changes safely
Running two web servers means your team has two sets of logs to watch. Caddy writes edge access logs, while Apache records backend app errors and script output. Make sure both servers use the same time zone and request ID headers. When Caddy creates a unique ID for each request, pass it to Apache. This lets engineers trace a single slow request across both log files fast.
Keep admin access to both servers locked down at all times. Engineers often log into production hosts with shared keys to edit server files. Shared SSH keys make it impossible to see who changed a routing rule. Instead, tie every server login and file change to a single person. Test your rule files before you reload either server in production. A quick syntax check stops bad rules from taking your site offline.
Govern statements and responses across databases and APIs
Good config and scoped roles are needed setup. They do not check single queries in flight or mask sensitive fields in returned rows. Across Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes APIs, SSH, and internal HTTP endpoints, hoop.dev runs beside each supported service as an open-source proxy, a sidecar for your database or API.
First, hoop.dev guardrails block banned queries before they run. Then hoop.dev data masking rewrites matched sensitive values in responses in memory. The audit trail records every statement and verdict per resource. Furthermore, hoop.dev holds SOC 2 Type II and is open source on GitHub.
Frequently asked questions
Why run Caddy in front of Apache instead of using one server?
Caddy automates TLS setup, while Apache runs legacy modules that many older apps still need.
Should traffic between Caddy and Apache be encrypted?
If both run on the same host, local traffic is safe, but separate hosts need TLS.
How do we stop Apache from logging Caddy's IP address for every user?
Set Apache to read the forwarding header from Caddy and trust only Caddy's internal IP.
Related guides
In this post