Skip to content

Instantly share code, notes, and snippets.

@RafalSladek
Created June 10, 2018 14:34
Show Gist options
  • Select an option

  • Save RafalSladek/28a93873c9bb15f2b8195c02ffc2328e to your computer and use it in GitHub Desktop.

Select an option

Save RafalSladek/28a93873c9bb15f2b8195c02ffc2328e to your computer and use it in GitHub Desktop.
install and setup caddy web proxy as service for monit, to server ssl and password protected access
#!/bin/bash
curl https://getcaddy.com | bash -s personal hook.service,http.datadog,http.forwardproxy,http.login,http.minify,http.nobots,http.ratelimit
# config
mkdir /etc/caddy
chown -R root:www-data /etc/caddy
cat << EOF > /etc/caddy/Caddyfile
alpharack1.crypto-pool.net/monit {
gzip
log /var/log/caddy/access.log
proxy / localhost:2812 #this is proxy for monit
tls [email protected]
basicauth / user password
}
EOF
# ssl
mkdir /etc/ssl/caddy
chown -R www-data /etc/ssl/caddy
chmod 0770 /etc/ssl/caddy
# log
mkdir /var/log/caddy
chown -R www-data /var/log/caddy
chmod 0770 /var/log/caddy
# firewall
ufw allow http
ufw allow https
# service unit file
curl -s https://raw.githubusercontent.com/mholt/caddy/master/dist/init/linux-systemd/caddy.service -o /etc/systemd/system/caddy.service
systemctl daemon-reload
systemctl enable caddy
systemctl start caddy
systemctl status caddy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment