From 4589766f27fd6868c7cfa3095a9f4b4baefada8c Mon Sep 17 00:00:00 2001 From: MythEclipse Date: Mon, 8 Jun 2026 00:00:33 +0700 Subject: [PATCH] build(web): switch to alpine-based nginx runner for sub_filter support Migrate the web runner stage from the official nginx alpine image to a standard alpine image with the nginx package installed. This ensures the presence of the `http_sub_module` required for path rewriting in the telemetry proxy configuration. - Replace `nginx:1.27-alpine` with `alpine:3.20` and `apk add nginx` - Update Nginx configuration file path to `/etc/nginx/http.d/default.conf` - Update web asset root directory to `/var/lib/nginx/html` - Add `X-Forwarded-For` and `X-Forwarded-Proto` headers to proxy locations --- apps/web/Dockerfile | 13 ++++++++++--- apps/web/nginx.conf | 8 +++++--- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/apps/web/Dockerfile b/apps/web/Dockerfile index 71d6cd2..6a81ff0 100644 --- a/apps/web/Dockerfile +++ b/apps/web/Dockerfile @@ -14,8 +14,15 @@ ENV VITE_API_BASE_URL=$VITE_API_BASE_URL RUN bun run --cwd packages/shared build RUN bun run --cwd apps/web build -FROM nginx:1.27-alpine AS runner -COPY apps/web/nginx.conf /etc/nginx/conf.d/default.conf -COPY --from=builder /app/apps/web/dist /usr/share/nginx/html +# ============================================================================= +# Stage 2: nginx (Alpine package — includes sub_filter module) +# Alpine's nginx package is built with --with-http_sub_module +# ============================================================================= +FROM alpine:3.20 AS runner +RUN apk add --no-cache nginx + +COPY apps/web/nginx.conf /etc/nginx/http.d/default.conf +COPY --from=builder /app/apps/web/dist /var/lib/nginx/html + EXPOSE 80 CMD ["nginx", "-g", "daemon off;"] diff --git a/apps/web/nginx.conf b/apps/web/nginx.conf index 21e1872..c6f302a 100644 --- a/apps/web/nginx.conf +++ b/apps/web/nginx.conf @@ -1,7 +1,7 @@ server { listen 80; server_name _; - root /usr/share/nginx/html; + root /var/lib/nginx/html; index index.html; location /api/ { @@ -28,6 +28,8 @@ server { proxy_http_version 1.1; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; expires 1y; add_header Cache-Control "public, immutable"; } @@ -57,7 +59,7 @@ server { proxy_read_timeout 10s; } - # Telemetry SPA — proxy to orange, rewrite root-relative paths to prefix + # Telemetry SPA — proxy to orange VPS, rewrite root-relative paths to /telemetry/ prefix location /telemetry/ { proxy_pass http://100.96.248.86:8181/; proxy_http_version 1.1; @@ -69,7 +71,7 @@ server { proxy_send_timeout 35s; proxy_read_timeout 35s; - # Rewrite root-relative paths in HTML/JS to /telemetry/ prefix + # Rewrite root-relative paths (