diff --git a/reverse_proxy/CLAUDE.md b/reverse_proxy/CLAUDE.md index 92fc112..6d8012b 100644 --- a/reverse_proxy/CLAUDE.md +++ b/reverse_proxy/CLAUDE.md @@ -17,6 +17,14 @@ The solution uses a multi-stage Docker build: - **Stage 2 (tailscale)**: Downloads and extracts Tailscale binaries - **Stage 3 (production)**: Final Alpine image with nginx, Tailscale, and GoAccess +### Memory Optimization + +Configured for 256MB Fly.io containers: +- **Go GC settings**: `GOGC=10` and `GOMEMLIMIT=100MiB` for aggressive Tailscale memory management +- **GoAccess**: Static HTML generation (60-second intervals) instead of real-time WebSocket +- **Nginx**: Reduced connection timeouts and buffer sizes +- **Package optimization**: Minimal Alpine packages only + ### Key Components - **nginx.conf**: Main configuration with rate limiting zones, server blocks for each subdomain, and GoAccess metrics endpoint diff --git a/reverse_proxy/Dockerfile b/reverse_proxy/Dockerfile index 4ec7a81..12802e0 100644 --- a/reverse_proxy/Dockerfile +++ b/reverse_proxy/Dockerfile @@ -21,6 +21,10 @@ COPY --from=builder /app/start.sh /app/start.sh COPY --from=tailscale /app/tailscaled /app/tailscaled COPY --from=tailscale /app/tailscale /app/tailscale RUN mkdir -p /var/run/tailscale /var/cache/tailscale /var/lib/tailscale /usr/share/nginx/html + +# Set aggressive Go GC settings for Tailscale to reduce memory usage +ENV GOGC=10 +ENV GOMEMLIMIT=100MiB COPY nginx.conf /etc/nginx/http.d/nginx.conf COPY custom_50x.html /usr/share/nginx/html/ COPY goaccess.sh /app/goaccess.sh diff --git a/reverse_proxy/start.sh b/reverse_proxy/start.sh index b717d4b..4390fca 100755 --- a/reverse_proxy/start.sh +++ b/reverse_proxy/start.sh @@ -1,5 +1,9 @@ #!/bin/sh +# Set aggressive GC settings for Tailscale to reduce memory usage +export GOGC=10 +export GOMEMLIMIT=100MiB + /app/tailscaled --state=/var/lib/tailscale/tailscaled.state --socket=/var/run/tailscale/tailscaled.sock & /app/tailscale up --authkey=${TAILSCALE_AUTHKEY} --hostname=reverseproxy