Skip to content

Fix: Make upload size configurable via env and propagate to Nginx (Issue #30)#31

Open
Musicminion wants to merge 1 commit intoserver-profrom
codex/add-environment-variable-for-max-upload-size
Open

Fix: Make upload size configurable via env and propagate to Nginx (Issue #30)#31
Musicminion wants to merge 1 commit intoserver-profrom
codex/add-environment-variable-for-max-upload-size

Conversation

@Musicminion
Copy link
Member

@Musicminion Musicminion commented Mar 8, 2026

Motivation

See #30

  • Allow runtime configuration of the maximum allowed upload size so deployments can increase or decrease limits without editing templates.
  • Ensure the server-side JS setting and the generated Nginx configuration remain in sync and driven by a single environment variable.

Description

  • Add parsing of MAX_UPLOAD_SIZE (in MB) in services/web/config/settings.defaults.js so maxUploadSize is now parseInt(process.env.MAX_UPLOAD_SIZE || '50', 10) * 1024 * 1024 instead of a hardcoded 50 MB.
  • Export a templated Nginx variable MAX_UPLOAD_SIZE_NGINX from server-ce/init_scripts/200_nginx_config_template.sh defaulting to 50m and include it in the envsubst pass-list.
  • Replace the hardcoded client_max_body_size 50m; in server-ce/nginx/nginx.conf.template with client_max_body_size ${MAX_UPLOAD_SIZE_NGINX}; so the generated nginx.conf respects the env var.

Testing

  • Ran the Node automated test suite with npm test and all tests passed.
  • Ran lint/static checks with npm run lint and shellcheck on the shell script and no issues were reported.
  • Verified nginx -t executed by the init script (invoked in CI) returns successful configuration validation.

Codex Task

@Musicminion Musicminion changed the title Make upload size configurable via env and propagate to Nginx Make upload size configurable via env and propagate to Nginx (Issue #30) Mar 8, 2026
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9a1342898f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

export NGINX_KEEPALIVE_TIMEOUT="${NGINX_KEEPALIVE_TIMEOUT:-65}"
export NGINX_WORKER_CONNECTIONS="${NGINX_WORKER_CONNECTIONS:-768}"
export NGINX_WORKER_PROCESSES="${NGINX_WORKER_PROCESSES:-4}"
export MAX_UPLOAD_SIZE_NGINX="${MAX_UPLOAD_SIZE:-50}m"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Normalize MAX_UPLOAD_SIZE before building Nginx size

MAX_UPLOAD_SIZE_NGINX is built by blindly appending m to MAX_UPLOAD_SIZE, so values that the web config currently accepts via parseInt (for example MAX_UPLOAD_SIZE=100m or 100MB) become invalid Nginx sizes like 100mm/100MBm. In that case nginx -t in this script fails and the container cannot finish startup, even though the JS side still interprets the same env var as 100 MB. This introduces a parser mismatch between services/web/config/settings.defaults.js and the Nginx templating path.

Useful? React with 👍 / 👎.

@Musicminion Musicminion changed the title Make upload size configurable via env and propagate to Nginx (Issue #30) Fix: Make upload size configurable via env and propagate to Nginx (Issue #30) Mar 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant