import React, { useEffect, useState } from 'react' import { Server, RefreshCw, RotateCcw, CheckCircle, XCircle } from 'lucide-react' import { api } from '../api/client' export default function WebServer() { const [status, setStatus] = useState<{ nginx: { active: boolean }; apache: { active: boolean } } | null>(null) const [vhosts, setVhosts] = useState<{ domain: string; path: string }[]>([]) const [logs, setLogs] = useState<{ lines: string[] } | null>(null) const [logType, setLogType] = useState<'access' | 'error'>('access') const [loading, setLoading] = useState(false) const [testResult, setTestResult] = useState(null) const fetch = async () => { setLoading(true) try { const [s, v, l] = await Promise.all([ api.get('/whm/webserver/status'), api.get('/whm/webserver/vhosts'), api.get(`/whm/webserver/logs/${logType}`), ]) setStatus(s.data.data); setVhosts(v.data.data); setLogs(l.data.data) } finally { setLoading(false) } } useEffect(() => { fetch() }, [logType]) const testConfig = async () => { const r = await api.post('/whm/webserver/nginx/test') setTestResult(r.data.data.output) } const reload = async () => { try { await api.post('/whm/webserver/nginx/reload'); fetch() } catch (err: unknown) { alert((err as { response?: { data?: { error?: string } } })?.response?.data?.error ?? 'Reload failed') } } return (

Web Server

Nginx and Apache management

{status && (
{[['nginx', status.nginx.active], ['apache2', status.apache.active]].map(([name, active]) => (
{name}
{active ? : }
))}
)}
{testResult && (
{testResult}
)}

Logs

{(['access', 'error'] as const).map(t => ( ))}
            {logs?.lines.slice(-100).join('\n') ?? 'Loading...'}
          
) }