quickAssist = function() { let history = []; const states = { start: { prompt: "What are you looking for?", options: [ { text: "How to install Caddy", next: "install" }, { text: "Help configuring Caddy", next: "configure" }, { text: "A solution to a problem", next: "solution" }, { text: "An example for my use case", next: "example" } ] }, install: { prompt: "How do you want to install Caddy?", options: [ { text: "OS package manager", next: "install_pkgmgr" }, { text: "Docker", next: "install_docker" }, { text: "Build from source", next: "install_build" }, { text: "Build with plugins", next: "install_with_plugins" }, { text: "Pre-built binary", next: "install_binary" } ] }, install_pkgmgr: { prompt: "Which OS are you using?", options: [ { text: "Linux (Debian, Ubuntu, Raspbian)", next: "install_dpkg" }, { text: "Linux (Fedora, RedHat, CentOS)", next: "install_rpm" }, { text: "Linux (Arch, Manjaro, Parabola)", next: "install_arch" }, { text: "macOS", next: "install_mac" }, { text: "Windows", next: "install_windows" }, { text: "Nix/NixOS", next: "install_nix" }, { text: "Android", next: "install_android" }, { text: "Other", next: "install_other" } ] }, install_dpkg: { title: "Install Caddy on Debian-based systems", content: `
sudo apt install -y debian-keyring debian-archive-keyring apt-transport-https
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' | sudo gpg --dearmor -o /usr/share/keyrings/caddy-stable-archive-keyring.gpg
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt' | sudo tee /etc/apt/sources.list.d/caddy-stable.list
sudo apt update
sudo apt install caddy
`,
options: [
{
text: "Learn more",
href: "/docs/install#debian-ubuntu-raspbian"
}
]
},
install_rpm: {
title: "Install Caddy via RPM",
content: `dnf install 'dnf-command(copr)'
dnf copr enable @caddy/caddy
dnf install caddy
`,
options: [
{
text: "Learn more",
href: "/docs/install#fedora-redhat-centos"
}
]
},
install_arch: {
title: "Install Caddy on Arch/Manjaro/Parabola Linux",
content: `pacman -Syu caddy
`,
options: [
{
text: "Learn more",
href: "/docs/install#arch-linux-manjaro-parabola"
}
]
},
install_mac: {
title: "Install Caddy on macOS",
content: `brew install caddy
`,
options: [
{
text: "Learn more",
href: "/docs/install#homebrew"
}
]
},
install_windows: {
title: "Install Caddy on Windows",
content: `Chocolatey:
choco install caddy
Scoop:
scoop install caddy
`,
options: [
{
text: "Learn more",
href: "/docs/install#windows"
}
]
},
install_nix: {
title: "Install Caddy on Nix/Nixpkgs/NixOS",
content: `caddy
services.caddy
pkg install caddy
`,
options: [
{
text: "Learn more",
href: "/docs/install#termux"
}
]
},
install_other: {
title: "Miscellaneous install methods",
content: ` Linux and macOS:
curl -sS https://webi.sh/caddy | sh
Windows:
curl.exe https://webi.ms/caddy | powershell
ansible-galaxy install nvjacobo.caddy
`,
options: [
{
text: "Learn more",
href: "/docs/install#fedora-redhat-centos"
}
]
},
install_docker: {
title: "Official Docker image",
content: `docker pull caddy
`,
options: [
{
text: "Learn more",
href: "/docs/install#docker"
}
]
},
install_build: {
title: "Build Caddy from source",
content: `Make sure to have git
and the latest version of Go installed.
git clone "https://github.com/caddyserver/caddy.git"
cd caddy/cmd/caddy/
go build
`,
options: [
{
text: "Learn more",
href: "/docs/build"
}
]
},
install_with_plugins: {
title: "Build Caddy with plugins",
content: `
xcaddy
is a command line tool
that helps you build Caddy with plugins. A basic build looks like:
xcaddy build
To build with plugins, use --with
:
xcaddy build \\
--with github.com/caddyserver/nginx-adapter
--with github.com/caddyserver/ntlm-transport@v0.1.1
`,
options: [
{
text: "Learn more",
href: "/docs/build#xcaddy"
}
]
},
install_binary: {
title: "Install Caddy binary manually",
content: `
go
or xcaddy
)
Place the binary in one of your $PATH
(or %PATH%
on Windows) directories so you can run
caddy
without typing the full path of the executable file. (Run echo $PATH
to see the list
of directories that qualify.)
You can upgrade static binaries by replacing them with newer versions and restarting Caddy. The caddy upgrade
command can make this easy.
In order to prevent abuse, you must first configure an ask
endpoint so Caddy
can check whether it should get a certificate. Add this to your global options at the top:
on_demand_tls {
ask http://localhost:5555/check
}
Change that endpoint to be something you've set up that will respond with HTTP 200 if the
domain given in the domain=
query parameter is allowed to have a certificate.
Then create a site block that serves all sites/hosts on the TLS port:
https:// {
tls {
on_demand
}
}
This is the minimum config to enable Caddy to accept and service TLS connections for arbitrary
hosts. This config doesn't invoke any handlers. Usually you'll also reverse_proxy
to your backend application.