How to securely deploy a Dockerized app on a VPS using Caddy and keep Postgres private
A common security pitfall for developers hosting side projects on cheap VPS servers is leaving PostgreSQL exposed on port 5432, skipping HTTPS, and committing secrets to version control. A single Docker Compose file can address all three issues by placing Caddy as the only internet-facing service on ports 80 and 443, while the app and database communicate solely over an internal Docker network. Caddy handles automatic TLS certificate issuance via Let's Encrypt, proxying external traffic to the app container without exposing it directly to the host. The database container omits any published ports entirely, ensuring Postgres is never reachable from the public internet. The setup requires a VPS running Ubuntu with Docker installed, a domain A record pointing to the server's IP, and a securely generated .env file that is never committed to the repository.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.
Discussion (0)
Log in to join the discussion and vote.
Log in