fix: [plausible, clickhouse] close the /storybook code execution (Plausible 3.2.1) and apply ClickHouse low-memory settings #2
@@ -4,4 +4,23 @@
|
||||
|
||||
This charm is provided to work with plausible charm
|
||||
|
||||
* Usage
|
||||
Configuration files come from
|
||||
https://github.com/plausible/community-edition/ (=clickhouse/=).
|
||||
|
||||
* Usage
|
||||
|
||||
Added automatically by the =plausible= charm (=event-db= relation).
|
||||
|
||||
* Low memory settings
|
||||
|
||||
- =config.d/low-resources.xml=: server settings (=mark_cache_size=).
|
||||
- =users.d/default-profile-low-resources-overrides.xml=: settings of the
|
||||
=default= profile (=max_threads= 1, …). ClickHouse reads profiles
|
||||
only from users configuration files: in =config.d= they were ignored.
|
||||
|
||||
Check that they apply:
|
||||
|
||||
#+begin_src sh
|
||||
docker exec <container> clickhouse-client -q \
|
||||
"SELECT name, value FROM system.settings WHERE name = 'max_threads'"
|
||||
#+end_src
|
||||
|
||||
@@ -9,6 +9,9 @@ charm-resources:
|
||||
- /etc/clickhouse-server/config.d/logs.xml
|
||||
- /etc/clickhouse-server/config.d/ipv4-only.xml
|
||||
- /etc/clickhouse-server/config.d/low-resources.xml
|
||||
## Profile settings are only read from users.d (they were ignored when
|
||||
## they lived in config.d/low-resources.xml).
|
||||
- /etc/clickhouse-server/users.d/default-profile-low-resources-overrides.xml
|
||||
|
||||
provides:
|
||||
event-db:
|
||||
|
||||
@@ -1,23 +1,4 @@
|
||||
<!-- https://clickhouse.com/docs/en/operations/tips#using-less-than-16gb-of-ram -->
|
||||
<clickhouse>
|
||||
<!--
|
||||
https://clickhouse.com/docs/en/operations/server-configuration-parameters/settings#mark_cache_size -->
|
||||
<!-- https://clickhouse.com/docs/en/operations/server-configuration-parameters/settings#mark_cache_size -->
|
||||
<mark_cache_size>524288000</mark_cache_size>
|
||||
|
||||
<profile>
|
||||
<default>
|
||||
<!-- https://clickhouse.com/docs/en/operations/settings/settings#max_threads -->
|
||||
<max_threads>1</max_threads>
|
||||
<!-- https://clickhouse.com/docs/en/operations/settings/settings#max_block_size -->
|
||||
<max_block_size>8192</max_block_size>
|
||||
<!-- https://clickhouse.com/docs/en/operations/settings/settings#max_download_threads -->
|
||||
<max_download_threads>1</max_download_threads>
|
||||
<!--
|
||||
https://clickhouse.com/docs/en/operations/settings/settings#input_format_parallel_parsing -->
|
||||
<input_format_parallel_parsing>0</input_format_parallel_parsing>
|
||||
<!--
|
||||
https://clickhouse.com/docs/en/operations/settings/settings#output_format_parallel_formatting -->
|
||||
<output_format_parallel_formatting>0</output_format_parallel_formatting>
|
||||
</default>
|
||||
</profile>
|
||||
</clickhouse>
|
||||
</clickhouse>
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
<!-- https://clickhouse.com/docs/en/operations/tips#using-less-than-16gb-of-ram -->
|
||||
<clickhouse>
|
||||
<profiles>
|
||||
<default>
|
||||
<!-- https://clickhouse.com/docs/en/operations/settings/settings#max_threads -->
|
||||
<max_threads>1</max_threads>
|
||||
<!-- https://clickhouse.com/docs/en/operations/settings/settings#max_block_size -->
|
||||
<max_block_size>8192</max_block_size>
|
||||
<!-- https://clickhouse.com/docs/en/operations/settings/settings#max_download_threads -->
|
||||
<max_download_threads>1</max_download_threads>
|
||||
<!--
|
||||
https://clickhouse.com/docs/en/operations/settings/settings#input_format_parallel_parsing -->
|
||||
<input_format_parallel_parsing>0</input_format_parallel_parsing>
|
||||
<!--
|
||||
https://clickhouse.com/docs/en/operations/settings/settings#output_format_parallel_formatting -->
|
||||
<output_format_parallel_formatting>0</output_format_parallel_formatting>
|
||||
</default>
|
||||
</profiles>
|
||||
</clickhouse>
|
||||
@@ -4,4 +4,40 @@
|
||||
|
||||
From: https://github.com/plausible/community-edition/
|
||||
|
||||
* Usage
|
||||
* Usage
|
||||
|
||||
#+begin_src yaml
|
||||
plausible:
|
||||
relations:
|
||||
web-proxy:
|
||||
frontend:
|
||||
domain: stats.example.com
|
||||
#+end_src
|
||||
|
||||
A =clickhouse= (statistics) and a =postgres= (accounts, sites) service
|
||||
are added automatically.
|
||||
|
||||
* Security
|
||||
|
||||
- Plausible before 3.2.1 serves =/storybook=, which runs any code sent
|
||||
to it without authentication (CVE-2026-8467, GHSA-mhcv-h7gf-57cf).
|
||||
This charm uses 3.2.1, and its default web-proxy rules refuse
|
||||
=/storybook= in case an older image is deployed again.
|
||||
- The Erlang release cookie of the image is generated when the image is
|
||||
built, so it is the same for every installation. The charm generates
|
||||
its own (=release-cookie= in the service datastore) and sets
|
||||
=RELEASE_DISTRIBUTION= to =none=: this single node opens no =epmd= nor
|
||||
Erlang distribution port.
|
||||
|
||||
* Upgrading from 3.0.x
|
||||
|
||||
- Migrations run at each start (=db migrate= in the entrypoint), for
|
||||
both PostgreSQL and ClickHouse. They cannot be reverted: back up both
|
||||
databases first.
|
||||
- Deploy together with the =clickhouse= charm of the same revision: the
|
||||
ClickHouse low-memory profile moved to =users.d= (upstream change of
|
||||
3.2.0).
|
||||
- Sites keep working with their existing tracking snippet.
|
||||
- Changing =secret-key= signs everybody out, invalidates every API key,
|
||||
and makes the 2FA secrets unreadable unless =TOTP_VAULT_KEY= is set
|
||||
to the key derived from the previous one.
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
#!/bin/bash
|
||||
|
||||
SECRET_KEY_BASE="$SERVICE_DATASTORE"/secret-key
|
||||
## Erlang release cookie. The image ships one in ``/app/releases/COOKIE``
|
||||
## that is generated when the image is built, so it is the same for every
|
||||
## installation of that image: replace it by one of our own.
|
||||
RELEASE_COOKIE_FILE="$SERVICE_DATASTORE"/release-cookie
|
||||
|
||||
SHARE_DIR="$SERVICE_DATASTORE"/var/lib/plausible
|
||||
mkdir -p $SHARE_DIR
|
||||
@@ -16,12 +20,25 @@ else
|
||||
info "Using existing secret key"
|
||||
fi
|
||||
|
||||
secret_key_base=$(cat "$SECRET_KEY_BASE")
|
||||
if ! [ -f "$RELEASE_COOKIE_FILE" ]; then
|
||||
info "Generating Erlang release cookie"
|
||||
mkdir -p "${RELEASE_COOKIE_FILE%/*}"
|
||||
(umask 077; openssl rand -hex 32 > "$RELEASE_COOKIE_FILE")
|
||||
fi
|
||||
|
||||
secret_key_base=$(cat "$SECRET_KEY_BASE")
|
||||
release_cookie=$(cat "$RELEASE_COOKIE_FILE")
|
||||
|
||||
## ``RELEASE_DISTRIBUTION: none``: Plausible Community Edition runs a
|
||||
## single node and never needs Erlang distribution (the ``db createdb`` and
|
||||
## ``db migrate`` commands use ``eval``), so the node opens no ``epmd`` nor
|
||||
## distribution port that anything else could connect to.
|
||||
init-config-add "
|
||||
$SERVICE_NAME:
|
||||
environment:
|
||||
SECRET_KEY_BASE: \"$secret_key_base\"
|
||||
RELEASE_COOKIE: \"$release_cookie\"
|
||||
RELEASE_DISTRIBUTION: \"none\"
|
||||
"
|
||||
|
||||
chown -v "$uid" "$SHARE_DIR"
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
docker-image: docker.0k.io/plausible:3.0.1
|
||||
#docker-image: ghcr.io/plausible/community-edition:v3.0.1
|
||||
## 3.2.1 or later is required: earlier versions expose ``/storybook``,
|
||||
## an unauthenticated remote code execution (CVE-2026-8467).
|
||||
docker-image: docker.0k.io/plausible:3.2.1 ## from: ghcr.io/plausible/community-edition:v3.2.1
|
||||
|
||||
data-resources:
|
||||
- /var/lib/plausible
|
||||
@@ -49,6 +50,11 @@ uses:
|
||||
RewriteCond %{HTTP:Connection} upgrade [NC]
|
||||
RewriteRule ^/(live/websocket)$ ws://${MASTER_BASE_SERVICE_NAME}:8000/\$1 [P,L]
|
||||
|
||||
## Plausible < 3.2.1 runs any code sent to /storybook
|
||||
## (CVE-2026-8467). 3.2.1 removed it; keep it closed in case
|
||||
## an older image is ever deployed again.
|
||||
RewriteRule ^/storybook(/|$) - [F,L]
|
||||
|
||||
|
||||
backup:
|
||||
constraint: recommended
|
||||
|
||||
Reference in New Issue
Block a user