# Vida Chart — Apache HTTPS (SSL) vhost reverse-proxy include for cPanel/EA4
# Install to:
#   /etc/apache2/conf.d/userdata/ssl/2_4/vidanexusai/chart.vidanexus.ai/vidachart.conf
# Then: /usr/local/cpanel/scripts/ensure_vhost_includes --user=vidanexusai
#       /usr/local/cpanel/scripts/rebuildhttpdconf && /usr/local/cpanel/scripts/restartsrv_httpd
#
# Requires EA4 modules: ea-apache24-mod_proxy, mod_proxy_http, mod_proxy_wstunnel

# Let cPanel AutoSSL / DCV + ACME challenges serve from the docroot — never proxy them,
# otherwise AutoSSL cert issuance fails (Node returns 404 for these paths).
ProxyPass /.well-known/ !

# WebSocket / SSE upgrade → Node
RewriteEngine On
RewriteCond %{HTTP:Upgrade} =websocket [NC]
RewriteRule ^/?(.*) ws://127.0.0.1:3000/$1 [P,L]

ProxyPreserveHost On
ProxyTimeout 3600

# flushpackets=on is REQUIRED for Server-Sent Events (the realtime dashboard) to stream;
# without it Apache buffers the response and the Live tab stalls.
ProxyPass        /  http://127.0.0.1:3000/ flushpackets=on
ProxyPassReverse /  http://127.0.0.1:3000/
