-
Notifications
You must be signed in to change notification settings - Fork 0
/
install_caddy.sh
executable file
·73 lines (58 loc) · 1.47 KB
/
install_caddy.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/bin/bash
echo -e "Please type full qualified domain name for this server"
read -e FQDN
echo -e "Please type host"
read -e hostname
echo -e "Please type username"
read -e username
echo -e "Please type password"
read -e password
echo -e "Please type email"
read -e email
curl https://getcaddy.com | bash -s personal hook.service,http.cache,http.datadog,http.geoip,http.login,http.minify,http.nobots,http.ratelimit
chown www-data:www-data /usr/local/bin/caddy
# config
mkdir /etc/caddy
chown -R root:www-data /etc/caddy
rm -rf /var/www/html/*
cat << EOF > /etc/caddy/Caddyfile
${FQDN}/monit {
gzip
log /var/log/caddy/access.log
proxy / localhost:2812
tls ${email}
basicauth / ${username} ${password}
datadog {
statsd 127.0.0.1:8125
tags loc:${hostname} usecase:masternode role:monit
}
}
${FQDN} {
gzip
log /var/log/caddy/access.log
root /var/www/html
tls ${email}
basicauth / ${username} ${password}
datadog {
statsd 127.0.0.1:8125
tags loc:${hostname} usecase:masternode role:monit
}
}
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