<VirtualHost *:80>
    ServerName 10.40.180.74
    ServerAdmin webmaster@localhost

    # Frontend - Next.js 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]

    # Backend API endpoint (if needed separately)
    # ProxyPass /api http://localhost:8000/api
    # ProxyPassReverse /api http://localhost:8000/api

    # 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
</VirtualHost>
