From e14546356c50b90b3c5988b5c32fabb33b6b0cff Mon Sep 17 00:00:00 2001 From: Lucilio Correia Date: Fri, 24 Apr 2026 23:53:03 -0300 Subject: [PATCH] feature: remote wp-content/uploads content --- docker-compose.yml | 1 + .../templates/wordpress-regular-site.conf.template | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/docker-compose.yml b/docker-compose.yml index 1331cf2..316d67b 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -14,6 +14,7 @@ services: environment: WORDPRESS_SITEURL: ${WPSTACK_PROTOCOL}://${WPSTACK_DOMAIN}/${WPSTACK_URLPATH:-} WORDPRESS_SITE_TYPE: ${WPSTACK_MULTISITE:-regular} + REMOTE_MEDIA_URL: ${REMOTE_MEDIA_URL:-} labels: caddy: ${WPSTACK_DOMAIN} caddy.reverse_proxy: "reverse-proxy:80" diff --git a/docker/nginx/templates/wordpress-regular-site.conf.template b/docker/nginx/templates/wordpress-regular-site.conf.template index 477b6e4..9598019 100644 --- a/docker/nginx/templates/wordpress-regular-site.conf.template +++ b/docker/nginx/templates/wordpress-regular-site.conf.template @@ -28,6 +28,19 @@ server { access_log off; } + location ~ ^/wp-content/uploads/(.*)$ { + try_files $uri @remote_assets; + } + + location @remote_assets { + set $remote_url "${REMOTE_MEDIA_URL}"; + if ($remote_url = "") { + return 404; + } + add_header X-Redirect-From "nginx-local" always; + return 302 $remote_url$request_uri; + } + location / { # This is cool because no php is touched for static content. # include the "?$args" part so non-default permalinks doesn't break when using query string