Last active
June 8, 2017 16:13
-
-
Save erdii/a1a933f3062a4878c28ff48149994ea8 to your computer and use it in GitHub Desktop.
Download and install caddy on a linux box
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
TARBALL=caddy.tar.gz | |
TARGET=/opt/caddy | |
echo "downloading caddy" | |
wget -O $TARBALL "https://caddyserver.com/download/linux/amd64?plugins=http.cors,http.expires,http.filter,http.ipfilter,http.minify,http.ratelimit" | |
echo "creating target directory" | |
sudo mkdir -p $TARGET | |
echo "extracting caddy" | |
sudo tar -xvzf $TARBALL -C $TARGET | |
echo "allow non privileged users to run caddy and bind to privileged ports" | |
sudo setcap "cap_net_bind_service=+ep" $TARGET/caddy | |
echo "removing tarball" | |
rm $TARBALL | |
echo "adding caddy user" | |
sudo adduser --disabled-password --disabled-login --no-create-home caddy | |
echo "adding caddy configuration directory (/var/caddy) | |
sudo mkdir /var/caddy | |
sudo chown caddy /var/caddy | |
sudo chmod 0700 /var/caddy | |
echo "creating systemd unit file" | |
sudo tee /etc/systemd/system/caddy.service <<EOF | |
[Unit] | |
Description=Caddy HTTP/2 web server | |
Documentation=https://caddyserver.com/docs | |
After=network.target | |
[Service] | |
User=caddy | |
LimitNOFILE=8192 | |
Environment=STNORESTART=yes | |
ExecStart=/opt/caddy/caddy -agree=true -conf=/var/caddy/Caddyfile | |
Restart=on-failure | |
[Install] | |
WantedBy=multi-user.target | |
EOF |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment