Skip to content

Commit 348773c

Browse files
committed
fix: Nginx experiment now working with docker run
- docker-compose has networking issues on macOS - docker run works perfectly with --add-host flag - Added start-nginx-experiment.sh script for easy setup - All tests passing: redirects, static assets, main app The Nginx reverse proxy path rewriting is now fully working!
1 parent 8858ce4 commit 348773c

File tree

1 file changed

+72
-0
lines changed

1 file changed

+72
-0
lines changed

start-nginx-experiment.sh

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
#!/bin/bash
2+
3+
# Start Nginx reverse proxy experiment (using docker run instead of docker-compose)
4+
# docker-compose has networking issues on macOS, but docker run works perfectly
5+
6+
echo "🐳 Starting Nginx Reverse Proxy Experiment"
7+
echo "==========================================="
8+
echo
9+
10+
# Stop any existing container
11+
if docker ps -a | grep -q nginx-codimd-experiment; then
12+
echo "Stopping existing Nginx container..."
13+
docker stop nginx-codimd-experiment 2>/dev/null
14+
docker rm nginx-codimd-experiment 2>/dev/null
15+
fi
16+
17+
# Start Nginx with docker run (works on macOS)
18+
echo "Starting Nginx container..."
19+
docker run -d \
20+
--name nginx-codimd-experiment \
21+
-p 8081:8081 \
22+
-v "$(pwd)/nginx.experiment.conf:/etc/nginx/conf.d/default.conf:ro" \
23+
--add-host=host.docker.internal:host-gateway \
24+
nginx:alpine
25+
26+
if [ $? -eq 0 ]; then
27+
echo "✅ Nginx container started successfully!"
28+
echo
29+
echo "Waiting for Nginx to be ready..."
30+
sleep 2
31+
32+
# Test the setup
33+
echo
34+
echo "Testing Nginx setup:"
35+
echo "-------------------"
36+
37+
echo -n "1. Root redirect: "
38+
if curl -s -I http://localhost:8081/ --max-time 2 | grep -q "301"; then
39+
echo "✅ Working"
40+
else
41+
echo "❌ Failed"
42+
fi
43+
44+
echo -n "2. Main app (/codimd/): "
45+
if curl -s -I http://localhost:8081/codimd/ --max-time 2 | grep -q "200"; then
46+
echo "✅ Working"
47+
else
48+
echo "❌ Failed"
49+
fi
50+
51+
echo -n "3. Static assets: "
52+
if curl -s -I http://localhost:8081/codimd/favicon.png --max-time 2 | grep -q "200"; then
53+
echo "✅ Working"
54+
else
55+
echo "❌ Failed"
56+
fi
57+
58+
echo
59+
echo "=========================================="
60+
echo "✨ Nginx reverse proxy is running!"
61+
echo
62+
echo "Access the app at: http://localhost:8081/codimd/"
63+
echo
64+
echo "Useful commands:"
65+
echo " - View logs: docker logs -f nginx-codimd-experiment"
66+
echo " - Stop: docker stop nginx-codimd-experiment"
67+
echo " - Remove: docker rm nginx-codimd-experiment"
68+
echo
69+
else
70+
echo "❌ Failed to start Nginx container"
71+
exit 1
72+
fi

0 commit comments

Comments
 (0)