Repository navigation
GeoIP
oCMS Internal Analytics module supports GeoIP-based country detection using the MaxMind GeoLite2-Country database. The Sentinel module reads the same database to record the country of banned IPs.
When enabled, the analytics module detects and records the country of each visitor based on their IP address. This data appears in:
- Country breakdown statistics on the analytics dashboard
- Geographic distribution charts
MaxMind provides a free GeoLite2-Country database:
- Create a free account at MaxMind GeoLite2
- Download the GeoLite2-Country database in MMDB format
- Extract
GeoLite2-Country.mmdbto a location on your server
Set the OCMS_GEOIP_DB_PATH environment variable:
export OCMS_GEOIP_DB_PATH=/path/to/GeoLite2-Country.mmdbOr in your systemd service file:
[Service]
Environment="OCMS_GEOIP_DB_PATH=/opt/geoip/GeoLite2-Country.mmdb"The database is loaded at startup for optimal performance.
MaxMind updates the GeoLite2 databases weekly (Tuesdays). To update:
- Download the new database from MaxMind
- Replace the existing
.mmdbfile - Internal Analytics automatically detects file changes and reloads the database within an hour (the hourly
geoip_reloadjob listed at/admin/scheduler, scheduled only if the database loaded at startup)
Alternatively, restart oCMS to immediately load the new database. The Sentinel module loads the database only at startup, so it needs a restart to pick up a replaced file.
If the GeoIP database is not configured or cannot be loaded:
- The analytics module continues to function normally
- Country detection is silently disabled
- The "Countries" section shows "Unknown" for public addresses (private and loopback addresses still show as "Local Network")
- A startup message is logged: info when
OCMS_GEOIP_DB_PATHis unset, warning when the file cannot be loaded
- Database is loaded at startup (memory-mapped) and reloaded when the file changes
- Lookups are thread-safe and extremely fast (<1ms)
- Memory usage depends on database size (~5MB for GeoLite2-Country)
- Check if
OCMS_GEOIP_DB_PATHis set - Verify the file exists and is readable
- Check startup logs for GeoIP-related messages
- Ensure you're using the Country database, not City or ASN
- Check that visitors are not all from local/private IP ranges
- Verify the database file is not corrupted
- Traffic is coming from private or loopback IP ranges (10.x.x.x, 192.168.x.x, 172.16.x.x to 172.31.x.x, 127.x.x.x)
- If behind a reverse proxy, ensure it sends X-Forwarded-For or X-Real-IP and that its address is listed in
OCMS_TRUSTED_PROXIES; forwarding headers are ignored from any other peer - See Reverse Proxy for header configuration
- MaxMind GeoLite2 — Database downloads
- Reverse Proxy — Nginx/Apache header configuration
- Configuration — Environment variables reference
Getting Started
Core Features
- Content Management
- Media Library
- Taxonomy
- Menu Builder
- Forms
- Multi-Language
- SEO
- Feeds
- Video Embedding
- Agent-Ready
Administration
API & Integrations
Security
Theme Development
Module Development
Built-in Modules
- Module: Sentinel
- Module: Developer
- Module: DB Manager
- Module: Migrator
- Module: Informer
- Module: Demo Mode
- Module: Internal Analytics
- Module: External Analytics
- Module: Privacy
- Module: Embed
- Module: MCP Server
Deployment