NginxPulse Documentation
repository·main·Indexed 25 days ago
https://github.com/likaia/nginxpulseNginxPulse is a lightweight Nginx access log analysis and visualization dashboard providing real-time statistics, PV filtering, and IP geolocation. It supports deployment via Docker, Docker Compose, and as a standalone binary (requiring PostgreSQL for versions > 1.5.3). Key features include a mobile-optimized interface, configurable data retention, and a web-based initialization wizard.
What's inside NginxPulse
- NginxPulse is a lightweight Nginx access log analysis and visualization panel. It provides real-time statistics, PV (Page View) filtering, IP geolocation resolution, and client information parsing, making it suitable for visual analysis of Nginx access logs.
NginxPulse documentation index
mainThe NginxPulse Wiki provides detailed guides for the following topics:
Understand IP Geo resolution order and flow
mainNginxPulse resolves IP locations using a tiered approach from fastest to slowest:
- DB cache (
ip_geo_cache) - Local ip2region (v4/v6)
- Remote
ip-api.com(batch lookup)
If local lookups fail or return "unknown", the system falls back to the remote lookup.
Processing Flow
- Parsing writes IPs into the
ip_geo_pendingqueue. - A background task processes these in batches (default size: 500).
- Results are saved to
ip_geo_cacheand backfilled into log tables. - The cache is automatically trimmed when it exceeds the
system.ipGeoCacheLimitthreshold.
- DB cache (
Understand the NginxPulse project structure
mainThe project is organized into the following key directories:
cmd/nginxpulse/: The main entry point for the application.internal/: Core logic including:app/: Initialization and task scheduling.analytics/: Statistical logic and aggregation.enrich/: IP geolocation and PV filtering.ingest/: Log scanning, parsing, and database ingestion.server/: HTTP service and middleware.store/: PostgreSQL repository and schema.web/: API routing.webui/: Embedded frontend static assets.
webapp/: Frontend source code.webapp_mobile/: Mobile frontend source code (accessible via/m).configs/: Configuration files (nginxpulse_config.json,nginx_frontend.conf).scripts/: Build and deployment scripts (build_single.sh,dev_local.sh,publish_docker.sh).var/: Runtime data directory.
Understand the NginxPulse Log Parsing Workflow
mainNginxPulse follows a multi-stage process to ingest and enrich log data:
- Initial Scan: Parses logs from the "recent window" upon startup.
- Incremental Scan: A scheduled task continuously scans for new content based on
system.taskInterval. - Historical Backfill: Gradually processes historical logs in the background without blocking real-time parsing.
- IP Geo Backfill: Asynchronously parses and enriches IP geolocation data after logs are stored in the database.
Understand the NginxPulse Log Parsing Flow
mainNginxPulse follows a four-stage process for handling logs:
- Initial scan: Parses the recent window of logs immediately after startup.
- Incremental scan: Scans newly appended logs based on the
system.taskIntervalsetting. - Historical backfill: Processes older logs in the background to ensure historical data is available without blocking real-time parsing.
- IP geo backfill: Asynchronously resolves IP locations after the log entries have been inserted into the database.
Understand the IP Geolocation resolution order
mainNginxPulse resolves IP locations using a tiered approach from fastest to slowest to optimize performance:
- Database Cache: Checks the
ip_geo_cachefirst. - Local Libraries: Uses
ip2region(supporting both v4 and v6) for local lookups. - Remote API: If the local library returns "未知" (Unknown) or fails, it calls the remote interface (e.g.,
ip-api.com) in batches.
Optimization Tip: To minimize remote API calls and latency, ensure your local
ip2regionlibraries are updated to cover as many IP ranges as possible.- Database Cache: Checks the
Understand the NginxPulse directory structure
mainNginxPulse is organized into several key directories that define its functionality:
cmd/nginxpulse/main.go: The main program entry point.internal/: Contains the core logic:app/: Initialization and task scheduling.analytics/: Metrics definitions and aggregation.enrich/: IP geolocation and PV filtering.ingest/: Log scanning and parsing.server/: HTTP server and middleware.store/: PostgreSQL schema and database operations.web/: API route handlers.webui/dist/: Embedded frontend assets for single binary deployments.
webapp/: Frontend source code.webapp_mobile/: Mobile-specific frontend source code (accessed via/m).configs/: Configuration files includingnginxpulse_config.jsonandnginx_frontend.conf.scripts/: Automation scripts for building and running the project.var/: Runtime data directory.
Frontend Initialization Wizard Requirements
mainThe frontend implements a full-screen or masked initialization wizard that is only displayed when the backend reports
setup_required=true.Wizard Features:
- Multi-step workflow with a progress bar.
- "Advanced" collapsible sections for each step to hide complexity.
- Real-time validation for required fields and backend-driven validation error messages.
- JSON preview mode for the configuration before saving.
- Post-save notification: Users must be prompted to restart the service after saving configuration changes (specifically for changes involving ports, databases, or access keys) to ensure they take effect.
Mount Nginx logs in Docker
mainTo use host-side logs in a Docker container, mount the host directory to a path inside the container, then point NginxPulse's
logPathto that internal path.# Docker Compose volume mount volumes: - /var/log/nginx:/share/logs/nginx:ro# NginxPulse configuration { "name": "主站", "logPath": "/share/logs/nginx/access.log", "domains": ["example.com"], "logType": "nginx" }Run the Fumadocs development server
mainTo start the development server for the Fumadocs Next.js application, use thepnpm devcommand. Once running, the application is accessible athttp://localhost:3000.pnpm devOverride Mobile Bottom Navigation via URL
mainThe mobile interface (
/m/) allows temporary overrides of the navigation bar position using URL parameters. These settings are written to local storage and persist across subsequent page navigations.Parameter Priority:
tabbarBottomtakes precedence overtabbar.Values:
- Bottom Navigation (Truth):
1,true,yes,on,bottom. - Top Navigation (False):
0,false,no,off,top.
Usage Examples:
- Force bottom navigation:
https://example.com/m/?tabbarBottom=true - Force top navigation:
https://example.com/m/?tabbarBottom=false
- Bottom Navigation (Truth):