@@ -49,7 +49,7 @@ services:
4949 - " traefik.http.routers.wsc-https.entrypoints=websecure"
5050 - " traefik.http.routers.wsc-https.service=wsc"
5151 # load middlewares for routes
52- - " traefik.http.routers.wsc-http.middlewares=wsc-https"
52+ - " traefik.http.routers.wsc-http.middlewares=wsc-https@docker "
5353 # - "traefik.http.routers.wsc-https.middlewares="
5454 # http to https redirect
5555 - " traefik.http.middlewares.wsc-https.redirectscheme.scheme=https"
@@ -66,6 +66,7 @@ services:
6666 volumes :
6767 - ./data-db:/var/lib/mysql:rw
6868 - ./config/mysql_wsc.cnf:/etc/mysql/conf.d/70-wsc.cnf:ro
69+ - ./config/mysql_exporter-user.sh:/docker-entrypoint-initdb.d/20_exporter-user.sh:ro
6970 environment :
7071 TZ : " ${TIMEZONE:-Europe/Berlin}"
7172 MARIADB_ROOT_PASSWORD : " ${MYSQL_ROOT_PASSWORD}"
@@ -74,11 +75,15 @@ services:
7475 MARIADB_PASSWORD : " ${MYSQL_PASSWORD}"
7576 MARIADB_MYSQL_LOCALHOST_USER : " true"
7677 # MARIADB_AUTO_UPGRADE: 1
78+ # Exporter (mounted by script)
79+ EXPORTER_USER : " ${MYSQL_EXPORTER_USER}"
80+ EXPORTER_PASSWORD : " ${MYSQL_EXPORTER_PASSWORD}"
81+ # EXPORTER_MAXUSERCONNECTIONS: "3"
7782 # ports:
7883 # - 127.0.0.1:3306:3306/tcp
7984 healthcheck :
80- test : mysqladmin ping -h 127.0.0.1 -u root --password=$$MARIADB_ROOT_PASSWORD || exit 1
81- # test: mysqladmin ping -h 127.0.0.1 -u $$MARIADB_USER --password=$$MARIADB_PASSWORD || exit 1
85+ test : mariadb-admin ping -h 127.0.0.1 -u root --password=$$MARIADB_ROOT_PASSWORD || exit 1
86+ # test: mariadb-admin ping -h 127.0.0.1 -u $$MARIADB_USER --password=$$MARIADB_PASSWORD || exit 1
8287 # start_period: 10s
8388 interval : 30s
8489 timeout : 5s
@@ -89,10 +94,173 @@ services:
8994 - wsc-database
9095 - wsc-mysql
9196 - wsc-mariadb
97+ # check with: "docker inspect --format='{{json .State.Health}}' wsc-db | jq"
98+
99+ # # https://github.com/prometheus/mysqld_exporter
100+ # wsc-db-exporter:
101+ # image: docker.io/prom/mysqld-exporter:latest # quay.io/prometheus/mysqld-exporter:latest
102+ # container_name: wsc-db-exporter
103+ # restart: unless-stopped
104+ # command:
105+ # - --web.listen-address=:9104
106+ # - --web.telemetry-path=/metrics
107+ # - --mysqld.address=wsc-db:3306
108+ # - --mysqld.username=${MYSQL_EXPORTER_USER}
109+ # - --log.level=info
110+ # environment:
111+ # MYSQLD_EXPORTER_PASSWORD: ${MYSQL_EXPORTER_PASSWORD}
112+ # ports:
113+ # - 127.0.0.1:9104:9104/tcp
114+ # networks:
115+ # - wsc-net
116+ # #- monitoring-net
117+ # depends_on:
118+ # wsc-db:
119+ # condition: service_started # service_started or service_healthy
120+ # # Test: curl http://localhost:9104/metrics
121+ #
122+ # # https://github.com/Lusitaniae/apache_exporter
123+ # wsc-apache-exporter:
124+ # image: docker.io/lusotycoon/apache-exporter:latest # quay.io/lusitaniae/apache-exporter:latest
125+ # container_name: wsc-apache-exporter
126+ # restart: unless-stopped
127+ # command:
128+ # - --web.listen-address=:9117
129+ # - --telemetry.endpoint=/metrics
130+ # - --scrape_uri='http://wsc-php:80/server-status?auto'
131+ # - --log.level=info
132+ # ports:
133+ # - 127.0.0.1:9117:9117/tcp
134+ # networks:
135+ # - wsc-net
136+ # #- monitoring-net
137+ # depends_on:
138+ # wsc-php:
139+ # condition: service_started
140+ # # Test: curl http://127.0.0.1:9117/metrics
141+
142+ # https://hub.docker.com/_/traefik
143+ # https://github.com/traefik/traefik/
144+ # Docs: https://doc.traefik.io/traefik/
145+ traefik :
146+ image : docker.io/library/traefik:3
147+ container_name : traefik
148+ restart : unless-stopped
149+ environment :
150+ - TZ="${TIMEZONE:-Europe/Berlin}"
151+ ports :
152+ - " 80:80/tcp" # http
153+ - " 443:443/tcp" # https (tcp)
154+ - " 443:443/udp" # https (udp) / HTTP3
155+ - " 127.0.0.1:8082:8082/tcp" # Traefik Metrics
156+ # - "127.0.0.1:8080:8080/tcp" # Traefik Dashboard (if insecure enabled)
157+ command :
158+ # Entrypoints and Ports
159+ - " --entrypoints.web.address=:80"
160+ - " --entrypoints.websecure.address=:443"
161+ - " --entryPoints.websecure.http3"
162+ # - "--entryPoints.websecure.http3.advertisedport=443"
163+ - " --entryPoints.traefik.address=:8080"
164+ - " --entryPoints.metrics.address=:8082"
165+ # Monitoring (Prometheus and Ping)
166+ - " --entryPoints.metrics.address=:8082"
167+ - " --metrics.prometheus=true"
168+ - " --metrics.prometheus.entryPoint=metrics"
169+ - " --metrics.prometheus.buckets=0.1,0.3,1.2,5.0"
170+ - " --metrics.prometheus.addEntryPointsLabels=true"
171+ - " --metrics.prometheus.addrouterslabels=true"
172+ - " --metrics.prometheus.addServicesLabels=true"
173+ - " --ping=true"
174+ - " --ping.entryPoint=metrics"
175+ # API and Dashboard
176+ - " --api=true"
177+ - " --api.dashboard=true"
178+ - " --api.basePath=/traefik"
179+ # - "--api.insecure=true"
180+ # Log and AccessLog
181+ - " --log.level=ERROR" # TRACE, DEBUG, INFO, WARN, ERROR, FATAL, and PANIC
182+ - " --log.format=common" # common, json
183+ - " --accesslog=true"
184+ - " --accesslog.format=common" # common, genericCLF , json
185+ - " --accesslog.addinternals"
186+ - " --accesslog.fields.names.StartUTC=drop" # TimeZone (set to "drop", for use from env)
187+ # ServersTransport (internal/backend CA-Cert/SSL)
188+ - " --serversTransport.insecureSkipVerify=true"
189+ # - "--serversTransport.rootCAs=/config/certs/ca.crt"
190+ # Dynamic Configs
191+ - " --providers.file.directory=/config/dynamic"
192+ - " --providers.file.watch=true"
193+ # Optional: Plugins <https://plugins.traefik.io/plugins>
194+ # https://plugins.traefik.io/plugins/62947307108ecc83915d7783/rewrite-body
195+ # - "--experimental.plugins.rewrite.modulename=github.com/traefik/plugin-rewritebody"
196+ # - "--experimental.plugins.rewrite.version=v0.3.1"
197+ # https://plugins.traefik.io/plugins/62947354108ecc83915d778e/block-path
198+ # - "--experimental.plugins.block.modulename=github.com/traefik/plugin-blockpath"
199+ # - "--experimental.plugins.block.version=v0.2.1"
200+ # https://plugins.traefik.io/plugins/62947302108ecc83915d7781/geoblock
201+ # - "--experimental.plugins.geoblock.modulename=github.com/nscuro/traefik-plugin-geoblock"
202+ # - "--experimental.plugins.geoblock.version=v0.14.0"
203+ # Docker Provider (Traefik must run as root)
204+ - " --providers.docker=true"
205+ # - "--providers.docker.endpoint=unix:///var/run/docker.sock"
206+ - " --providers.docker.exposedbydefault=false"
207+ # - "--providers.docker.network=traefik"
208+ volumes :
209+ - /var/run/docker.sock:/var/run/docker.sock:ro # docker.sock for read labels
210+ - ./config/traefik/dynamic/:/config/dynamic/:ro # dynamic config files
211+ - ./ssl-certs/:/config/certs/:ro # ssl certs files
212+ networks :
213+ - traefik-net
214+ healthcheck :
215+ test : ['CMD', 'traefik', 'healthcheck', '--ping', "--entryPoints.ping.address=:8082", "--ping.entryPoint=ping"]
216+ # start_period: 10s
217+ interval : 30s
218+ timeout : 5s
219+ retries : 3
220+ # check with: "docker inspect --format='{{json .State.Health}}' traefik | jq"
221+ labels :
222+ # Explicitly tell Traefik to expose this container
223+ - " traefik.enable=true"
224+ - " traefik.docker.network=traefik-net"
225+ # http
226+ - " traefik.http.routers.traefik-http.rule=Host(`${DOMAIN}`) && PathPrefix(`/traefik`)"
227+ - " traefik.http.routers.traefik-http.entrypoints=web"
228+ - " traefik.http.routers.traefik-http.service=api@internal"
229+ # https
230+ - " traefik.http.routers.traefik-https.tls=true"
231+ - " traefik.http.routers.traefik-https.rule=Host(`${DOMAIN}`) && PathPrefix(`/traefik`)"
232+ - " traefik.http.routers.traefik-https.entrypoints=websecure"
233+ - " traefik.http.routers.traefik-https.service=api@internal"
234+ # load middlewares for routes
235+ - " traefik.http.routers.traefik-http.middlewares=traefik-https@docker,traefik-auth@docker"
236+ - " traefik.http.routers.traefik-https.middlewares=traefik-auth@docker"
237+ # Middleware: http to https redirect
238+ - " traefik.http.middlewares.traefik-https.redirectscheme.scheme=https"
239+ - " traefik.http.middlewares.traefik-https.redirectscheme.permanent=true"
240+ # - "traefik.http.middlewares.traefik-https.redirectscheme.port=443"
241+ # Middleware: auth
242+ # basic auth with htpasswd (You may need to escape any $ with another $ in password. create password: "docker run --rm tobi312/tools:htpasswd -bn admin 'passw0rd' | sed 's/\$/\$\$/g'" OR only for Password: "openssl passwd -apr1 'passw0rd' | sed 's/\$/\$\$/g'")
243+ - " traefik.http.middlewares.traefik-auth.basicauth.users=admin:$$apr1$$6Yq5UCPq$$ZmXnIrJwqH0qfKRurLAiR1,traefik:$$apr1$$zIohxmBm$$TVYfYKcqYXOdONsU93L8w0"
244+ # URL for Webbrowser: https://example.com/traefik
92245
93246networks :
94247 wsc-net :
95248 name : wsc-net
249+ # monitoring-net:
250+ # name: monitoring-net
251+ # external: true
96252 traefik-net :
97253 name : traefik-net
98- external : true
254+ # external, script? https://github.com/Tob1as/docker-kubernetes-collection/blob/master/examples_docker-compose/docker_network_create.sh
255+ # external: true
256+ # not external, but with IPv4 and IPv6:
257+ # driver: bridge
258+ # attachable: true
259+ # enable_ipv6: true
260+ # labels:
261+ # created.by: "docker-compose_WSC"
262+ # ipam:
263+ # driver: default
264+ # config:
265+ # - subnet: 172.20.0.0/24 # IPv4 Subnet
266+ # - subnet: fd00:dead:beef::/48 # IPv6 Subnet
0 commit comments