Skip to content

Commit 5bc3e38

Browse files
committed
plausible analytics & traefik - initial commit
1 parent 0d06811 commit 5bc3e38

File tree

11 files changed

+364
-0
lines changed

11 files changed

+364
-0
lines changed

traefik-plausible/README.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# docker-compose Traefik & Plausible
2+
3+
Plausible is an analytics tools for your website, with a lightweight script, GPDR compliant and simple. It is less complicated than Matomo, but there is less functionnality. To have more informations at [plausible website](https://plausible.io/simple-web-analytics).
4+
5+
## :factory: Requirements
6+
7+
* linux host (tested successfully on Ubuntu 20.04 && 22.04, Debian 10 & 11)
8+
* docker >= 23.x
9+
* docker compose (plugin) >= 2.17.x
10+
11+
## :rocket: How to use
12+
13+
Clone this repo where you want with this line :
14+
15+
```bash
16+
git clone https://github.com/Mettmett/docker-compose.git:traefik-plausible
17+
```
18+
19+
You need to edit files `plausible-conf.env` and `.env` at the source folder to modify the values of some vars.
20+
21+
After that when you're all set, press the red button to initiate :fire: !
22+
23+
```bash
24+
docker compose pull && docker compose up -d && docker compose logs -f
25+
```
26+
27+
## :star: Author
28+
29+
Made by Julien HOMMET :fr: for [my personnal website](https://j.hommet.net)
30+
31+
* Twitter: [@mettmettz](https://twitter.com/mettmettz)
32+
* GitHub: [Mettmett](https://github.com/Mettmett)
33+
34+
## :wrench: Support & Contribution
35+
36+
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
37+
38+
## :moneybag: Licence
39+
40+
[CC BY-NC-SA](https://creativecommons.org/licenses/by-nc-sa/4.0)
41+
42+
## :anchor: Misc
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<yandex>
2+
<logger>
3+
<level>warning</level>
4+
<console>true</console>
5+
</logger>
6+
7+
<!-- Stop all the unnecessary logging -->
8+
<query_thread_log remove="remove"/>
9+
<query_log remove="remove"/>
10+
<text_log remove="remove"/>
11+
<trace_log remove="remove"/>
12+
<metric_log remove="remove"/>
13+
<asynchronous_metric_log remove="remove"/>
14+
</yandex>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<yandex>
2+
<profiles>
3+
<default>
4+
<log_queries>0</log_queries>
5+
<log_query_threads>0</log_query_threads>
6+
</default>
7+
</profiles>
8+
</yandex>

traefik-plausible/conf/acme.json

Whitespace-only changes.

traefik-plausible/conf/traefik.yml

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
---
2+
global:
3+
sendAnonymousUsage: true
4+
checkNewVersion: false
5+
6+
api:
7+
#insecure: true
8+
dashboard: true
9+
#debug: true
10+
11+
log:
12+
filePath: "/etc/traefik/applog.log"
13+
format: json
14+
level: "ERROR"
15+
16+
providers:
17+
docker:
18+
#endpoint: unix:///var/run/docker.sock
19+
endpoint: tcp://dockerproxy:2375
20+
network: dockerproxynet
21+
exposedByDefault: false
22+
watch: true
23+
swarmMode: false
24+
file:
25+
directory: "/etc/traefik/dynamic"
26+
watch: true
27+
28+
entryPoints:
29+
web:
30+
address: ":80"
31+
http:
32+
redirections:
33+
entryPoint:
34+
to: websecure
35+
scheme: https
36+
websecure:
37+
address: ":443"
38+
metrics:
39+
address: ":9090"
40+
ping:
41+
address: ":8082"
42+
43+
ping:
44+
entryPoint: "ping"
45+
46+
certificatesResolvers:
47+
letsencrypt:
48+
acme:
49+
email: mail@domain.name
50+
# caServer: https://acme-staging-v02.api.letsencrypt.org/directory
51+
caServer: https://acme-v02.api.letsencrypt.org/directory
52+
storage: acme.json
53+
keyType: EC256
54+
httpChallenge:
55+
entryPoint: web
56+
57+
metrics:
58+
prometheus:
59+
entryPoint: metrics
60+
addEntryPointsLabels: true
61+
addRoutersLabels: true
62+
addServicesLabels: true
63+
buckets:
64+
- 0.1
65+
- 0.3
66+
- 1.2
67+
- 5.0
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
---
2+
tls:
3+
options:
4+
default:
5+
minVersion: VersionTLS12
6+
sniStrict: true
7+
cipherSuites:
8+
- TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256
9+
- TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384
10+
- TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305
11+
- TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256
12+
- TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384
13+
- TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305
14+
- TLS_AES_128_GCM_SHA256
15+
- TLS_AES_256_GCM_SHA384
16+
- TLS_CHACHA20_POLY1305_SHA256
17+
curvePreferences:
18+
- CurveP521
19+
- CurveP384
20+
alpnProtocols:
21+
- h2
22+
- http/1.1
23+
mintls13:
24+
minVersion: VersionTLS13
25+
26+
http:
27+
middlewares:
28+
security:
29+
headers:
30+
accessControlAllowMethods:
31+
- GET
32+
- OPTIONS
33+
- PUT
34+
accessControlMaxAge: 100
35+
addVaryHeader: true
36+
browserXssFilter: true
37+
contentTypeNosniff: true
38+
forceSTSHeader: true
39+
frameDeny: true
40+
sslRedirect: true
41+
sslForceHost: true
42+
stsPreload: true
43+
customFrameOptionsValue: SAMEORIGIN
44+
referrerPolicy: "same-origin"
45+
featurePolicy: "camera 'none'; microphone 'none'; payment 'none'; usb 'none';"
46+
stsSeconds: 315360000
47+
hostsProxyHeaders:
48+
- "X-Forwarded-Host"
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
---
2+
http:
3+
routers:
4+
rt-traefik:
5+
entryPoints:
6+
- websecure
7+
service: api@internal
8+
rule: Host (`traefik.domain.name`)
9+
tls:
10+
options: default
11+
certResolver: letsencrypt
12+
13+
rt-plausible:
14+
entryPoints:
15+
- websecure
16+
middlewares:
17+
- security
18+
service: sc-plausible
19+
rule: Host (`plausible.domain.local`)
20+
tls:
21+
certResolver: letsencrypt
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
http:
3+
services:
4+
sc-plausible:
5+
loadBalancer:
6+
servers:
7+
- url: "http://plausible:8000"

traefik-plausible/docker-compose.yml

Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
---
2+
3+
services:
4+
dockerproxy:
5+
image: tecnativa/docker-socket-proxy:edge
6+
restart: always
7+
container_name: dockerproxy
8+
networks:
9+
- dockerproxynet
10+
volumes:
11+
- /var/run/docker.sock:/var/run/docker.sock:ro
12+
environment:
13+
LOG_LEVEL: info
14+
# 0 to revoke access / 1 to grant access.
15+
## Granted by Default
16+
EVENTS: 1
17+
PING: 1
18+
VERSION: 1
19+
## Revoked by Default
20+
# Security critical
21+
AUTH: 0
22+
SECRETS: 0
23+
# Not always needed
24+
BUILD: 0
25+
COMMIT: 0
26+
CONFIGS: 0
27+
CONTAINERS: 1 # Traefik, portainer, etc.
28+
DISTRIBUTION: 0
29+
EXEC: 0
30+
IMAGES: 1 # Portainer
31+
INFO: 1 # Portainer
32+
NETWORKS: 1 # Portainer
33+
NODES: 0
34+
PLUGINS: 0
35+
SERVICES: 1 # Portainer
36+
SESSION: 0
37+
SWARM: 0
38+
SYSTEM: 0
39+
TASKS: 1 # Portainer
40+
VOLUMES: 1 # Portainer
41+
TZ: "Europe/Paris"
42+
43+
traefik:
44+
image: traefik:saintmarcelin
45+
restart: unless-stopped
46+
container_name: traefik
47+
networks:
48+
- dockerproxynet
49+
ports:
50+
- target : 80
51+
published : 80
52+
protocol: tcp
53+
mode : host
54+
- target : 443
55+
published : 443
56+
protocol: tcp
57+
mode : host
58+
volumes:
59+
- ./conf/acme.json:/acme.json
60+
- ./conf/traefik.yml:/etc/traefik/traefik.yml:ro
61+
- ./conf/traefikdynamic:/etc/traefik/dynamic:ro
62+
- ./logs/traefik.log:/etc/traefik/applog.log
63+
- /etc/localtime:/etc/localtime:ro
64+
#- /var/run/docker.sock:/var/run/docker.sock:ro
65+
environment:
66+
TZ: "Europe/Paris"
67+
healthcheck:
68+
test: ["CMD", "traefik", "healthcheck", "--ping"]
69+
interval: 10s
70+
timeout: 5s
71+
retries: 3
72+
mem_limit: 256m
73+
mem_reservation: 128m
74+
depends_on:
75+
- dockerproxy
76+
77+
plausible_mail:
78+
image: bytemark/smtp
79+
container_name: plausible_mail
80+
restart: unless-stopped
81+
environment:
82+
RELAY_HOST: mail.domain.local
83+
RELAY_PORT: 587
84+
RELAY_USERNAME: changeme@domain.local
85+
RELAY_PASSWORD: changeme
86+
TZ: Europe/Paris
87+
volumes:
88+
- /etc/localtime:/etc/localtime:ro
89+
mem_limit: 128m
90+
mem_reservation: 64m
91+
92+
plausible_db:
93+
image: postgres:14-alpine
94+
container_name: plausible_db
95+
restart: unless-stopped
96+
volumes:
97+
- db-data:/var/lib/postgresql/data
98+
- /etc/localtime:/etc/localtime:ro
99+
environment:
100+
POSTGRES_USER: plausibledbuser
101+
POSTGRES_PASSWORD: plausibledbpassword
102+
POSTGRES_DB: plausibledb
103+
TZ: Europe/Paris
104+
105+
plausible_events_db:
106+
image: clickhouse/clickhouse-server:22.6-alpine
107+
container_name: plausible_events_db
108+
restart: unless-stopped
109+
volumes:
110+
- event-data:/var/lib/clickhouse
111+
- ./clickhouse/clickhouse-config.xml:/etc/clickhouse-server/config.d/logging.xml:ro
112+
- ./clickhouse/clickhouse-user-config.xml:/etc/clickhouse-server/users.d/logging.xml:ro
113+
- /etc/localtime:/etc/localtime:ro
114+
environment:
115+
TZ: Europe/Paris
116+
ulimits:
117+
nofile:
118+
soft: 262144
119+
hard: 262144
120+
121+
plausible:
122+
image: plausible/analytics:latest
123+
container_name: plausible
124+
restart: unless-stopped
125+
command: sh -c "sleep 10 && /entrypoint.sh db createdb && /entrypoint.sh db migrate && /entrypoint.sh db init-admin && /entrypoint.sh run"
126+
depends_on:
127+
- plausible_db
128+
- plausible_events_db
129+
- plausible_mail
130+
env_file:
131+
- plausible-conf.env
132+
volumes:
133+
- /etc/localtime:/etc/localtime:ro
134+
environment:
135+
TZ: Europe/Paris
136+
137+
volumes:
138+
db-data:
139+
driver: local
140+
event-data:
141+
driver: local
142+
geoip:
143+
driver: local
144+
145+
networks:
146+
dockerproxynet:
147+
name: dockerproxynet
148+
ipam:
149+
config:
150+
- subnet: 172.16.10.0/24

traefik-plausible/logs/traefik.log

Whitespace-only changes.

0 commit comments

Comments
 (0)