<VirtualHost *:80>
    ServerName 10.40.180.74
    ServerAdmin admin@mcube.com

    # Frontend - Next.js production server on port 3000
    ProxyPreserveHost On
    ProxyPass / http://localhost:3000/
    ProxyPassReverse / http://localhost:3000/

    # WebSocket support for LiveKit
    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]

    # Logging
    ErrorLog ${APACHE_LOG_DIR}/livekit-voicebot-error.log
    CustomLog ${APACHE_LOG_DIR}/livekit-voicebot-access.log combined

    # Security headers
    Header always set X-Frame-Options "SAMEORIGIN"
    Header always set X-Content-Type-Options "nosniff"
    Header always set X-XSS-Protection "1; mode=block"

    # Allow larger uploads for audio/video
    LimitRequestBody 104857600

    # Timeout settings for long-running connections
    ProxyTimeout 300
    TimeOut 300
</VirtualHost>
