Skip to content

Instantly share code, notes, and snippets.

@kristian-lange
Forked from Jamesits/caddy.sh
Last active December 15, 2018 16:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kristian-lange/c5a7e0ed5a01b7fd726f873f81b585a5 to your computer and use it in GitHub Desktop.
Save kristian-lange/c5a7e0ed5a01b7fd726f873f81b585a5 to your computer and use it in GitHub Desktop.
Install Caddy Server on Ubuntu with Systemd.
#!/bin/bash
# This shell script installs and starts Caddy (https://caddyserver.com/) on Debian based distros.
# It uses Caddy's personal license (https://caddyserver.com/products/licenses).
# This script is a fork from https://gist.github.com/Jamesits/2a1e2677ddba31fae62d022ef8aa54dc.
# It will by default install all plugins; you can customize this behavior on line 7.
apt update
apt install curl
curl https://getcaddy.com | bash -s personal
chown root:root /usr/local/bin/caddy
chmod 755 /usr/local/bin/caddy
setcap 'cap_net_bind_service=+eip' /usr/local/bin/caddy
mkdir -p /etc/caddy
chown -R root:www-data /etc/caddy
mkdir -p /etc/ssl/caddy
chown -R www-data:root /etc/ssl/caddy
chmod 770 /etc/ssl/caddy
touch /etc/caddy/Caddyfile
mkdir -p /var/www
chown www-data:www-data /var/www
chmod 755 /var/www
curl -L https://github.com/mholt/caddy/raw/master/dist/init/linux-systemd/caddy.service | sed "s/;CapabilityBoundingSet/CapabilityBoundingSet/" | sed "s/;AmbientCapabilities/AmbientCapabilities/" | sed "s/;NoNewPrivileges/NoNewPrivileges/" | tee /etc/systemd/system/caddy.service
chown root:root /etc/systemd/system/caddy.service
chmod 744 /etc/systemd/system/caddy.service
systemctl daemon-reload
systemctl enable caddy.service
systemctl start caddy.service
# if you need QUIC protocol:
# 1. edit /etc/systemd/system/caddy.service, write " -quic" (without quotes) to the end of the line ExecStart
# 2. systemctl daemon-reload
# 3. systemctl restart caddy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment