Hands-on tutorial

Tutorials · DevOps & Containers

How to Publish Internal Web Apps Securely With a Reverse Proxy and Automatic TLS

Put a reverse proxy such as Caddy in front of internal web applications on an edge server: automatic HTTPS certificates, one entry point, access restrictions and security headers.

Intermediate9 min6 steps

Before you start

  • A Linux edge server with Docker
  • A domain name you control and DNS records for each application
  • Firewall rules allowing ports 80 and 443 to the proxy only

Step by step

  1. Run the proxy

    Run Caddy in a container with persistent storage for certificates.

    docker run -d --name caddy -p 80:80 -p 443:443 \
      -v $PWD/Caddyfile:/etc/caddy/Caddyfile -v caddy_data:/data caddy:2
    
  2. Define the sites

    Each hostname forwards to an internal application; Caddy obtains and renews certificates automatically.

    portal.example.com {
      reverse_proxy 10.0.20.15:8080
    }
    
  3. Restrict access

    Limit admin applications to office or VPN IP ranges, and add authentication where the application has none.

  4. Add security headers

    Enable HSTS and sensible security headers, and hide server version information.

  5. Keep applications private

    Applications listen only on internal addresses; the proxy is the only thing exposed.

  6. Log and monitor

    Send proxy logs to your logging system and alert on unusual errors or traffic.

Commands are generic, industry-standard examples. Exact syntax and menu names vary by model and firmware; check your device's manual on the Documentation page.

Pro tips

  • Use split-horizon DNS so internal users reach the same names.
  • Back up the proxy configuration with the rest of the server.
  • Consider a WAF for public applications.