bordulets

zbx

Oct 6th, 2021
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.63 KB | None | 0 0
  1. # Zabbix with Let's Encrypt in a Docker Compose
  2.  
  3. # Vladimir Mikhalev
  4. # www.heyvaldemar.com
  5.  
  6. # Install the Docker Engine by following the official guide: https://docs.docker.com/engine/install/
  7. # Install the Docker Compose by following the official guide: https://docs.docker.com/compose/install/
  8.  
  9. # Run zabbix-restore-database.sh to restore database if needed.
  10.  
  11. # Deploy Zabbix server with a Docker Compose using the command:
  12. # docker-compose -f zbx-pgs-lencrypt-docker-compose.yml -p zabbix up -d
  13.  
  14. volumes:
  15. zabbix-postgres:
  16. zabbix-postgres-backups:
  17. traefik-certificates:
  18.  
  19. services:
  20. postgres:
  21. # Image tag (replace with yours)
  22. image: postgres:13.2
  23. volumes:
  24. - zabbix-postgres:/var/lib/postgresql/data
  25. environment:
  26. # Database name (replace with yours)
  27. POSTGRES_DB: zabbixdb
  28. # Database user (replace with yours)
  29. POSTGRES_USER: zabbixdbuser
  30. # Database password (replace with yours)
  31. POSTGRES_PASSWORD: Proxima200!
  32. healthcheck:
  33. test: ["CMD-SHELL", "pg_isready -U postgres -h 127.0.0.1"]
  34. interval: 10s
  35. timeout: 5s
  36. retries: 3
  37. start_period: 60s
  38. restart: unless-stopped
  39.  
  40. zabbix:
  41. # Image tag (replace with yours)
  42. image: zabbix/zabbix-server-pgsql:ubuntu-5.4.5
  43. environment:
  44. DB_SERVER_HOST: postgres
  45. DB_SERVER_PORT: 5432
  46. # Database name (replace with yours)
  47. POSTGRES_DB: zabbixdb
  48. # Database user (replace with yours)
  49. POSTGRES_USER: zabbixdbuser
  50. # Database password (replace with yours)
  51. POSTGRES_PASSWORD: Proxima200!
  52. ZBX_VALUECACHESIZE: 64M
  53. ZBX_CACHESIZE: 128M
  54. ZBX_TRENDCACHESIZE: 128M
  55. ports:
  56. - "10051:10051"
  57. restart: unless-stopped
  58. depends_on:
  59. postgres:
  60. condition: service_healthy
  61.  
  62. web:
  63. # Image tag (replace with yours)
  64. image: zabbix/zabbix-web-nginx-pgsql:ubuntu-5.4.5
  65. environment:
  66. DB_SERVER_HOST: postgres
  67. DB_SERVER_PORT: 5432
  68. # Database name (replace with yours)
  69. POSTGRES_DB: zabbixdb
  70. # Database user (replace with yours)
  71. POSTGRES_USER: zabbixdbuser
  72. # Database password (replace with yours)
  73. POSTGRES_PASSWORD: Proxima200!
  74. ZBX_SERVER_HOST: zabbix.eager.su
  75. ZBX_SERVER_PORT: 10051
  76. # Timezone (replace with yours) https://www.php.net/manual/en/timezones.php
  77. PHP_TZ: Europe/Minsk
  78. healthcheck:
  79. test: ["CMD", "curl", "-f", "http://localhost:8080/"]
  80. interval: 10s
  81. timeout: 5s
  82. retries: 3
  83. start_period: 90s
  84. labels:
  85. - "traefik.enable=true"
  86. # Zabbix URL (replace with yours)
  87. - "traefik.http.routers.zabbix.rule=Host(`zabbix.eager.su`)"
  88. - "traefik.http.routers.zabbix.service=zabbix"
  89. - "traefik.http.routers.zabbix.entrypoints=websecure"
  90. - "traefik.http.services.zabbix.loadbalancer.server.port=8080"
  91. - "traefik.http.routers.zabbix.tls=true"
  92. - "traefik.http.routers.zabbix.tls.certresolver=letsencrypt"
  93. - "traefik.http.services.zabbix.loadbalancer.passhostheader=true"
  94. - "traefik.http.routers.zabbix.middlewares=compresstraefik"
  95. - "traefik.http.middlewares.compresstraefik.compress=true"
  96. restart: unless-stopped
  97. depends_on:
  98. postgres:
  99. condition: service_healthy
  100. traefik:
  101. condition: service_healthy
  102.  
  103. agent:
  104. # Image tag (replace with yours)
  105. image: zabbix/zabbix-agent2:ubuntu-trunk
  106. environment:
  107. # Zabbix Hostname (replace with yours)
  108. # Set as DNS name on Zabbix server host configuration screen to make checks of Zabbix server itself
  109. ZBX_HOSTNAME: zabbix
  110. ZBX_SERVER_HOST: 0.0.0.0/0
  111. ports:
  112. - "10050:10050"
  113. restart: unless-stopped
  114. depends_on:
  115. - postgres
  116. - zabbix
  117.  
  118. traefik:
  119. # Image tag (replace with yours)
  120. image: traefik:2.4
  121. command:
  122. - "--log.level=WARN"
  123. - "--accesslog=true"
  124. - "--api.dashboard=true"
  125. - "--api.insecure=true"
  126. - "--ping=true"
  127. - "--ping.entrypoint=ping"
  128. - "--entryPoints.ping.address=:8082"
  129. - "--entryPoints.web.address=:80"
  130. - "--entryPoints.websecure.address=:443"
  131. - "--providers.docker=true"
  132. - "--providers.docker.endpoint=unix:///var/run/docker.sock"
  133. - "--providers.docker.exposedByDefault=false"
  134. - "--certificatesresolvers.letsencrypt.acme.tlschallenge=true"
  135. # Email for Let's Encrypt (replace with yours)
  136. - "--certificatesresolvers.letsencrypt.acme.email=bordulets@gmail.com"
  137. - "--certificatesresolvers.letsencrypt.acme.storage=/etc/traefik/acme/acme.json"
  138. - "--metrics.prometheus=true"
  139. - "--metrics.prometheus.buckets=0.1,0.3,1.2,5.0"
  140. - "--global.checkNewVersion=true"
  141. - "--global.sendAnonymousUsage=false"
  142. volumes:
  143. - /var/run/docker.sock:/var/run/docker.sock
  144. - traefik-certificates:/etc/traefik/acme
  145. ports:
  146. - "80:80"
  147. - "443:443"
  148. healthcheck:
  149. test: ["CMD", "wget", "http://localhost:8082/ping","--spider"]
  150. interval: 10s
  151. timeout: 5s
  152. retries: 3
  153. start_period: 5s
  154. labels:
  155. - "traefik.enable=true"
  156. # Traefik URL (replace with yours)
  157. - "traefik.http.routers.dashboard.rule=Host(`traefik.zabbix.eager.su`)"
  158. - "traefik.http.routers.dashboard.service=api@internal"
  159. - "traefik.http.routers.dashboard.entrypoints=websecure"
  160. - "traefik.http.services.dashboard.loadbalancer.server.port=8080"
  161. - "traefik.http.routers.dashboard.tls=true"
  162. - "traefik.http.routers.dashboard.tls.certresolver=letsencrypt"
  163. - "traefik.http.services.dashboard.loadbalancer.passhostheader=true"
  164. - "traefik.http.routers.dashboard.middlewares=authtraefik"
  165. # Basic Authentication for Traefik Dashboard
  166. # Username: traefikadmin (replace with yours)
  167. # Passwords must be encoded using MD5, SHA1, or BCrypt
  168. - "traefik.http.middlewares.authtraefik.basicauth.users=traefikadmin:$$apr1$$5xglnycu$$GzgaWmink.HuydjjyICAm1"
  169. - "traefik.http.routers.http-catchall.rule=HostRegexp(`{host:.+}`)"
  170. - "traefik.http.routers.http-catchall.entrypoints=web"
  171. - "traefik.http.routers.http-catchall.middlewares=redirect-to-https"
  172. - "traefik.http.middlewares.redirect-to-https.redirectscheme.scheme=https"
  173. restart: unless-stopped
  174.  
  175. backups:
  176. # Image tag (replace with yours)
  177. image: postgres:13.2
  178. # Database backups prune interval (replace with yours). Default is 7 days.
  179. # find /srv/zabbix-postgres/backups -type f -mtime +7 | xargs rm -f
  180.  
  181. # Zabbix backups interval (replace with yours). Default is 1 day.
  182. # sleep 24h
  183.  
  184. # Run zabbix-restore-database.sh to restore database if needed.
  185. command: sh -c 'sleep 30m
  186. && while true; do
  187. PGPASSWORD="$$(echo $$POSTGRES_PASSWORD)"
  188. pg_dump
  189. -h postgres
  190. -p 5432
  191. -d zabbixdb
  192. -U zabbixdbuser | gzip > /srv/zabbix-postgres/backups/zabbix-postgres-backup-$$(date "+%Y-%m-%d_%H-%M").gz
  193. && find /srv/zabbix-postgres/backups -type f -mtime +7 | xargs rm -f;
  194. sleep 24h; done'
  195. volumes:
  196. # Database backups location
  197. - zabbix-postgres-backups:/srv/zabbix-postgres/backups
  198. environment:
  199. # Database password (replace with yours)
  200. POSTGRES_PASSWORD: Proxima200!
  201. restart: unless-stopped
  202. depends_on:
  203. postgres:
  204. condition: service_healthy
  205. web:
  206. condition: service_healthy
  207.  
  208.  
  209.  
  210.  
  211.  
Advertisement
Add Comment
Please, Sign In to add comment