Docker — Proxy Mode
In proxy mode, the gateway sits in front of your existing web server and injects variables into HTML responses.
Browser → [REP Gateway :8080] → [nginx :80]Dockerfile
Section titled “Dockerfile”# Stage 1: Build the frontendFROM node:22-alpine AS buildWORKDIR /appCOPY package*.json ./RUN npm ciCOPY . .RUN npm run build
# Stage 2: nginx + REP gatewayFROM nginx:alpine
# Copy built assets to nginxCOPY --from=build /app/dist /usr/share/nginx/html
# Add the REP gateway binaryCOPY --from=ghcr.io/ruachtech/rep/gateway:latest \ /usr/local/bin/rep-gateway /usr/local/bin/rep-gateway
EXPOSE 8080
ENTRYPOINT ["rep-gateway"]CMD ["--mode", "proxy", "--upstream", "localhost:80", "--port", "8080"]Running
Section titled “Running”docker build -t myapp .
# Stagingdocker run -p 8080:8080 \ -e REP_PUBLIC_API_URL=https://api.staging.example.com \ -e REP_PUBLIC_FEATURE_FLAGS=dark-mode,beta \ -e REP_SENSITIVE_ANALYTICS_KEY=UA-XXXXX-staging \ myapp
# Production — SAME IMAGEdocker run -p 8080:8080 \ -e REP_PUBLIC_API_URL=https://api.example.com \ -e REP_PUBLIC_FEATURE_FLAGS=dark-mode \ -e REP_SENSITIVE_ANALYTICS_KEY=UA-XXXXX-prod \ -e REP_GATEWAY_STRICT=true \ myappHow it works
Section titled “How it works”- nginx starts and serves static files on port 80 (inside the container)
- The gateway starts and proxies all requests to
localhost:80 - For
text/htmlresponses, the gateway intercepts and injects the REP payload - All other responses (JS, CSS, images) pass through unmodified
When to use proxy mode
Section titled “When to use proxy mode”- You need nginx features (gzip, caching headers, URL rewriting, basic auth)
- You’re adding REP to an existing deployment with minimal changes
- Your infrastructure team prefers nginx/Caddy for static file serving