Skip to content

Commit 1011c89

Browse files
committed
Switch health check endpoint to Unix socket to avoid port conflicts
1 parent dbb4a1b commit 1011c89

File tree

4 files changed

+6
-7
lines changed

4 files changed

+6
-7
lines changed

compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ services:
1515
- EXTERNAL_RESOLVER=${EXTERNAL_RESOLVER:-8.8.8.8 8.8.4.4 valid=300s}
1616
restart: unless-stopped
1717
healthcheck:
18-
test: ["CMD", "sh", "-c", "wget -qO /dev/null http://127.0.0.1/health && nc -z 127.0.0.1 1234"]
18+
test: ["CMD", "sh", "-c", "curl -sf --unix-socket /var/run/nginx-health.sock http://localhost/health && nc -z 127.0.0.1 1234"]
1919
interval: 30s
2020
timeout: 5s
2121
retries: 10

docker/Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ FROM moby/buildkit:${BUILDKIT_VERSION}
1717
RUN apk add --no-cache \
1818
nginx nginx-mod-stream \
1919
dnsmasq \
20-
iptables
20+
iptables \
21+
curl
2122

2223
# envsubst
2324
COPY --from=deps /usr/bin/envsubst /usr/bin/envsubst

docker/files/nginx.conf.template

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,12 +109,10 @@ ${NGINX_HTTP_LISTEN_DEFAULT}
109109
}
110110
}
111111

112-
# Localhost-only server (for health checks)
112+
# Health check (fixed port, localhost only)
113113
server {
114-
${NGINX_HTTP_LISTEN}
115-
server_name localhost 127.0.0.1;
114+
listen unix:/var/run/nginx-health.sock;
116115

117-
# Health check
118116
location /health {
119117
access_log off;
120118
return 200 "OK\n";

setup/compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ services:
1313
- EXTERNAL_RESOLVER=${EXTERNAL_RESOLVER:-1.1.1.1 8.8.8.8 valid=300s}
1414
restart: unless-stopped
1515
healthcheck:
16-
test: ["CMD", "sh", "-c", "wget -qO /dev/null http://127.0.0.1/health && nc -z 127.0.0.1 1234"]
16+
test: ["CMD", "sh", "-c", "curl -sf --unix-socket /var/run/nginx-health.sock http://localhost/health && nc -z 127.0.0.1 1234"]
1717
interval: 30s
1818
timeout: 5s
1919
retries: 10

0 commit comments

Comments
 (0)