Skip to content

Commit 06c0a5f

Browse files
committed
Better image proxy for wpe?
1 parent d9847fa commit 06c0a5f

File tree

2 files changed

+33
-15
lines changed

2 files changed

+33
-15
lines changed

commands/host/project-configure

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,35 @@ EOF
391391
fi
392392
fi
393393

394+
# Configure nginx proxy if PROXY_URL is set
395+
if [ -n "$PROXY_URL" ]; then
396+
echo "Configuring nginx proxy..."
397+
398+
# Create nginx directory if it doesn't exist
399+
mkdir -p .ddev/nginx
400+
401+
# Extract hostname from PROXY_URL for Host header
402+
PROXY_HOST=$(echo "$PROXY_URL" | sed 's|https\?://||' | sed 's|/.*||')
403+
404+
# Process nginx configuration template - use the current add-on source if available
405+
NGINX_TEMPLATE=""
406+
407+
# Try to find the template in various locations
408+
if [ -f ".ddev/addon-metadata/ddev-kanopi-wp/config/nginx/nginx-site.conf" ]; then
409+
NGINX_TEMPLATE=".ddev/addon-metadata/ddev-kanopi-wp/config/nginx/nginx-site.conf"
410+
elif [ -f "/Users/thejimbirch/Projects/ddev-kanopi-wp/config/nginx/nginx-site.conf" ]; then
411+
NGINX_TEMPLATE="/Users/thejimbirch/Projects/ddev-kanopi-wp/config/nginx/nginx-site.conf"
412+
fi
413+
414+
if [ -n "$NGINX_TEMPLATE" ]; then
415+
sed "s|PROXY_URL_PLACEHOLDER|$PROXY_URL|g; s|HOST_PLACEHOLDER|$PROXY_HOST|g" \
416+
"$NGINX_TEMPLATE" > ".ddev/nginx/nginx-site.conf"
417+
echo " ✅ Nginx proxy configuration created"
418+
else
419+
echo " ⚠️ Nginx template not found - proxy configuration not updated"
420+
fi
421+
fi
422+
394423
echo ""
395424
echo -e "🎉 ${green}Configuration complete!${NC}"
396425
echo ""

config/nginx/nginx-site.conf

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,19 @@
11
#ddev-generated
22
# Custom NGINX configuration for Kanopi WordPress development
33

4-
# Include common security and performance settings
5-
include /mnt/ddev_config/nginx/nginx-common.conf;
6-
74
# Image proxy configuration for multi-provider integration
85
location ~ ^/wp-content/uploads/.* {
9-
try_files $uri @rewrite @proxy;
6+
try_files $uri @proxy;
107
}
118

129
location @proxy {
1310
# Proxy missing uploads to hosting provider environment
14-
# Uses PROXY_URL environment variable set based on hosting provider
1511
resolver 8.8.8.8;
16-
17-
# Set proxy URL based on hosting provider via environment variable
18-
set $proxy_url "";
19-
if ($http_host) {
20-
set $proxy_url $PROXY_URL;
21-
}
22-
23-
# Fallback proxy pass with environment variable
24-
proxy_pass $proxy_url$request_uri;
12+
proxy_pass PROXY_URL_PLACEHOLDER$request_uri;
13+
proxy_set_header Host HOST_PLACEHOLDER;
2514
proxy_set_header X-Real-IP $remote_addr;
2615
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
2716
proxy_set_header X-Forwarded-Proto $scheme;
17+
proxy_ssl_verify off;
2818
proxy_intercept_errors on;
29-
proxy_redirect off;
3019
}

0 commit comments

Comments
 (0)