Skip to content

Instantly share code, notes, and snippets.

@CodingWithAnxiety
Last active August 23, 2024 20:56
Show Gist options
  • Save CodingWithAnxiety/9ac0b17472fcbe13550add3df9c23e41 to your computer and use it in GitHub Desktop.
Save CodingWithAnxiety/9ac0b17472fcbe13550add3df9c23e41 to your computer and use it in GitHub Desktop.

This is a suppliment to the guide provided on the namelessMC tutorials page.

1.0 What is Caddy?

From wikipedia: "Caddy is an extensible, cross-platform, open-source web server written in Go."

1.1 Why caddy?

Caddy is a highly preformant and highly extensible webserver, spouting automated HTTPS & certificate deployment, automated HTTP/3 deployment, and an extremely simply configuration syntax.

2.0 Installing caddy

Run these commands, depending on your distro.

Debian / Ubuntu / Derrivities:

sudo apt update
sudo apt install caddy

Fedora / Red Hat / CentOS / Rocky Linux / AlmaLinux:

sudo dnf install caddy

Arch (NOT RECOMMENDED)

I cannot in good faith recommend Arch Linux for NamelessMC due to the amount of config needed. I may make a guide on this at a later date.
sudo pacman -S caddy

We need to add caddy to the http group, since Arch doesn't do this by default. Without this, permissions later in the guide will not work.

sudo usermod -aG http caddy

If you are unsure, please follow your distributions guide to installing caddy.

2.1 Setting up permissions

In short, run the following two commands;

sudo chown -R www-data:www-data /var/www/html
sudo find /var/www/html -type d -exec chmod 2770 {} +
sudo find /var/www/html -type f -exec chmod 0660 {} +

On Arch, replace www-data with http.

2.2 Creating the Caddyfile

In short, run the following commands;

sudo mkdir -p /etc/caddy/conf.d
sudo chown -R caddy:caddy /etc/caddy

Modify the base Caddyfile as following;

nano /etc/caddy/Caddyfile

Paste the following within; import /etc/caddy/conf.d/*

Important

You may want to remove all previous info in this file to prevent conflicts later- though caddy is good at avoiding it.

Then,

nano /etc/caddy/conf.d/example.com

Modify and paste this config within.

2.3 Running Caddy

Important

If you run into permission issues, make sure caddy is apart of either the www-data or http group!

All that is left to run is to run caddy run. If you want caddy to run on startup, view https://caddyserver.com/docs/running

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment