# Softswitch Switchboard - Standalone Nginx Configuration
# Use this when Switchboard is installed on a separate server

server {
    listen 80;
    server_name _;

    access_log /var/log/nginx/switchboard_access.log;
    error_log /var/log/nginx/switchboard_error.log;

    # Monitoring API proxy (to Admin/API Server)
    # Update ADMIN_SERVER_IP with your Admin server IP
    location /monitoring-api/ {
        rewrite ^/monitoring-api/(.*) /$1 break;
        proxy_pass http://ADMIN_SERVER_IP:3500;
        
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
    }

    # Monitoring WebSocket (real-time updates)
    location /monitoring-ws {
        rewrite ^/monitoring-ws$ /ws break;
        rewrite ^/monitoring-ws/(.*)$ /ws/$1 break;
        proxy_pass http://ADMIN_SERVER_IP:3500;
        
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_set_header Host $host;
        
        proxy_read_timeout 86400;
    }

    # Switchboard Application (root)
    location / {
        root /var/www/softswitch/switchboard;
        index index.html;
        try_files $uri $uri/ /index.html;
    }
}
