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
This commit is contained in:
MythEclipse
2026-06-08 00:00:33 +07:00
parent 4dde9d8408
commit 4589766f27
2 changed files with 15 additions and 6 deletions
+10 -3
View File
@@ -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;"]
+5 -3
View File
@@ -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 (<script src="/", href="/", fetch("/")) to /telemetry/ prefix
sub_filter_types text/html application/javascript;
sub_filter_once off;
sub_filter 'src="/' 'src="/telemetry/';