"use client"; import { useFormState } from "react-dom"; import { Alert, Box, Button, Card, CardContent, Checkbox, FormControlLabel, MenuItem, Stack, TextField, Typography } from "@mui/material"; import type { GeneralSettings, AuthentikSettings, MetricsSettings, LoggingSettings } from "@/src/lib/settings"; import { updateCloudflareSettingsAction, updateGeneralSettingsAction, updateAuthentikSettingsAction, updateMetricsSettingsAction, updateLoggingSettingsAction } from "./actions"; type Props = { general: GeneralSettings | null; cloudflare: { hasToken: boolean; zoneId?: string; accountId?: string; }; authentik: AuthentikSettings | null; metrics: MetricsSettings | null; logging: LoggingSettings | null; }; export default function SettingsClient({ general, cloudflare, authentik, metrics, logging }: Props) { const [generalState, generalFormAction] = useFormState(updateGeneralSettingsAction, null); const [cloudflareState, cloudflareFormAction] = useFormState(updateCloudflareSettingsAction, null); const [authentikState, authentikFormAction] = useFormState(updateAuthentikSettingsAction, null); const [metricsState, metricsFormAction] = useFormState(updateMetricsSettingsAction, null); const [loggingState, loggingFormAction] = useFormState(updateLoggingSettingsAction, null); return ( Settings Configure organization-wide defaults and DNS automation. General {generalState?.message && ( {generalState.message} )} Cloudflare DNS Configure a Cloudflare API token with Zone.DNS Edit permissions to enable DNS-01 challenges for wildcard certificates. {cloudflare.hasToken && ( A Cloudflare API token is already configured. Leave the token field blank to keep it, or select “Remove existing token” to delete it. )} {cloudflareState?.message && ( {cloudflareState.message} )} } label="Remove existing token" disabled={!cloudflare.hasToken} /> Authentik Defaults Set default Authentik forward authentication values. These will be pre-filled when creating new proxy hosts but can be customized per host. {authentikState?.message && ( {authentikState.message} )} Metrics & Monitoring Enable Caddy metrics exposure for monitoring with Prometheus, Grafana, or other observability tools. Metrics will be available at http://caddy:{metrics?.port ?? 9090}/metrics on a separate port (NOT the admin API port for security). {metricsState?.message && ( {metricsState.message} )} } label="Enable metrics endpoint" /> After enabling metrics, configure your monitoring tool to scrape http://caddy-proxy-manager-caddy:{metrics?.port ?? 9090}/metrics from within the Docker network. To expose metrics externally, add a port mapping like "{metrics?.port ?? 9090}:{metrics?.port ?? 9090}" in docker-compose.yml. Access Logging Enable HTTP access logging to track all requests going through your proxy hosts. Logs will be stored in the caddy-logs directory and mounted at /logs/access.log inside the container. {loggingState?.message && ( {loggingState.message} )} } label="Enable access logging" /> JSON Console (Common Log Format) Access logs will be available at ./caddy-logs/access.log on the host machine. You can tail them with: docker exec caddy-proxy-manager-caddy tail -f /logs/access.log ); }