Skip to content

Commit eb3b6be

Browse files
committed
Add loopback fix script for wp-env sync daemon support
Configure Apache to listen on port 8888 inside the Docker container so Cloudinary's self-pinging REST API requests resolve correctly.
1 parent d0c1ea0 commit eb3b6be

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

.wp-env/mu-plugins/.gitkeep

Whitespace-only changes.

.wp-env/scripts/fix-loopback.sh

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/bin/bash
2+
# Fix loopback requests in wp-env Docker environment.
3+
#
4+
# WordPress in wp-env thinks its URL is localhost:8888, but inside the
5+
# container Apache only listens on port 80. This causes self-pinging
6+
# REST API requests (used by Cloudinary's sync daemon) to fail with
7+
# cURL error 7. Adding port 8888 to Apache resolves this.
8+
#
9+
# This script finds the wp-env WordPress container and configures Apache
10+
# to also listen on port 8888, enabling loopback requests to succeed.
11+
12+
# Find the wp-env wordpress container (exclude tests container).
13+
CONTAINER=$(docker ps --format '{{.Names}}' | grep -E 'wordpress-1$' | grep -v tests | head -1)
14+
15+
if [ -z "$CONTAINER" ]; then
16+
echo "Warning: Could not find wp-env WordPress container. Loopback fix skipped."
17+
exit 0
18+
fi
19+
20+
# Add Listen 8888 if not already present, then graceful restart Apache.
21+
docker exec "$CONTAINER" bash -c \
22+
"grep -q 'Listen 8888' /etc/apache2/ports.conf || (echo 'Listen 8888' >> /etc/apache2/ports.conf && apache2ctl graceful)" 2>/dev/null
23+
24+
if [ $? -eq 0 ]; then
25+
echo "Loopback fix applied: Apache now also listens on port 8888 inside the container."
26+
else
27+
echo "Warning: Failed to apply loopback fix."
28+
fi

0 commit comments

Comments
 (0)