# Vigthoria VS Code Extension - Monitoring Services
# SAFE ADDITION - Does not conflict with existing services
# Add this to the END of your Caddyfile after backing up

# VS Code Extension Monitoring Dashboard (Port 3001 - SAFE, no conflicts)
monitor.vigthoria.io {
    reverse_proxy localhost:3001 {
        header_up Host {host}
        header_up X-Real-IP {remote}
        header_up X-Forwarded-For {remote}
        header_up X-Forwarded-Proto {scheme}
    }
    
    # Security headers
    header {
        X-Frame-Options "SAMEORIGIN"
        X-XSS-Protection "1; mode=block"
        X-Content-Type-Options "nosniff"
        Referrer-Policy "no-referrer-when-downgrade"
    }
    
    encode gzip
}

# Prometheus Metrics (Port 9090 - Standard)
metrics.vigthoria.io {
    reverse_proxy localhost:9090 {
        header_up Host {host}
        header_up X-Real-IP {remote}
        header_up X-Forwarded-For {remote}
        header_up X-Forwarded-Proto {scheme}
    }
    
    # Basic auth for metrics (optional)
    # basicauth {
    #     admin $2a$14$hashed_password_here
    # }
}

# VS Code Extension API (Port 8002 - Extension communication)
extension.vigthoria.io {
    # Handle WebSocket connections for real-time extension communication
    @websockets {
        header Connection *Upgrade*
        header Upgrade websocket
    }
    handle @websockets {
        reverse_proxy localhost:8002
    }
    
    # Regular API requests
    reverse_proxy localhost:8002 {
        header_up Host {host}
        header_up X-Real-IP {remote}
        header_up X-Forwarded-For {remote}
        header_up X-Forwarded-Proto {scheme}
    }
    
    # CORS for extension development
    header {
        Access-Control-Allow-Origin "*"
        Access-Control-Allow-Methods "GET, POST, PUT, DELETE, OPTIONS"
        Access-Control-Allow-Headers "Content-Type, Authorization, X-VS-Code-Extension"
    }
    
    encode gzip
}
