Complete Feature & Architecture DocumentationReact Router v8.5.1 • SSRlogs.ibnuhajar.io

VPS /var/log Monitoring & Security Analytics Guide

Full technical reference covering system architecture, Keycloak OIDC Single Sign-On, real-time log parsing, SSH/Fail2ban/UFW intrusion analytics, Server-Sent Events (SSE) live tailing, binary/gzipped log decoding, and VPS operational runbooks.

1. Platform Architecture & Technology Stack

How logs.ibnuhajar.io processes, analyzes, and streams /var/log data

The monitoring dashboard is built as a full-stack Server-Side Rendered (SSR) application powered by React Router 8 (`v8.5.1`) running on Node.js (`127.0.0.1:3005`) behind an Nginx TLS 1.3 Reverse Proxy. All filesystem access to /var/log executes strictly inside server-only loaders and resource routes (app/services/logs.server.ts), ensuring zero raw filesystem exposure to unauthenticated clients.

Request & Telemetry Data Flow
┌──────────────────────┐     HTTPS (TLS 1.3)     ┌──────────────────────────────┐
│  Browser Client UI   │ ◄─────────────────────► │  Nginx Reverse Proxy (:443)  │
│  React Router 8 DOM  │   SSE (Unbuffered)      │  logs.ibnuhajar.io          │
└──────────┬───────────┘                         └──────────────┬───────────────┘
           │                                                    │
           │ OAuth2 / OIDC (PKCE S256)                          │ HTTP/1.1 (127.0.0.1:3005)
           ▼                                                    ▼
┌──────────────────────┐                         ┌──────────────────────────────┐
│  Keycloak 26.8.2 SSO │ ◄─────────────────────► │  React Router 8 SSR Server   │
│  auth.ibnuhajar.io  │   Token & UserInfo      │  Loaders & Resource Routes   │
└──────────────────────┘                         └──────────────┬───────────────┘
                                                                │
                                        ┌───────────────────────┼───────────────────────┐
                                        ▼                       ▼                       ▼
                               ┌─────────────────┐     ┌─────────────────┐     ┌─────────────────┐
                               │ Tail Byte Reader│     │  zlib .gz Gunzip│     │  Binary Decoders│
                               │ syslog/auth/ufw │     │  *.log.*.gz     │     │  last/lastb     │
                               └─────────────────┘     └─────────────────┘     └─────────────────┘
Frontend & SSR
React Router 8.5.1

Framework mode with React 19, Vite 8 Environment API, Tailwind CSS v4, and Lucide icons.

Identity & Access
Keycloak 26.8.2 OIDC

Centralized SSO via auth.ibnuhajar.io using PKCE S256 and signed HTTP-only cookies.

Log Processing
Node.js v26 Native I/O

Fixed-window byte tailing, native zlib gunzip decompression, and utmp binary decoders.

Edge & Process
Nginx + Systemd

Managed via ibnuhajar-logs.service on port 3005 with Let's Encrypt auto-renewing SSL.

2. Authentication & Keycloak OIDC SSO Integration

How Single Sign-On with auth.ibnuhajar.io protects sensitive /var/log data

Because /var/log contains sensitive IP addresses, SSH usernames, and system telemetry, every dashboard view and API endpoint is guarded by requireUser(request) in app/services/auth.server.ts.

  • PKCE S256 Protection: Every login generates a cryptographic 32-byte code_verifier, SHA-256 code_challenge, and anti-CSRF state token stored in an encrypted session cookie.
  • Dual-Realm Support: Users can sign in on /login using either the exploration-lab application realm or the master administrator realm.
  • Federated Single Sign-Out: Clicking the logout button calls /auth/logout, destroying the local session cookie and redirecting to Keycloak's end_session_endpoint with id_token_hint.
OIDC Configuration Parameters
OIDC Providerhttps://auth.ibnuhajar.io
Client IDlogs-monitoring
Supported Realmsexploration-lab, master
Callback URIhttps://logs.ibnuhajar.io/auth/callback
Session Cookie__ibnuhajar_logs_session (HttpOnly, 12h)

3. Feature Guide: System & Security Overview (/)

Real-time executive summary of VPS health, log volume, and intrusion telemetry

Go to Overview
1. /var/log Footprint & Disk Telemetry

Calculates total bytes across all discovered log files, counts files modified in the last 24 hours, and queries df -h /var/log for partition utilization percentage and available free space.

2. Host Uptime, Load Average & Memory

Displays the VPS hostname, system uptime, RAM usage percentage, and Linux 1m / 5m / 15m load averages via Node's node:os module, with a manual Refresh Metrics revalidation button.

3. 12-Hour Log Event Distribution Chart

Buckets log timestamps over the past 12 hours into stacked bars segmented by INFO, SECURITY, and ERROR/WARN with interactive hover tooltips.

4. Critical Alerts Feed & Storage Ranking

Presents a unified feed of the latest security and critical error events alongside a ranked progress-bar list of the largest files inside /var/log.

4. Feature Guide: /var/log File Explorer & Inspector (/explorer)

Deep search, regex filtering, .gz archive decompression, and binary login log decoding

Open Explorer
Transparent .gz Archive Reader

Rotated gzipped logs (such as php8.5-fpm.log.2.gz) are automatically decompressed in-memory using zlib.gunzipSync and can be searched or downloaded as plain text with one click.

Binary Login Decoders (utmp/btmp)

Clicking binary files like btmp, btmp.1, wtmp, or lastlog automatically runs lastb, last, or lastlog to render human-readable login history.

Structured vs. Raw View + IP Pivot

Toggle between parsed structured rows (with severity badges, timestamps, service tags, and clickable IP filter pills) and raw terminal output, or export the file via /api/download.

Interactive Regex Search Cheatsheet

Click any pattern below to run it directly inside the Log Explorer with Regex mode enabled

Use CaseTarget FileRegex PatternAction
SSH Brute-Force & Auth Failures
Matches all failed SSH login attempts, PAM auth failures, and invalid username probes.
auth.log(Failed password|Invalid user|authentication failure)Try Pattern
Specific Attacker Subnet or IP
Finds all events originating from a specific /16 IPv4 CIDR block.
auth.log\b143\.246\.\d+\.\d+\bTry Pattern
Fail2ban Jail Ban / Unban Events
Isolates active IP ban and unban enforcement actions triggered by Fail2ban.
fail2ban.log\[sshd\]\s+(Ban|Unban)\s+\d+\.\d+\.\d+\.\d+Try Pattern
UFW Blocked SYN Scans on Sensitive Ports
Detects external TCP SYN packets targeting SSH, MySQL, PostgreSQL, Redis, or admin ports.
ufw.logPROTO=TCP.*DPT=(22|3306|5432|6379|8080|8082).*SYNTry Pattern
Nginx 4xx / 5xx Error Status Codes
Matches HTTP 401/403/404/429 client errors and 500/502/503/504 upstream errors.
nginx/access.log"\s+(40[134]|429|50[0234])\s+\d+Try Pattern
WordPress / Env / Git Scanner Probes
Identifies automated vulnerability scanners probing common web paths.
nginx/access.log(wp-admin|wp-login|\.env|\.git|xmlrpc\.php|phpmyadmin)Try Pattern
Kernel Out-of-Memory (OOM) or Segfaults
Finds critical Linux kernel memory exhaustion or process crash events.
kern.log(Out of memory|Killed process|segfault|oom-kill)Try Pattern

5. Feature Guide: Security, Firewall & Intrusion Center (/security)

Automated correlation across auth.log, fail2ban.log, ufw.log, and nginx logs

Open Security Center
SSH Brute-Force & Username Enumeration (auth.log)

Extracts every Failed password and Invalid user event, ranking the Top Attacking IPv4 Addresses along with the specific usernames each IP attempted to compromise (e.g., root, admin, postgres). Clicking any attacker IP pivots directly to the filtered auth.log audit trail.

Fail2ban Jail Enforcement (fail2ban.log)

Tracks total Found offender matches, Ban actions, and Unban expirations across active jails ([sshd]), providing a live chronological feed of banned IPs.

UFW Firewall Port Scan Telemetry (ufw.log)

Parses Linux kernel [UFW BLOCK] packets by protocol (TCP, UDP, ICMP), maps destination ports (DPT=) to well-known services (SSH, HTTP/S, PostgreSQL, MySQL, Redis, RDP), and ranks the most aggressive port-scanner IPs.

Nginx Traffic & TLS/SSL Error Inspector

Aggregates HTTP response status codes (2xx, 3xx, 4xx, 5xx), identifies top client IPs and requested URL paths, and surfaces recent [crit] / [error] entries from nginx/error.log.

6. Feature Guide: Real-Time Live Tail SSE Stream (/live)

Sub-second Server-Sent Events streaming for active /var/log files

Open Live Tail
1. Initial Context Burst (`event: init`)

Upon connecting to /api/stream?file=..., the server immediately reads the last 24 KB (~40 lines) of the file, parses each line, and pushes an initial snapshot so the terminal is populated right away.

2. Byte-Offset Delta Polling (`event: lines`)

Every 1,000ms, the server checks fsp.stat(fullPath). When new bytes are appended, only the newly written byte range (stat.size - currentSize) is read and streamed. If the file is rotated (stat.size < currentSize), the offset automatically resets to 0.

3. Interactive Terminal Controls

Includes Pause / Resume Stream, Auto-Scroll ON/OFF, instant client-side keyword and severity filtering (ERROR, SECURITY, WARN, INFO), and a 500-line rolling ring buffer.

7. /var/log Monitored File Dictionary

Reference guide to system, security, web, database, and binary log files on this VPS

File PathCategoryFormat / ParserDescription & Telemetry Purpose
/var/log/syslogSystemISO-8601 SyslogPrimary system activity log recording systemd service events, cron jobs, daemon messages, and kernel netfilter logs.
/var/log/auth.logSecurityISO-8601 PAM/SSHDAuthentication and authorization events including OpenSSH logins, sudo usage, PAM checks, and brute-force attempts.
/var/log/fail2ban.logSecurityFail2ban TimestampedIntrusion prevention daemon log tracking IP pattern matches (Found), temporary firewall bans (Ban), and expirations (Unban).
/var/log/ufw.logSecurityKernel NetfilterUncomplicated Firewall packet log capturing blocked incoming packets ([UFW BLOCK]) with SRC/DST IP, PROTO, SPT, and DPT.
/var/log/kern.logSystemISO-8601 KernelLinux kernel ring buffer and subsystem messages, hardware/driver events, firewall drops, and OOM killer notices.
/var/log/nginx/access.logWeb & ProxyNginx CombinedEvery HTTP/HTTPS request processed by Nginx across ibnuhajar.io, auth.ibnuhajar.io, and logs.ibnuhajar.io.
/var/log/nginx/error.logWeb & ProxyNginx ErrorNginx reverse proxy upstream failures, TLS/SSL handshake errors, and configuration warnings.
/var/log/btmp & btmp.1Security (Binary)utmp Binary (lastb)Binary record of bad/failed login attempts. Automatically decoded into human-readable rows via `lastb -f`.
/var/log/wtmpSecurity (Binary)utmp Binary (last)Binary history of all successful user logins, logouts, and system reboots. Automatically decoded via `last -f`.
/var/log/lastlogSecurity (Binary)lastlog BinaryBinary database of the most recent login timestamp for every system account. Decoded automatically via `lastlog`.
/var/log/postgresql/*.logDatabase & AppsPostgreSQL LogPostgreSQL 18 cluster startup, checkpoint, connection, and query error logs (including Keycloak backing DB).
/var/log/php8.5-fpm.log*Database & AppsPHP-FPM / Gzip (.gz)PHP 8.5 FastCGI Process Manager worker pool lifecycle events, including rotated `.gz` compressed archives.
/var/log/dpkg.log & apt/*Package & UpdatesDebian Package LogAudit trail of apt/dpkg package installations, upgrades, and unattended security updates.
/var/log/letsencrypt/letsencrypt.logWeb & ProxyCertbot Python LogACME certificate issuance and automated renewal logs for *.ibnuhajar.io domains.

8. HTTP Resource Routes & Security Controls

Internal API endpoints and sandbox protections enforcing read-only /var/log safety

Application Endpoints
GET /api/stream?file=<relativePath>

Streams real-time log lines via text/event-stream with 15s keep-alive heartbeats and X-Accel-Buffering: no.

GET /api/download?file=<relativePath>&decompress=1

Downloads any log file inside /var/log. Passing decompress=1 on a .gz file gunzips it on the fly and serves a .txt attachment.

GET /auth/login • /auth/callback • /auth/logout

Handles OIDC PKCE redirect, token exchange, UserInfo lookup, and federated logout.

Defense-in-Depth Security Controls
  • Strict Path Traversal Prevention: resolveSafeLogPath() resolves all requested paths against /var/log and throws an immediate error if a path attempts ../ traversal outside /var/log.
  • Read-Only Non-Destructive Access: The application never modifies, truncates, or deletes any file in /var/log.
  • Hardened Nginx Headers: Enforces Strict-Transport-Security, X-Content-Type-Options: nosniff, X-Frame-Options: SAMEORIGIN, and Content-Security-Policy via /etc/nginx/snippets/site-security.conf.

9. VPS Operations, Systemd & Nginx Administration Runbook

Commands for managing, rebuilding, and monitoring logs.ibnuhajar.io on the VPS

Systemd Service Management (ibnuhajar-logs.service)

# Check service status & resource consumption
systemctl status ibnuhajar-logs.service

# Restart service after configuration changes
systemctl restart ibnuhajar-logs.service

# View real-time application stdout/stderr logs
journalctl -u ibnuhajar-logs.service -f

Building & Deploying Code Updates

cd /root/AIEngineer/LogsMonitoring

# Run React Router 8 typegen & TypeScript validation
npm run typecheck

# Build production client & SSR bundles
npm run build

# Restart the production systemd service
systemctl restart ibnuhajar-logs.service

Nginx Reverse Proxy & Let's Encrypt SSL

# Configuration file location
cat /etc/nginx/sites-available/logs.ibnuhajar.io

# Test Nginx syntax & reload gracefully
nginx -t && systemctl reload nginx

# Test automated Let's Encrypt certificate renewal
certbot renew --dry-run

Keycloak OIDC Container (auth.ibnuhajar.io)

cd /opt/keycloak

# Check Keycloak container status & health
docker compose ps
curl -fsS http://127.0.0.1:9002/health/ready

# Verify OIDC discovery endpoint
curl -s https://auth.ibnuhajar.io/realms/exploration-lab/.well-known/openid-configuration | jq .