Last active
July 22, 2022 05:15
-
-
Save dimasahmad/6a07a648c0fe433c3b64686ed741fe77 to your computer and use it in GitHub Desktop.
Install Caddy 2 on Ubuntu
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
#!/usr/local/env bash | |
# | |
# Create a cloud server with Vultr! Get free credits with this affiliate link: https://www.vultr.com/?ref=8498681-6G | |
# | |
# (Unofficial) Caddy 2 Installer Script | |
# | |
# Tested on Ubuntu 19.10 | |
# | |
# Caddy 2 is still in beta. Once it released a stable version, this script will be updated to only use stable version. | |
# | |
# Caddy documentation: https://caddyserver.com/docs/install | |
# Check root permission | |
if [ "$(whoami)" != "root" ]; then | |
SUDO=sudo | |
fi | |
# Update system | |
${SUDO} apt update && ${SUDO} apt full-upgrade -y | |
# Define caddy2 version | |
VER=$(curl -s https://github.com/caddyserver/caddy/releases | egrep -o '(v[0-9]).*(linux_amd64)' | grep caddy2 | grep beta | head -1) | |
# Get caddy2 binary | |
${SUDO} wget "https://github.com/caddyserver/caddy/releases/download/${VER}" -O /usr/bin/caddy | |
# Change file permission | |
${SUDO} chmod +x /usr/bin/caddy | |
# Print caddy version | |
caddy version | |
# Create a group named caddy | |
${SUDO} groupadd --system caddy | |
# Create a user named caddy, with a writebale home folder | |
${SUDO} useradd --system \ | |
--gid caddy \ | |
--create-home \ | |
--home-dir /var/lib/caddy \ | |
--shell /usr/sbin/nologin \ | |
--comment "Caddy web server" \ | |
caddy | |
# Get systemd service | |
${SUDO} wget https://github.com/caddyserver/dist/raw/master/init/caddy.service -O /etc/systemd/system/caddy.service | |
sudo mkdir /etc/caddy | |
sudo chown -R root:caddy /etc/caddy | |
sudo touch /etc/caddy/Caddyfile | |
# Reload service | |
${SUDO} systemctl daemon-reload | |
# Enable service | |
${SUDO} systemctl enable caddy | |
# Start service | |
${SUDO} systemctl start caddy |
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
# Refer to the Caddy docs for more information: | |
# https://caddyserver.com/docs/caddyfile | |
:80 | |
reverse_proxy 10.100.100.1:80 |
Outdated, please update.
I don't use caddy anymore. You should find another tutorial.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Why not use api.github.com to get latest version of caddy