-
Update your system:
sudo apt update && sudo apt upgrade -y
-
Install required packages:
sudo apt install -y curl git build-essential
-
Install Go (if not already installed):
sudo apt install -y golang
Verify Go installation:
go version
If the version is older than 1.18, you may need to install a newer version manually:
wget https://go.dev/dl/go1.20.5.linux-amd64.tar.gz sudo tar -C /usr/local -xzf go1.20.5.linux-amd64.tar.gz
Add Go to your PATH by adding these lines to your ~/.bashrc file:
export PATH=$PATH:/usr/local/go/bin export PATH=$PATH:$(go env GOPATH)/bin
Then, reload your bash profile:
source ~/.bashrc
- Install xcaddy:
go install github.com/caddyserver/xcaddy/cmd/xcaddy@latest
-
Build Caddy with the L4 module:
xcaddy build --with github.com/mholt/caddy-l4
-
Verify the build:
./caddy version
-
Move the Caddy binary to a system-wide location:
sudo mv caddy /usr/local/bin/
-
Set the appropriate permissions:
sudo chown root:root /usr/local/bin/caddy sudo chmod 755 /usr/local/bin/caddy
-
(Optional) If you want Caddy to bind to privileged ports (like 80 and 443):
sudo setcap CAP_NET_BIND_SERVICE=+eip /usr/local/bin/caddy
-
Create a Caddyfile in your current directory or specify a path when running Caddy.
-
Run Caddy:
caddy run --config /path/to/your/Caddyfile
Remember to replace "/path/to/your/Caddyfile" with the actual path to your Caddy configuration file.