diff --git a/config/nginx.conf b/config/nginx.conf index f24585bc..da20a5a9 100644 --- a/config/nginx.conf +++ b/config/nginx.conf @@ -88,6 +88,20 @@ http { add_header Cache-Control "public"; } + # Never execute PHP files in the uploads directories + # https://developer.wordpress.org/advanced-administration/server/web-server/nginx/ + location ~* /(?:uploads|files)/.*\.php$ { + deny all; + } + + # Protect WooCommerce downloadable products from direct access, + # only allow serving them through X-Accel-Redirect + # https://developer.woocommerce.com/docs/code-snippets/using_nginx_server_to_protect_your_uploads_directory/ + location ^~ /wp-content/uploads/woocommerce_uploads/ { + root /var/www; + internal; + } + location / { # First attempt to serve request as file, then # as directory, then fall back to index.php