Skip to content

Harden nginx config for uploads and WooCommerce downloads - #98

Merged
TrafeX merged 1 commit into
masterfrom
nginx-hardening
Nov 23, 2026
Merged

TrafeX merged 1 commit into
masterfrom
nginx-hardening

Conversation

@TrafeX

@TrafeX TrafeX commented Nov 23, 2026

Copy link
Copy Markdown
Owner

Summary

  • Deny PHP execution in uploads/files directories, following the WordPress nginx docs. Previously an uploaded .php file already returned 404 (the PHP location resolves against /usr/src/wordpress, not the wp-content volume), so this is defense in depth rather than a fix for an exploitable issue.
  • Make /wp-content/uploads/woocommerce_uploads/ internal, following the WooCommerce docs. Previously downloadable products were publicly accessible (200). internal (instead of deny all) keeps the X-Accel-Redirect download method working.

A fresh build also pulls nginx 1.30.7 from Alpine 3.24, which fixes NGINX2Shell (CVE-2026-123007 / CVE-2026-123633). The image doesn't enable HTTP/2, so it wasn't directly exploitable.

Test plan

Tested locally with a --pull --no-cache build:

  • /wp-content/uploads/evil.php → 403
  • /wp-content/uploads/woocommerce_uploads/product.zip direct → 404
  • Same file through X-Accel-Redirect → 200 with content
  • Regular uploads and theme assets → 200
  • nginx -v → 1.30.7

🤖 Generated with Claude Code

- Deny execution of PHP files in uploads/files directories, as recommended
  by the WordPress nginx docs
- Make WooCommerce's woocommerce_uploads directory internal so downloadable
  products can only be served via X-Accel-Redirect

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@TrafeX
TrafeX merged commit 2edd049 into master Nov 23, 2026
1 check passed
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.

1 participant