Skip to content

Commit a3968cd

Browse files
Merge pull request #12 from kanopi/pantheon-test
Fixes for pantheon
2 parents 356efe7 + dbc8ce3 commit a3968cd

File tree

10 files changed

+154
-228
lines changed

10 files changed

+154
-228
lines changed

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ A comprehensive DDEV add-on that provides Kanopi's battle-tested workflow for Wo
1111
## 🚀 Quick Start
1212

1313
```bash
14+
# Intialize a project
15+
ddev config --project-type=wordpress
16+
1417
# Install the add-on
1518
ddev add-on get kanopi/ddev-kanopi-wp
1619

@@ -82,7 +85,7 @@ ddev restart
8285
### New Projects
8386
```bash
8487
# Initialize DDEV
85-
ddev config --project-type=wordpress --docroot=public # or web or wp...
88+
ddev config --project-type=wordpress
8689

8790
# Install add-on
8891
ddev add-on get kanopi/ddev-kanopi-wp

commands/host/project-configure

Lines changed: 33 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -437,42 +437,41 @@ fi
437437
if [ -n "$PROXY_URL" ]; then
438438
echo "Configuring nginx proxy..."
439439

440-
# Create nginx directory if it doesn't exist
441-
mkdir -p .ddev/nginx
442-
443-
# Extract hostname from PROXY_URL for Host header
444-
PROXY_HOST=$(echo "$PROXY_URL" | sed 's|https\://||' | sed 's|http://||' | sed 's|/.*||')
445-
446-
# Process nginx configuration template - use the current add-on source if available
447-
NGINX_MAIN_TEMPLATE=""
448-
NGINX_SNIPPET_TEMPLATE=""
449-
450-
# Try to find the templates in the add-on metadata
451-
if [ -f ".ddev/addon-metadata/ddev-kanopi-wp/config/nginx/nginx-site-main.conf" ]; then
452-
NGINX_MAIN_TEMPLATE=".ddev/addon-metadata/ddev-kanopi-wp/config/nginx/nginx-site-main.conf"
453-
fi
454-
455-
if [ -f ".ddev/addon-metadata/ddev-kanopi-wp/config/nginx/nginx-site.conf" ]; then
456-
NGINX_SNIPPET_TEMPLATE=".ddev/addon-metadata/ddev-kanopi-wp/config/nginx/nginx-site.conf"
457-
fi
440+
# Get the actual docroot from DDEV configuration
441+
DOCROOT=$(grep '^docroot:' .ddev/config.yaml | cut -d: -f2 | tr -d ' ' || echo "web")
458442

459-
if [ -n "$NGINX_MAIN_TEMPLATE" ]; then
460-
# Get the actual docroot from DDEV configuration
461-
DOCROOT=$(grep '^docroot:' .ddev/config.yaml | cut -d: -f2 | tr -d ' ' || echo "web")
462-
463-
# Create complete nginx configuration to override DDEV's default
464-
# First remove #ddev-generated marker, then do all replacements
465-
sed '1s/^#ddev-generated$//' "$NGINX_MAIN_TEMPLATE" | \
466-
sed "s|PROXY_URL_PLACEHOLDER|$PROXY_URL|g; s|HOST_PLACEHOLDER|$PROXY_HOST|g; s|/var/www/html/public|/var/www/html/$DOCROOT|g" \
467-
> ".ddev/nginx_full/nginx-site.conf"
468-
echo " ✅ Complete nginx proxy configuration created (docroot: $DOCROOT)"
469-
elif [ -n "$NGINX_SNIPPET_TEMPLATE" ]; then
470-
# Fallback to snippet approach
471-
sed "s|PROXY_URL_PLACEHOLDER|$PROXY_URL|g; s|HOST_PLACEHOLDER|$PROXY_HOST|g" \
472-
"$NGINX_SNIPPET_TEMPLATE" > ".ddev/nginx/nginx-site.conf"
473-
echo " ✅ Nginx proxy snippet created"
443+
# Check if nginx_full/nginx-site.conf exists
444+
if [ -f ".ddev/nginx_full/nginx-site.conf" ]; then
445+
# Extract hosting domain and environment from PROXY_URL
446+
# Example: https://dev-sitename.pantheonsite.io -> domain=pantheonsite.io, env=dev
447+
PROXY_HOST=$(echo "$PROXY_URL" | sed 's|https\://||' | sed 's|http://||' | sed 's|/.*||')
448+
449+
# Determine hosting domain based on provider
450+
case "$HOST_PROVIDER" in
451+
"pantheon")
452+
HOSTING_DOMAIN="pantheonsite.io"
453+
;;
454+
"wpengine")
455+
HOSTING_DOMAIN="wpengine.com"
456+
;;
457+
"kinsta")
458+
HOSTING_DOMAIN="kinsta.cloud"
459+
;;
460+
*)
461+
HOSTING_DOMAIN=""
462+
;;
463+
esac
464+
465+
# Update the nginx configuration with actual values
466+
sed -i.bak \
467+
-e "s|HOSTING_ENV-HOSTING_SITE.HOSTING_DOMAIN|$PROXY_HOST|g" \
468+
-e "s|/var/www/html/web|/var/www/html/$DOCROOT|g" \
469+
".ddev/nginx_full/nginx-site.conf"
470+
rm -f ".ddev/nginx_full/nginx-site.conf.bak"
471+
472+
echo " ✅ Nginx proxy configuration updated (docroot: $DOCROOT, proxy: $PROXY_HOST)"
474473
else
475-
echo " ⚠️ Nginx template not found - proxy configuration not updated"
474+
echo " ⚠️ .ddev/nginx_full/nginx-site.conf not found - proxy configuration not updated"
476475
fi
477476
fi
478477

config/nginx/nginx-common.conf

Lines changed: 0 additions & 42 deletions
This file was deleted.

config/nginx/nginx-site.conf

Lines changed: 0 additions & 19 deletions
This file was deleted.

config/php/php.ini

Lines changed: 0 additions & 33 deletions
This file was deleted.

install.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ name: ddev-kanopi-wp
44
project_files:
55
- commands/
66
- config/
7+
- php
8+
- nginx_full
79
- scripts/
810

911
# DDEV version constraint

config/nginx/nginx-site-main.conf renamed to nginx_full/nginx-site.conf

Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
1-
#ddev-generated
2-
# ddev wordpress config with Kanopi proxy support
1+
# ddev wordpress config
32
# https://developer.wordpress.org/advanced-administration/server/web-server/nginx/
43

4+
# If you want to take over this file and customize it, remove the line above
5+
# and ddev will respect it and won't overwrite the file.
6+
# See https://ddev.readthedocs.io/en/stable/users/extend/customization-extendibility/#custom-nginx-configuration
7+
58
# Much of this config is adapted from
69
# https://codex.wordpress.org/Nginx
710

811
server {
912
listen 80 default_server;
1013
listen 443 ssl default_server;
1114

12-
root /var/www/html/public;
15+
root /var/www/html/web;
1316

1417
ssl_certificate /etc/ssl/certs/master.crt;
1518
ssl_certificate_key /etc/ssl/certs/master.key;
@@ -50,22 +53,14 @@ server {
5053
deny all;
5154
}
5255

53-
# Image proxy configuration for wp-content/uploads
54-
location ~ ^/wp-content/uploads/.* {
55-
try_files $uri @proxy;
56-
}
56+
# Try WordPress uploads locally then at a proxy URL
57+
location ~ ^/wp-content/uploads/.* {
58+
try_files $uri @rewrite @proxy;
59+
}
5760

58-
location @proxy {
59-
# Proxy missing uploads to hosting provider environment
60-
resolver 8.8.8.8;
61-
proxy_pass PROXY_URL_PLACEHOLDER$request_uri;
62-
proxy_set_header Host HOST_PLACEHOLDER;
63-
proxy_set_header X-Real-IP $remote_addr;
64-
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
65-
proxy_set_header X-Forwarded-Proto $scheme;
66-
proxy_ssl_verify off;
67-
proxy_intercept_errors on;
68-
}
61+
location @proxy {
62+
rewrite ^/(.*)$ https://HOSTING_ENV-HOSTING_SITE.HOSTING_DOMAIN/$1;
63+
}
6964

7065
location / {
7166
absolute_redirect off;
@@ -100,8 +95,8 @@ server {
10095

10196
# Expire rules for static content
10297

103-
# Media: images, icons, video, audio, HTC (exclude wp-content/uploads which has proxy)
104-
location ~* ^(?!/wp-content/uploads).*\.(jpg|jpeg|gif|png|ico|cur|gz|svg|svgz|mp4|ogg|ogv|webm|webp|htc)$ {
98+
# Media: images, icons, video, audio, HTC
99+
location ~* \.(jpg|jpeg|gif|png|ico|cur|gz|svg|svgz|mp4|ogg|ogv|webm|webp|htc)$ {
105100
expires max;
106101
log_not_found off;
107102
try_files $uri /index.php$is_args$args;
@@ -112,4 +107,4 @@ server {
112107
}
113108
include /etc/nginx/common.d/*.conf;
114109
include /mnt/ddev_config/nginx/*.conf;
115-
}
110+
}

php/php.ini

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#ddev-generated
2+
; Custom PHP configuration for Kanopi WordPress development
3+
4+
[php]
5+
; Memory limit for WordPress operations. Most hosting has low memory
6+
memory_limit = 256M
File renamed without changes.

0 commit comments

Comments
 (0)