Skip to content

Raise WordPress upload limits and prevent false-positive upload 403s#33

Merged
MaximillianGroup merged 15 commits into
mainfrom
copilot/increase-upload-size-limits
Jun 19, 2026
Merged

Raise WordPress upload limits and prevent false-positive upload 403s#33
MaximillianGroup merged 15 commits into
mainfrom
copilot/increase-upload-size-limits

Conversation

Copilot AI commented Jun 13, 2026

Copy link
Copy Markdown
Contributor

Uploading large plugins (e.g. Gutenberg at ~35 MB) returned 413 Request Entity Too Large from nginx because /wp-admin/update.php inherited the global 10m default. PHP-FPM's upload_max_filesize defaulted to 2M, silently blocking media uploads that nginx would otherwise pass. Upload handlers were also returning 403 in some valid cases due to $block_reason UA/geo checks.

nginx (nginx/snippets/spx-upload-limits.conf)

Per-route client_max_body_size overrides, included by the HTTPS vhost:

Route Limit
/wp-admin/update.php 64m — plugin/theme ZIPs
/wp-admin/async-upload.php 100m — media library uploader
/wp-json/wp/v2/media 100m — REST API media endpoint

All values stay at or below Cloudflare's 100 MB per-request cap. Global default remains 10m.

Upload routes now bypass soft UA/geo $block_reason false-positive checks but still enforce hard malicious-signature blocks via $hard_block_reason (from nginx/conf.d/spx-bot-mitigation-logic.conf). Method restrictions and rate limiting remain in place, and upload authorization is still enforced by WordPress.

PHP-FPM (var/www/html/.user.ini) — new file

PHP-FPM scans .user.ini from the document root for every request. upload_max_filesize / post_max_size are PHP_INI_PERDIR and cannot be set via ini_set() at runtime.

upload_max_filesize = 100M
post_max_size       = 105M   ; 5M headroom for multipart overhead

Direct web access is blocked by perimeter dotfile deny rules.

Copilot AI requested review from Copilot and removed request for Copilot June 13, 2026 21:33
Copilot AI changed the title Raise nginx upload body-size limits for WordPress plugins and media Raise WordPress upload limits: nginx body-size + PHP-FPM per-directory overrides Jun 13, 2026
Copilot AI requested a review from MaximillianGroup June 13, 2026 21:33

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Raises WordPress upload limits end-to-end by aligning PHP-FPM per-directory upload caps with the (per-route) Nginx request body limits, addressing 413s and PHP’s default 2M upload ceiling.

Changes:

  • Add PHP-FPM per-directory overrides via a new var/www/html/.user.ini.
  • Set upload_max_filesize/post_max_size to support larger plugin and media uploads.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread var/www/html/.user.ini Outdated
Comment thread var/www/html/.user.ini Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Max Barrett <34328348+MaximillianGroup@users.noreply.github.com>
Copilot AI review requested due to automatic review settings June 19, 2026 16:16
@MaximillianGroup

Copy link
Copy Markdown
Contributor

@copilot - this solution will not solve the 403 error. The user upload limits is 120M already. This is not a solution

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Max Barrett <34328348+MaximillianGroup@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.

Comment thread var/www/html/.user.ini Outdated
Copilot AI requested review from Copilot and removed request for Copilot June 19, 2026 16:24

Copilot AI commented Jun 19, 2026

Copy link
Copy Markdown
Contributor Author

@copilot - this solution will not solve the 403 error. The user upload limits is 120M already. This is not a solution

Updated in 176d534: I removed $block_reason 403 enforcement from the WordPress upload endpoints (/wp-admin/update.php, /wp-admin/async-upload.php, /wp-json/wp/v2/media) so legitimate uploads are not blocked by UA/geo false positives, while keeping per-route method limits and rate limiting in place.

Copilot AI changed the title Raise WordPress upload limits: nginx body-size + PHP-FPM per-directory overrides Raise WordPress upload limits and prevent false-positive upload 403s Jun 19, 2026
Copilot AI requested a review from MaximillianGroup June 19, 2026 16:25
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Max Barrett <34328348+MaximillianGroup@users.noreply.github.com>
Copilot AI review requested due to automatic review settings June 19, 2026 17:26
Copilot AI requested review from Copilot and removed request for Copilot June 19, 2026 17:37
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Max Barrett <34328348+MaximillianGroup@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

Comment thread var/www/html/.user.ini Outdated
Comment thread nginx/snippets/spx-upload-limits.conf Outdated
Comment thread nginx/conf.d/spx-bot-mitigation-logic.conf Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Max Barrett <34328348+MaximillianGroup@users.noreply.github.com>
Copilot AI review requested due to automatic review settings June 19, 2026 18:15
MaximillianGroup and others added 2 commits June 19, 2026 11:15
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Max Barrett <34328348+MaximillianGroup@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Max Barrett <34328348+MaximillianGroup@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

Comment thread nginx/conf.d/spx-bot-mitigation-logic.conf
Comment thread var/www/html/.user.ini
Comment on lines +32 to +33
upload_max_filesize = 95M
post_max_size = 100M
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Max Barrett <34328348+MaximillianGroup@users.noreply.github.com>
Copilot AI review requested due to automatic review settings June 19, 2026 22:08
@MaximillianGroup MaximillianGroup merged commit e51d867 into main Jun 19, 2026
6 checks passed

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

Comment thread var/www/html/.user.ini
Comment on lines +32 to +33
upload_max_filesize = 95M
post_max_size = 100M
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants