# Apache Configuration for Connect-5
# Add this to your Apache virtual host configuration

# Enable required modules (run these commands first):
# sudo a2enmod proxy
# sudo a2enmod proxy_http
# sudo a2enmod proxy_wstunnel
# sudo a2enmod rewrite
# sudo systemctl restart apache2

<VirtualHost *:443>
    ServerName connect5.beyondcloud.technology
    
    # Your existing SSL and document root settings
    DocumentRoot /home/github2/apps/app-connect5
    
    # Proxy API requests to Node.js
    ProxyPreserveHost On
    ProxyPass /api http://localhost:3000/api
    ProxyPassReverse /api http://localhost:3000/api
    
    # Proxy Socket.io WebSocket requests
    ProxyPass /socket.io http://localhost:3000/socket.io
    ProxyPassReverse /socket.io http://localhost:3000/socket.io
    
    # WebSocket upgrade support
    RewriteEngine On
    RewriteCond %{HTTP:Upgrade} =websocket [NC]
    RewriteRule /(.*)           ws://localhost:3000/$1 [P,L]
    RewriteCond %{HTTP:Upgrade} !=websocket [NC]
    RewriteRule /(.*)           http://localhost:3000/$1 [P,L]
    
    # Your existing SSL configuration
    SSLEngine on
    # SSLCertificateFile /path/to/cert
    # SSLCertificateKeyFile /path/to/key
</VirtualHost>

# If you also need HTTP (port 80) redirect:
<VirtualHost *:80>
    ServerName connect5.beyondcloud.technology
    Redirect permanent / https://connect5.beyondcloud.technology/
</VirtualHost>
