feature: remote wp-content/uploads content
This commit is contained in:
@@ -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"
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user