Skip to content

Commit 1b8474a

Browse files
authored
πŸš€ Release: beta β†’ master (#67)
* feat(docker): update Grafana service configuration and add healthcheck * feat(nginx): add Docker DNS resolution for upstream service names * feat(nginx): use variable for Grafana upstream in /monitor/ location
1 parent e756065 commit 1b8474a

2 files changed

Lines changed: 23 additions & 4 deletions

File tree

β€Žinfra/docker-compose.monitoring.ymlβ€Ž

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,8 @@ services:
141141
image: grafana/grafana:10.4.2
142142
container_name: grafana
143143
restart: unless-stopped
144-
ports:
145-
- "127.0.0.1:3001:3000"
144+
expose:
145+
- "3000"
146146

147147
environment:
148148
- GF_SECURITY_ADMIN_PASSWORD=${GRAFANA_ADMIN_PASSWORD}
@@ -169,6 +169,13 @@ services:
169169
max-size: "10m"
170170
max-file: "3"
171171

172+
healthcheck:
173+
test: ["CMD", "wget", "--spider", "-q", "http://localhost:3000/api/health"]
174+
interval: 30s
175+
timeout: 5s
176+
retries: 3
177+
start_period: 30s
178+
172179
node-exporter:
173180
image: prom/node-exporter:v1.8.1
174181
container_name: node-exporter

β€Žinfra/nginx/api.confβ€Ž

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,17 @@ server {
9797

9898
server_tokens off;
9999

100+
# ─────────────────────────────────────────────────────────────────────────────
101+
# Docker DNS Resolution (CRITICAL for service name upstreams)
102+
#
103+
# Enables runtime DNS resolution for Docker service names (e.g., grafana:3000).
104+
# Without this, Nginx fails at config-load with: "host not found in upstream".
105+
# Docker's embedded resolver is at 127.0.0.11:53.
106+
# valid=10s caches DNS lookups for 10 seconds.
107+
# ─────────────────────────────────────────────────────────────────────────────
108+
resolver 127.0.0.11 valid=10s;
109+
resolver_timeout 5s;
110+
100111
# safer host validation (still simple)
101112
if ($host !~* ^(__API_HOSTNAME__|localhost|127\.0\.0\.1)$) {
102113
return 444;
@@ -217,10 +228,11 @@ server {
217228
proxy_buffering on;
218229
}
219230

220-
# Grafana (Cloudflare + localhost only)
231+
# Grafana (Cloudflare + localhost only, via Docker service DNS)
221232
location /monitor/ {
222233
if ($is_trusted_source = 0) { return 403; }
223-
proxy_pass http://127.0.0.1:3333/monitor/;
234+
set $grafana_upstream "http://grafana:3000";
235+
proxy_pass $grafana_upstream;
224236
proxy_http_version 1.1;
225237
proxy_set_header Upgrade $http_upgrade;
226238
proxy_set_header Connection $connection_upgrade;

0 commit comments

Comments
Β (0)