Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Install caddy-umami module #14

Merged
merged 1 commit into from
Apr 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ concurrency:
jobs:
deploy:
runs-on: ubuntu-latest
if: github.event.repository.fork == false
steps:
- name: Checkout
uses: actions/checkout@v4
Expand All @@ -36,4 +37,3 @@ jobs:
KEY: ${{ secrets.VPS_SSH_PRIVATE_KEY }}
TARGET: "/home/website/thenewoil/"
ARGS: '-z -r -v -l -t --delete-after --exclude node_modules/ .git/'

1 change: 1 addition & 0 deletions .github/workflows/mirror.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ concurrency:

jobs:
to_gitlab:
if: github.event.repository.fork == false
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand Down
18 changes: 18 additions & 0 deletions .github/workflows/validate-caddy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Validate Caddyfile
on:
push:
paths:
- 'caddy/**'
pull_request:
paths:
- 'caddy/**'

jobs:
validate:
runs-on: ubuntu-latest
steps:
- name: Checkout Files
uses: actions/checkout@main
- name: Validate Caddyfile
run: |
docker run -v ./caddy:/data ghcr.io/jonaharagon/caddy-build:latest caddy validate --config /data/Caddyfile
7 changes: 7 additions & 0 deletions caddy/50-stats.caddy
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
(umami) {
umami {
event_endpoint "https://stats.thenewoil.org/api/send"
website_uuid "0cdf6f5b-9b3b-4815-9d22-8cb4d6132781"
Comment on lines +3 to +4
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Obviously (or not) you will need to replace this ID with the one from your Umami dashboard once you have it installed and the website set up in it.

device_detection
}
}
5 changes: 5 additions & 0 deletions caddy/90-clearnet.caddy
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
# Remember to change the number in ./Caddyfile after editing this file too!

thenewoil.org {
@file file
route @file {
import umami
}

# These two lines configure Caddy to serve from the www subdirectory of this repo
# see: https://caddyserver.com/docs/caddyfile/directives/file_server
root * /home/website/thenewoil/www
Expand Down
2 changes: 1 addition & 1 deletion caddy/Caddyfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# VERSION: 4
# VERSION: 5
# You should increment this number whenever changing ANY file in the /caddy folder, so that the webserver picks up the changes and restarts

# Imports the configuration from all files in this folder with the .caddy file extension
Expand Down
47 changes: 34 additions & 13 deletions docs/server/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,25 +47,46 @@ systemctl restart sshd

## Step 2. Webserver Install

1. [Install Caddy](https://caddyserver.com/docs/install#debian-ubuntu-raspbian)
1. [Install Caddy](https://caddyserver.com/docs/install#debian-ubuntu-raspbian) with apt

<details>
<summary>Why Caddy?</summary>
<details>
<summary>Why Caddy?</summary>

Trust me on this one. It's way easier to use than Nginx, and also plain better. Creating a website in Caddy is as simple as adding 4 lines to `/etc/caddy/Caddyfile`:
Trust me on this one. It's way easier to use than Nginx, and also plain better. Creating a website in Caddy is as simple as adding 4 lines to `/etc/caddy/Caddyfile`:

```text
example.com {
root * /var/www/html
file_server
}
```
```text
example.com {
root * /var/www/html
file_server
}
```

Simply doing this creates the website, grabs an SSL certificate, and everything is configured with very sane/modern defaults (HTTP/2 and HTTP/3, automatic HTTPS redirects, [etc.](https://caddyserver.com/features)).

With Nginx, you'd have to at minimum configure `/etc/nginx/nginx.conf`, `/etc/nginx/sites-enabled/your-website.conf`, **and** install Certbot, set up your certificates and renewal jobs; and chances are it still won't be configured as good as it could be unless you've taken the time to tweak every Nginx setting. Boo.

</details>

2. Download a customized build of Caddy:

```
wget https://github.com/jonaharagon/caddy-build/releases/latest/download/caddy-linux-amd64
```

- You can get a copy of this from anywhere, like go to https://caddyserver.com/download, search for "umami", select that plugin to add it to the build, and download Caddy from that website instead. **But** that download site has been unreliable lately, so that's why I'm linking to a pre-built one.

Simply doing this creates the website, grabs an SSL certificate, and everything is configured with very sane/modern defaults (HTTP/2 and HTTP/3, automatic HTTPS redirects, [etc.](https://caddyserver.com/features)).
3. Now we have to replace the Caddy we just installed with a custom version which includes the [caddy-umami](https://github.com/jonaharagon/caddy-umami) plugin:

With Nginx, you'd have to at minimum configure `/etc/nginx/nginx.conf`, `/etc/nginx/sites-enabled/your-website.conf`, **and** install Certbot, set up your certificates and renewal jobs; and chances are it still won't be configured as good as it could be unless you've taken the time to tweak every Nginx setting. Boo.
```
sudo dpkg-divert --divert /usr/bin/caddy.default --rename /usr/bin/caddy
chmod +x caddy-linux-arm64
sudo mv ./caddy-linux-arm64 /usr/bin/caddy.custom
sudo update-alternatives --install /usr/bin/caddy caddy /usr/bin/caddy.default 10
sudo update-alternatives --install /usr/bin/caddy caddy /usr/bin/caddy.custom 50
sudo systemctl restart caddy
```

</details>
- There's an explanation of what these commands do [here](https://caddyserver.com/docs/build#package-support-files-for-custom-builds-for-debianubunturaspbian).

## Step 3. Create User

Expand Down
20 changes: 20 additions & 0 deletions docs/server/updates.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Server Updates

## Caddy Updates

After installing a customized build of Caddy `apt` will no longer give you Caddy updates, unfortunately. To update caddy, you can run [`caddy upgrade`](https://caddyserver.com/docs/command-line#caddy-upgrade):

```
caddy upgrade
systemctl restart caddy
```

Alternatively (i.e. if that doesn't work) you can download a [pre-built copy of Caddy](https://github.com/jonaharagon/caddy-build/releases/latest) which includes the modules you have installed:

```
wget https://github.com/jonaharagon/caddy-build/releases/latest/download/caddy-linux-amd64
chmod +x caddy-linux-arm64
sudo mv ./caddy-linux-arm64 /usr/bin/caddy.custom
caddy validate --config /etc/caddy/Caddyfile
systemctl restart caddy
```