Skip to content

Instantly share code, notes, and snippets.

@Nill-R
Last active January 27, 2019 15:50
Show Gist options
  • Save Nill-R/40c5a4bcb33a9ea2b204e1502303d5ca to your computer and use it in GitHub Desktop.
Save Nill-R/40c5a4bcb33a9ea2b204e1502303d5ca to your computer and use it in GitHub Desktop.
Script for autoinstall Caddy
#!/bin/bash
apt -y install curl
CADDY_TELEMETRY=on curl -s https://getcaddy.com | bash -s personal http.cache,http.cgi,http.cors,http.expires,http.filter,http.forwardproxy,http.geoip,http.ipfilter,http.locale,http.login,http.minify,http.nobots,http.ratelimit,http.realip,tls.dns.cloudflare,tls.dns.namecheap,tls.dns.vultr
setcap 'cap_net_bind_service=+ep' /usr/local/bin/caddy
mkdir -p /etc/caddy/ssl
mkdir -p /etc/caddy/sites-enabled
mkdir -p /etc/caddy/sites-available
chown -R www-data:www-data /etc/caddy
chmod 0750 /etc/caddy/ssl
echo "import /etc/caddy/sites-enabled/*" >/etc/caddy/Caddyfile
chown www-data:www-data /etc/caddy/Caddyfile
chmod 640 /etc/caddy/Caddyfile
mkdir -p /var/log/caddy/
chown www-data:www-data /var/log/caddy
curl -s https://gist.githubusercontent.com/Nill-R/c2446c2a22db9304f499d19959a89ffc/raw/ab91efc9e85420dcc33acec0ab3d9137a6822d5b/caddy.service -o /etc/systemd/system/caddy.service
chown root:root /etc/systemd/system/caddy.service
chmod 644 /etc/systemd/system/caddy.service
curl -s https://gist.githubusercontent.com/Nill-R/b7c8407044ae26e5fe43873fd54b3288/raw/4cf35b2ba9741f65180dcb63b1387427b3adfe5d/default -o /etc/caddy/sites-available/default
ln -s /etc/caddy/sites-available/default /etc/caddy/sites-enabled/default
systemctl daemon-reload
systemctl start caddy.service
systemctl enable caddy.service
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment