This configuration is designed to redirect all requests to the WordPress
uploads directory (/wp-content/uploads/
) to a specified production
Content Delivery Network (CDN). This setup helps offload static media
assets to the CDN, reducing load on the main server and improving load times.
- The
$production
variable defines the CDN URL where the assets are located. - Requests for resources within
/wp-content/uploads/
are first checked locally. If the file is not found, the request is rewritten to the CDN location.
set $production
: Sets the CDN URL, which can be modified as needed.location @prod_uploads
: Defines a named location that rewrites URLs to the CDN for resources in the/wp-content/uploads/
directory.location ~ "^/wp-content/uploads/(.*)$"
: Matches requests for the/wp-content/uploads/
directory and attempts to serve files locally. If files are not found, it forwards the request to@prod_uploads
, triggering the CDN rewrite.
Place this configuration within an appropriate server block in your NGINX
configuration to enable fallback loading from the CDN for WordPress media.
Ensure the $production
variable points to the correct CDN path for your assets.
On SpinupWP, place this config here:
/etc/nginx/sites-available/{$site}/server/
See Setting Up s3cmd 2.x with DigitalOcean Spaces
- Run
s3cmd --configure
. - Enter your Access and Secret Keys.
- Accept the default US region as it doesn't apply with DO Spaces.
- S3 Endpoing:
nyc3.digitaloceanspaces.com
- Template for accessing a bucket:
%(bucket)s.nyc3.digitaloceanspaces.com
- No need to set an encryption password and accept the default path to GPG (we're not using it in this case).
Yes
for "Use HTTPS Protocol" (required by DO Spaces).- Proxy server, leave blank.