fix(nginx): make upload body size configurable via NGINX_MAX_BODY_SIZE env var
nginx.conf was hard-capped at 5M, causing 413 on uploads larger than 5MB despite the backend accepting up to MAX_FILE_SIZE_MB (default 50). Both nginx configs become envsubst templates. NGINX_MAX_BODY_SIZE defaults to 200M so the backend application limit is always the effective arbiter. gettext-base added to the single-image apt deps to provide envsubst.
This commit is contained in:
parent
2f811d41c8
commit
789b07c7d1
6 changed files with 17 additions and 7 deletions
|
|
@ -18,6 +18,10 @@
|
|||
# Max upload file size in MB (default: 50, 0 = unlimited)
|
||||
# MAX_FILE_SIZE_MB=50
|
||||
|
||||
# Nginx body size limit — nginx format (default: 200M, 0 = unlimited).
|
||||
# Must be >= MAX_FILE_SIZE_MB. Backend MAX_FILE_SIZE_MB is the effective arbiter.
|
||||
# NGINX_MAX_BODY_SIZE=200M
|
||||
|
||||
# Max pages per PDF (default: 0 = unlimited). Set to 20 for HF Spaces.
|
||||
# MAX_PAGE_COUNT=0
|
||||
|
||||
|
|
|
|||
10
Dockerfile
10
Dockerfile
|
|
@ -24,10 +24,11 @@ FROM python:3.12-slim AS base
|
|||
ARG APP_VERSION=dev
|
||||
ENV APP_VERSION=${APP_VERSION}
|
||||
|
||||
# System deps: poppler (pdf2image), nginx
|
||||
# System deps: poppler (pdf2image), nginx, gettext-base (envsubst for nginx template)
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
poppler-utils \
|
||||
nginx \
|
||||
gettext-base \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Python deps (common)
|
||||
|
|
@ -41,8 +42,8 @@ COPY document-parser/ .
|
|||
# Frontend static files
|
||||
COPY --from=frontend-build /build/dist /usr/share/nginx/html
|
||||
|
||||
# Nginx config
|
||||
COPY nginx.conf /etc/nginx/sites-enabled/default
|
||||
# Nginx config (template — substituted at container start via envsubst)
|
||||
COPY nginx.conf.template /etc/nginx/sites-enabled/default.template
|
||||
|
||||
# Non-root user
|
||||
RUN useradd --create-home --shell /bin/bash appuser
|
||||
|
|
@ -52,10 +53,11 @@ RUN mkdir -p /app/uploads /app/data && chown -R appuser:appuser /app
|
|||
|
||||
ENV UPLOAD_DIR=/app/uploads
|
||||
ENV DB_PATH=/app/data/docling_studio.db
|
||||
ENV NGINX_MAX_BODY_SIZE=200M
|
||||
|
||||
EXPOSE 3000
|
||||
|
||||
CMD ["sh", "-c", "nginx && exec su appuser -c 'uvicorn main:app --host 127.0.0.1 --port 8000'"]
|
||||
CMD ["sh", "-c", "envsubst '${NGINX_MAX_BODY_SIZE}' < /etc/nginx/sites-enabled/default.template > /etc/nginx/sites-enabled/default && nginx && exec su appuser -c 'uvicorn main:app --host 127.0.0.1 --port 8000'"]
|
||||
|
||||
# --- Remote: lightweight, delegates to Docling Serve ---
|
||||
FROM base AS remote
|
||||
|
|
|
|||
|
|
@ -117,6 +117,8 @@ services:
|
|||
context: ./frontend
|
||||
ports:
|
||||
- "3000:80"
|
||||
environment:
|
||||
NGINX_MAX_BODY_SIZE: ${NGINX_MAX_BODY_SIZE:-200M}
|
||||
depends_on:
|
||||
- document-parser
|
||||
|
||||
|
|
|
|||
|
|
@ -9,6 +9,8 @@ RUN npm run build
|
|||
FROM nginx:alpine
|
||||
|
||||
COPY --from=build /app/dist /usr/share/nginx/html
|
||||
COPY nginx.conf /etc/nginx/conf.d/default.conf
|
||||
COPY nginx.conf.template /etc/nginx/templates/default.conf.template
|
||||
|
||||
ENV NGINX_MAX_BODY_SIZE=200M
|
||||
|
||||
EXPOSE 80
|
||||
|
|
|
|||
|
|
@ -20,6 +20,6 @@ server {
|
|||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_read_timeout 900s;
|
||||
proxy_send_timeout 900s;
|
||||
client_max_body_size 5M;
|
||||
client_max_body_size ${NGINX_MAX_BODY_SIZE};
|
||||
}
|
||||
}
|
||||
|
|
@ -20,6 +20,6 @@ server {
|
|||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_read_timeout 900s;
|
||||
proxy_send_timeout 900s;
|
||||
client_max_body_size 5M;
|
||||
client_max_body_size ${NGINX_MAX_BODY_SIZE};
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue