-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.sh
39 lines (32 loc) · 1.01 KB
/
init.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
# download caddy
sudo curl https://getcaddy.com | bash -s http.minify,tls.dns.digitalocean
# permission to “root” and make it executable
sudo chown root:root /usr/local/bin/caddy
sudo chmod 755 /usr/local/bin/caddy
sudo setcap CAP_NET_BIND_SERVICE=+eip /usr/local/bin/caddy
# create the Caddy’s user and group
sudo groupadd caddy
sudo useradd \
-g caddy \
--home-dir /var/www --no-create-home \
--shell /usr/sbin/nologin \
--system caddy
# Caddyfile setup
sudo mkdir /etc/caddy
sudo touch /etc/caddy/Caddyfile
sudo chown -R root:caddy /etc/caddy
sudo chown caddy:caddy /etc/caddy/Caddyfile
sudo chmod 444 /etc/caddy/Caddyfile
# SSL config
sudo mkdir /etc/ssl/caddy
sudo chown -R caddy:root /etc/ssl/caddy
sudo chmod 770 /etc/ssl/caddy
# root dir
sudo mkdir /var/www
# Caddy service config
sudo cp Caddyservice /etc/systemd/system/caddy.service
sudo chown root:root /etc/systemd/system/caddy.service
sudo chmod 644 /etc/systemd/system/caddy.service
# Start Caddy
sudo systemctl daemon-reload
sudo systemctl start caddy