What is Caddy?

Caddy has a wide range of use cases including:

  • Web Server
  • Reverse Proxy
  • Sidecar Proxy
  • Load Balancer
  • API Gateway
  • Ingress Controller
  • System Manager
  • Process Supervisor
  • Task Scheduler

Today we will be installing and setting up Caddy as a Reverse Proxy. This will be on a Debian 10 system but this will also work with Ubuntu 20.

Install - https://caddyserver.com/docs/download
1.

echo "deb [trusted=yes] https://apt.fury.io/caddy/ /" \
| sudo tee -a /etc/apt/sources.list.d/caddy-fury.list
  1. sudo apt update
  2. sudo apt install caddy

Check status: systemctl status caddy
You should see something similar to this:

● caddy.service - Caddy
   Loaded: loaded (/lib/systemd/system/caddy.service; enabled; vendor preset: enabled)
   Active: active (running) since Sat 2020-11-15 20:00:00 UTC; 2min 35s ago
     Docs: https://caddyserver.com/docs/
 Main PID: 6969 (caddy)
    Tasks: 7 (limit: 1167)
   Memory: 15.5M
   CGroup: /system.slice/caddy.service
           └─4028 /usr/bin/caddy run --environ --config /etc/caddy/Caddyfile
  1. Now head to your server's IP e.g. http://127.0.0.1
    You should see:
    Alt

Reverse Proxy Setup

  1. Create Caddyfile in the current working directory

Use the following template:

example.com {
reverse_proxy 127.0.0.1:8080
}
  1. Restart Caddy and adopt the new config
    caddy reload

HTTPS
Once the new config is loaded, a Let's Encrypt HTTPS certificate is automatically generated for the domain. Just make sure the A record points to the Caddy server!

Additional Settings

  • Load Balancing
  • Active Health Checks
  • Passive Health Checks
  • Streaming
  • Header Manipulation
  • Transport

That's it! ‌
‌Now grab a coffee ☕️

Our other Caddy Guides:

How to enable Caddy HTTP Basic Authentication (basicauth) Guide
What is HTTP Basic Authentication?When visiting a website, protected with Basic Auth the browser will prompt theuser to enter a username and password before any recourses are loaded. The client will then send an Authorization header with each request to thewebsite, to maintain authentication.T…
Caddy Caddyfile Advanced Setup
Our Caddy Setup Guide can be found here [/caddy-setup/]. What will be covered? * HTTP Headers [/caddy-advanced-setup/#headers] * Custom Certificates [/caddy-advanced-setup/#customsslcertificates] * Using an alternative ACME Certificate Autority [/caddy-advanced-setup/#zerosslacmesetup] (ZeroS…