Market Data Service is a high-performance financial data API that provides comprehensive Symbol prices of different markets through both RESTful endpoints and real-time WebSocket connections.

nginx-entrypoint.sh 1.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #!/bin/sh
  2. # Nginx entrypoint script that processes environment variables in config
  3. set -e
  4. # Default domain name (can be overridden)
  5. DOMAIN_NAME="${DOMAIN_NAME:-default}"
  6. # Process the template config file (which is read-only mounted)
  7. # and create a processed version in a writable location
  8. PROCESSED_CONFIG="/tmp/nginx.conf"
  9. # Check if SSL certificates exist
  10. CERT_PATH="/etc/letsencrypt/live/${DOMAIN_NAME}/fullchain.pem"
  11. KEY_PATH="/etc/letsencrypt/live/${DOMAIN_NAME}/privkey.pem"
  12. # Replace DOMAIN_NAME_PLACEHOLDER in the config file (if it exists)
  13. # If no placeholder, just copy the config
  14. if grep -q "DOMAIN_NAME_PLACEHOLDER" /etc/nginx/nginx.conf 2>/dev/null; then
  15. sed "s|DOMAIN_NAME_PLACEHOLDER|${DOMAIN_NAME}|g" /etc/nginx/nginx.conf > "$PROCESSED_CONFIG"
  16. else
  17. cp /etc/nginx/nginx.conf "$PROCESSED_CONFIG"
  18. fi
  19. # If certificates don't exist, just use the config as-is (should be no-ssl config)
  20. if [ ! -f "$CERT_PATH" ] || [ ! -f "$KEY_PATH" ]; then
  21. echo "WARNING: SSL certificates not found at $CERT_PATH"
  22. echo "Using HTTP-only configuration for ACME challenges."
  23. fi
  24. # Start nginx with auto-reload for certificate updates
  25. # Reload every 6 hours OR when certbot signals a renewal
  26. # Use the processed config file
  27. exec /bin/sh -c "
  28. # Watch for certbot reload signal
  29. (while :; do
  30. if [ -f /var/run/certbot-reload/reload ]; then
  31. echo 'Certificate renewed, reloading nginx...'
  32. nginx -s reload -c $PROCESSED_CONFIG
  33. rm -f /var/run/certbot-reload/reload
  34. fi
  35. sleep 60
  36. done) &
  37. # Periodic reload every 6 hours
  38. (while :; do sleep 6h & wait \${!}; nginx -s reload -c $PROCESSED_CONFIG; done) &
  39. # Start nginx with processed config
  40. nginx -c $PROCESSED_CONFIG -g 'daemon off;'
  41. "