Author SHA1 Message Date
lucilio e14546356c feature: remote wp-content/uploads content 2026-04-24 23:53:03 -03:00
lucilio baf2239c57 fix: db host desambiguation with container name 2026-04-24 10:39:16 -03:00
2 changed files with 20 additions and 20 deletions
+7 -7
View File
@@ -14,7 +14,7 @@ services:
environment: environment:
WORDPRESS_SITEURL: ${WPSTACK_PROTOCOL}://${WPSTACK_DOMAIN}/${WPSTACK_URLPATH:-} WORDPRESS_SITEURL: ${WPSTACK_PROTOCOL}://${WPSTACK_DOMAIN}/${WPSTACK_URLPATH:-}
WORDPRESS_SITE_TYPE: ${WPSTACK_MULTISITE:-regular} WORDPRESS_SITE_TYPE: ${WPSTACK_MULTISITE:-regular}
WPSTACK_MEDIA_HOST: ${WPSTACK_MEDIA_HOST:-} REMOTE_MEDIA_URL: ${REMOTE_MEDIA_URL:-}
labels: labels:
caddy: ${WPSTACK_DOMAIN} caddy: ${WPSTACK_DOMAIN}
caddy.reverse_proxy: "reverse-proxy:80" caddy.reverse_proxy: "reverse-proxy:80"
@@ -32,7 +32,7 @@ services:
volumes: volumes:
- ./webroot:/var/www/html - ./webroot:/var/www/html
environment: environment:
WORDPRESS_DB_HOST: db WORDPRESS_DB_HOST: ${WPSTACK_PROJECT_NAME:-wpstack}-db
WORDPRESS_DB_USER: ${DB_USER} WORDPRESS_DB_USER: ${DB_USER}
WORDPRESS_DB_NAME: ${DB_NAME} WORDPRESS_DB_NAME: ${DB_NAME}
WORDPRESS_DB_PASSWORD: ${DB_PASS} WORDPRESS_DB_PASSWORD: ${DB_PASS}
@@ -54,15 +54,15 @@ services:
db: db:
container_name: ${WPSTACK_PROJECT_NAME:-wpstack}-db container_name: ${WPSTACK_PROJECT_NAME:-wpstack}-db
image: ${DB_ENGINE:-mariadb}:${DB_VERSION:-latest} image: mariadb
volumes: volumes:
- db_data:/var/lib/mysql - db_data:/var/lib/mysql
- ../db:/docker-entrypoint-initdb.d - ../db:/docker-entrypoint-initdb.d
environment: environment:
MYSQL_RANDOM_ROOT_PASSWORD: true MARIADB_RANDOM_ROOT_PASSWORD: true
MYSQL_USER: ${DB_USER} MARIADB_USER: ${DB_USER}
MYSQL_PASSWORD: ${DB_PASS} MARIADB_PASSWORD: ${DB_PASS}
MYSQL_DATABASE: ${DB_NAME} MARIADB_DATABASE: ${DB_NAME}
networks: networks:
- app-network - app-network
- proxy-network - proxy-network
@@ -28,6 +28,19 @@ server {
access_log off; 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 / { location / {
# This is cool because no php is touched for static content. # 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 # include the "?$args" part so non-default permalinks doesn't break when using query string
@@ -41,19 +54,6 @@ server {
fastcgi_pass php; fastcgi_pass php;
} }
location ~* ^/wp-content/uploads/ {
set $media_host "${WPSTACK_MEDIA_HOST}";
try_files $uri @remote_media;
}
location @remote_media {
if ($media_host = "") {
return 404;
}
return 302 $media_host$request_uri;
}
location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ { location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
expires max; expires max;
log_not_found off; log_not_found off;