Compare commits

...

10 commits

Author SHA1 Message Date
Florian Lüke
8201045013 add forgejo alias, disable nextcloud containers 2024-12-16 13:56:56 +01:00
Florian Lüke
a41b7174f4 crowdsec, timezones, prometheus 2024-12-16 13:38:46 +01:00
Florian Lüke
0c8bc1ac0a add crowdsec and crowdsec-bashboard (no bouncers)
Basic crowdsec and metabase dashboard setup is done. journalctl ssh
monitoring and alerts work. Need to check if other log sources work.

No bouncers active yet!
2023-10-15 18:29:32 +02:00
Florian Lüke
32c3b5352d use subdommains; make nextcloud log external IPs 2023-10-15 18:28:42 +02:00
Florian Lüke
a67bc93c87 pin nextcloud to v27 2023-10-15 18:27:36 +02:00
Florian Lüke
70941ceccd dms: disable traefik for the container 2023-10-15 18:26:47 +02:00
Florian Lüke
08123757cd prometheus: move node-exporter to the host network for accurate traffic stats 2023-09-17 17:11:09 +02:00
Florian Lüke
402ffae6e7 mailserver: set postfix message size limit to 100MB 2023-09-17 17:09:59 +02:00
Florian Lüke
4cb6d236f2 shorten prometheus scrape interval from 30s to 15s 2023-09-17 01:14:15 +02:00
Florian Lüke
daffa05b4d add disabled docker/metrics setup 2023-09-11 20:10:39 +02:00
12 changed files with 123 additions and 34 deletions

View file

@ -1,3 +1,3 @@
wireguard and traefik on the same vpn network
add traefik entry point to the vpn network
only enable api and dashboard on the internal networl
TODO
====
* Try out cAdvisor and a dashboard like 10619

View file

@ -0,0 +1,9 @@
source: docker
container_name:
- nextcloud-app
- forgejo-app
- prometheus
- grafana
- mailserver
labels:
type: syslog

View file

@ -0,0 +1,5 @@
source: journalctl
journalctl_filter:
- "_SYSTEMD_UNIT=ssh.service"
labels:
type: syslog

View file

@ -0,0 +1,5 @@
source: file
filenames:
- /run/logs/nextcloud.log
labels:
type: Nextcloud

View file

@ -0,0 +1,5 @@
source: file
filenames:
- /run/logs/traefik-access.log
labels:
type: traefik

View file

View file

@ -0,0 +1,3 @@
FROM metabase/metabase
RUN mkdir /data/ && wget https://crowdsec-statics-assets.s3-eu-west-1.amazonaws.com/metabase_sqlite.zip && unzip metabase_sqlite.zip -d /data/

View file

@ -1,5 +1,3 @@
version: "3.8"
# logger driver - change this driver to ship all container logs to a different location
x-logging: &logging
logging:
@ -45,4 +43,4 @@ services:
retries: 0
<<: *logging
labels:
- "traefik.enable=true"
- "traefik.enable=false"

View file

@ -254,7 +254,7 @@ ENABLE_QUOTAS=1
# Set the message size limit for all users. If set to zero, the size will be unlimited (not recommended!)
#
# empty => 10240000 (~10 MB)
POSTFIX_MESSAGE_SIZE_LIMIT=
POSTFIX_MESSAGE_SIZE_LIMIT=104857600 # 100MB
# Mails larger than this limit won't be scanned.
# ClamAV must be enabled (ENABLE_CLAMAV=1) for this.

View file

@ -1,5 +1,3 @@
version: "3.8"
# logger driver - change this driver to ship all container logs to a different location
x-logging: &logging
logging:
@ -46,7 +44,6 @@ services:
labels:
- "traefik.enable=true"
# Make the traefik dashboard available under https://oxmox.dev/traefik/dashboard/
# For some reason it's slow when used this way. It's fast when exposed via port 8080 and api.insecure=true.
- "traefik.http.routers.traefik_api.rule=Host(`oxmox.dev`) && (PathPrefix(`/api`) || PathPrefix(`/traefik`))"
- "traefik.http.routers.traefik_api.entrypoints=websecure"
- "traefik.http.routers.traefik_api.tls.certresolver=myresolver"
@ -66,6 +63,8 @@ services:
- "traefik.http.routers.whoami.tls.certresolver=myresolver"
nextcloud-db:
profiles:
- donotstart
image: mariadb:latest
container_name: "nextcloud-db"
restart: unless-stopped
@ -105,7 +104,9 @@ services:
- "traefik.enable=false"
nextcloud-app:
image: nextcloud:latest
profiles:
- donotstart
image: nextcloud:27-apache
container_name: "nextcloud-app"
restart: unless-stopped
<<: *logging
@ -122,11 +123,11 @@ services:
- MYSQL_PASSWORD_FILE=/run/secrets/nextcloud_db_password
- MYSQL_ROOT_PASSWORD_FILE=/run/secrets/nextcloud_db_root_password
# reverse proxy setup
- APACHE_DISABLE_REWRITE_IP=1
- TRUSTED_PROXIES=192.168.128.0/24
- NEXTCLOUD_TRUSTED_DOMAINS=oxmox.dev
#- APACHE_DISABLE_REWRITE_IP=0
- TRUSTED_PROXIES="172.18.0.0/16 172.18.0.9"
- NEXTCLOUD_TRUSTED_DOMAINS=cloud.oxmox.dev
# PHP tuning
- PHP_MEMORY_LIMIT=256M # default=512M
- PHP_MEMORY_LIMIT=512M # default=512M
- PHP_UPLOAD_LIMIT=512M # default=512M
# Sadly this did not work for me.
#- NEXTCLOUD_ADMIN_USER=admin
@ -137,13 +138,11 @@ services:
- nextcloud_admin_password
labels:
- "traefik.enable=true"
- "traefik.http.routers.nextcloud_app.rule=Host(`oxmox.dev`) && PathPrefix(`/nextcloud`)"
- "traefik.http.routers.nextcloud_app.rule=Host(`cloud.oxmox.dev`)"
- "traefik.http.routers.nextcloud_app.entrypoints=websecure"
- "traefik.http.routers.nextcloud_app.tls.certresolver=myresolver"
- "traefik.http.routers.nextcloud_app.middlewares=nextcloud_app_strip"
- "traefik.http.middlewares.nextcloud_app_strip.stripprefix.prefixes=/nextcloud"
- "traefik.http.routers.nextcloud_dav.rule=Host(`oxmox.dev`) && PathPrefix(`/.well-known/`)"
- "traefik.http.routers.nextcloud_dav.rule=(Host(`cloud.oxmox.dev`) || Host(`oxmox.dev`)) && PathPrefix(`/.well-known/`)"
- "traefik.http.routers.nextcloud_dav.entrypoints=websecure"
- "traefik.http.routers.nextcloud_dav.tls.certresolver=myresolver"
- "traefik.http.routers.nextcloud_dav.middlewares=nextcloud_app_dav"
@ -151,6 +150,8 @@ services:
- "traefik.http.middlewares.nextcloud_app_dav.replacepathregex.replacement=/remote.php/dav/"
nextcloud-app-cron:
profiles:
- donotstart
image: nextcloud:latest
container_name: "nextcloud-app-cron"
restart: unless-stopped
@ -224,11 +225,9 @@ services:
- FORGEJO__database__PASSWD=forgejo1234
labels:
- "traefik.enable=true"
- "traefik.http.routers.forgejo_app.rule=Host(`oxmox.dev`) && PathPrefix(`/forge`)"
- "traefik.http.routers.forgejo_app.rule=Host(`forge.oxmox.dev`)"
- "traefik.http.routers.forgejo_app.entrypoints=websecure"
- "traefik.http.routers.forgejo_app.tls.certresolver=myresolver"
- "traefik.http.routers.forgejo_app.middlewares=forgejo_app_strip"
- "traefik.http.middlewares.forgejo_app_strip.stripprefix.prefixes=/forge"
- "traefik.http.services.forgejo-app.loadbalancer.server.port=3000"
prometheus:
@ -240,6 +239,7 @@ services:
- '--web.external-url=/prometheus/'
- '--web.route-prefix=/prometheus/'
- '--storage.tsdb.path=/prometheus/tsdb'
#- '--log.level=debug'
volumes:
- ./prometheus:/prometheus
- /etc/timezone:/etc/timezone:ro
@ -254,6 +254,9 @@ services:
- "traefik.http.routers.prometheus_app.tls.certresolver=myresolver"
- "traefik.http.routers.prometheus_app.middlewares=traefik_api_auth"
- "traefik.http.services.prometheus_app.loadbalancer.server.port=9090"
extra_hosts:
# To be able to reach node-exporter which listens on the host network.
- "host.docker.internal:host-gateway"
grafana:
image: grafana/grafana
@ -287,19 +290,15 @@ services:
container_name: node-exporter
restart: unless-stopped
<<: *logging
#network_mode: host
# Put node-exporter on the host network to get meaningful network stats.
network_mode: host
pid: host
volumes:
#- /proc:/host/proc:ro
#- /sys:/host/sys:ro
- /:/rootfs:ro,rslave
- /etc/timezone:/etc/timezone:ro
- /etc/localtime:/etc/localtime:ro
command:
#- '--path.procfs=/host/proc'
- '--path.rootfs=/rootfs'
#- '--path.sysfs=/host/sys'
#- '--collector.filesystem.mount-points-exclude=^/(sys|proc|dev|host|etc)($$|/)'
expose:
- 9100
@ -344,6 +343,65 @@ services:
labels:
- "traefik.enable=false"
crowdsec:
image: crowdsecurity/crowdsec:latest-debian
container_name: "crowdsec"
restart: unless-stopped
<<: *logging
environment:
#this is the list of collections we want to install
#https://hub.crowdsec.net/author/crowdsecurity/collections/nginx
COLLECTIONS: "crowdsecurity/traefik crowdsecurity/nextcloud"
GID: "${GID-1000}"
depends_on:
- traefik
volumes:
- ./crowdsec/acquis.d:/etc/crowdsec/acquis.d
- ./crowdsec/config.yaml.local:/etc/crowdsec/config.yaml.local
- ./crowdsec/etc:/etc/crowdsec/
- ./crowdsec/db:/var/lib/crowdsec/data/
- /etc/timezone:/etc/timezone:ro
- /etc/localtime:/etc/localtime:ro
- /var/log/journal:/run/log/journal # host journald
- /var/run/docker.sock:/var/run/docker.sock:ro # host docker
- ./traefik/logs/access.log:/run/logs/traefik-access.log:ro
- ./nextcloud-app/nextcloud/data/nextcloud.log:/run/logs/nextcloud.log:ro
# metabase, because security is cool, but dashboards are cooler
crowdsec-dashboard:
container_name: "crowdsec-dashboard"
# we're using a custom Dockerfile so that metabase pops with pre-configured dashboards
build: ./crowdsec/dashboard
restart: unless-stopped
<<: *logging
ports:
- 3000:3000
environment:
MB_DB_FILE: /data/metabase.db
MGID: "${GID-1000}"
depends_on:
- 'crowdsec'
volumes:
- ./crowdsec/db:/metabase-data/
# FIXME: as soon as I enable this the metabase config is lost and the setup wizard starts.
# If it's not enabled then everythings works and the dashboard uses the
# default app downloaded in the dockerfile. This means default user and
# password. Problem is, once the container is restarted the changes are
# lost and we're back with the default user and password.
# I do not understand why this is happening, how to debug it or anything
# else. Metabase bad :(
#- ./crowdsec/dashboard-db/:/data/
- /etc/timezone:/etc/timezone:ro
- /etc/localtime:/etc/localtime:ro
labels:
- "traefik.enable=true"
- "traefik.http.routers.crowdsec_dashboard_app.rule=Host(`oxmox.dev`) && PathPrefix(`/crowdsec`)"
- "traefik.http.routers.crowdsec_dashboard_app.entrypoints=websecure"
- "traefik.http.routers.crowdsec_dashboard_app.tls.certresolver=myresolver"
- "traefik.http.routers.crowdsec_dashboard_app.middlewares=traefik_api_auth"
- "traefik.http.routers.crowdsec_dashboard_app.middlewares=traefik_api_auth,crowdsec_dashboard_app_strip"
- "traefik.http.middlewares.crowdsec_dashboard_app_strip.stripprefix.prefixes=/crowdsec"
- "traefik.http.services.crowdsec_dashboard_app.loadbalancer.server.port=3000"
#wireguard:
# image: lscr.io/linuxserver/wireguard:latest

1
env.sh
View file

@ -1,2 +1,3 @@
alias nextcloud-occ='docker exec -it -u 33 nextcloud-app /var/www/html/occ'
alias mail-setup='docker exec -it mailserver setup'
alias forgejo='docker exec -u git -it forgejo-app forgejo'

View file

@ -1,20 +1,25 @@
global:
scrape_interval: 30s
scrape_interval: 15s
scrape_timeout: 10s
evaluation_interval: 1m
scrape_configs:
- job_name: 'traefik'
scrape_interval: 1m
static_configs:
- targets: ['traefik:8080']
- job_name: 'node'
scrape_interval: 1m
static_configs:
- targets: ['node-exporter:9100']
- targets: ['host.docker.internal:9100']
- job_name: 'loki'
scrape_interval: 1m
static_configs:
- targets: ['loki-app:3100']
- job_name: 'docker'
static_configs:
- targets: ['host.docker.internal:9323']
- job_name: 'prometheus'
static_configs:
- targets: ['localhost:9090']