add example in docker-compose, clarify README, add clearer validation, longer timeouts for websocket connections
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
#!/bin/sh
|
||||
# Alpine-based image uses /bin/sh (busybox ash), not bash
|
||||
set -e
|
||||
|
||||
# Set default backend URL if not provided
|
||||
# Set default backend URL if not provided (host:port format, no protocol)
|
||||
export BACKEND_URL="${BACKEND_URL:-backend:8000}"
|
||||
|
||||
echo "Configuring nginx with BACKEND_URL: ${BACKEND_URL}"
|
||||
@@ -11,7 +12,11 @@ echo "Configuring nginx with BACKEND_URL: ${BACKEND_URL}"
|
||||
envsubst '${BACKEND_URL}' < /etc/nginx/nginx.conf.template > /etc/nginx/nginx.conf
|
||||
|
||||
# Validate the generated nginx configuration before starting
|
||||
nginx -t -c /etc/nginx/nginx.conf
|
||||
echo "Validating nginx configuration..."
|
||||
if ! nginx -t -c /etc/nginx/nginx.conf; then
|
||||
echo "ERROR: nginx configuration validation failed" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Execute the main command (nginx)
|
||||
exec "$@"
|
||||
exec "$@"
|
||||
|
||||
@@ -27,7 +27,7 @@ http {
|
||||
proxy_pass http://${BACKEND_URL}/;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "upgrade";
|
||||
proxy_set_header Connection 'upgrade';
|
||||
proxy_set_header Host $host;
|
||||
proxy_cache_bypass $http_upgrade;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
@@ -52,12 +52,16 @@ http {
|
||||
proxy_pass http://${BACKEND_URL}/socket.io/;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "upgrade";
|
||||
proxy_set_header Connection 'upgrade';
|
||||
proxy_set_header Host $host;
|
||||
proxy_cache_bypass $http_upgrade;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
|
||||
# Longer timeouts for WebSocket connections
|
||||
proxy_read_timeout 3600s;
|
||||
proxy_send_timeout 3600s;
|
||||
}
|
||||
|
||||
# Frontend routes
|
||||
@@ -71,4 +75,4 @@ http {
|
||||
add_header Cache-Control "public, immutable";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user