178c2997bd0482a4abe2c5cc101557587af551c6
Geofeed Manager
A complete solution for managing RFC 8805 compliant IP geolocation feeds (geofeeds). This system provides a modern web interface for managing geofeed entries, stores data in MariaDB/MySQL, and automatically exports to BunnyCDN via n8n workflows.
Features
- Modern Apple-esque UI - Clean, responsive interface for managing geofeed entries
- RFC 8805 Compliant - Generates valid geofeed CSV files per the specification
- CRUD Operations - Create, read, update, and delete geofeed entries
- Search & Filter - Find entries by IP prefix, city, region, or country
- Audit Logging - Track all changes to your geofeed
- Automated Export - n8n workflow exports to BunnyCDN hourly
- CSRF Protection - Secure form submissions
Directory Structure
geofeed-manager/
├── database/
│ ├── schema.sql # Database schema
│ └── import_csv.php # CSV import utility
├── webapp/
│ ├── config.php # Configuration & helpers
│ ├── api.php # RESTful API endpoints
│ └── index.php # Main web interface
└── n8n/
└── geofeed-export-workflow.json # n8n workflow
Installation (Docker)
Quick Start
- Clone and configure:
# Copy environment template
cp .env.example .env
# Edit with your passwords
nano .env
- Start the containers:
docker compose up -d
- Import your existing geofeed:
chmod +x import-geofeed.sh
./import-geofeed.sh https://store.prpl.uk/geofeed.csv
- Access the web interface:
- Web App: http://localhost:8080
- phpMyAdmin (optional): http://localhost:8081
With phpMyAdmin (for database admin)
docker compose --profile admin up -d
Container Details
| Service | Port | Description |
|---|---|---|
| webapp | 8080 | PHP web interface |
| mariadb | 3306 | MariaDB database (exposed for n8n) |
| phpmyadmin | 8081 | Database admin (optional) |
Connecting n8n to the Database
In n8n, create a MySQL credential with:
- Host: Your server IP or hostname (not
localhostunless n8n is on the same machine) - Port: 3306 (or your configured
DB_PORT) - Database: geofeed_manager
- User: geofeed (or your configured
DB_USER) - Password: Your configured
DB_PASSWORD
Installation (Manual)
1. Database Setup
Create the database and tables:
mysql -u root -p < database/schema.sql
2. Import Existing Geofeed (Optional)
export DB_HOST=localhost
export DB_NAME=geofeed_manager
export DB_USER=your_user
export DB_PASS=your_password
php database/import_csv.php https://store.prpl.uk/geofeed.csv
3. Web Application Setup
- Copy the
webapp/directory to your web server:
cp -r webapp/ /var/www/html/geofeed/
- Configure your web server (Apache example):
<VirtualHost *:80>
ServerName geofeed.yourdomain.com
DocumentRoot /var/www/html/geofeed
<Directory /var/www/html/geofeed>
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
- Set environment variables or update
config.php:
export DB_HOST=localhost
export DB_NAME=geofeed_manager
export DB_USER=your_user
export DB_PASS=your_password
4. n8n Workflow Setup
-
In n8n, go to Settings > Environment Variables and add:
BUNNY_STORAGE_ZONE- Your BunnyCDN storage zone nameBUNNY_API_KEY- Your BunnyCDN Storage API key
-
Create MySQL credentials in n8n:
- Go to Credentials
- Add new MySQL credential
- Configure with your database details
- Note the credential ID
-
Import the workflow:
- Go to Workflows
- Click Import from File
- Select
n8n/geofeed-export-workflow.json
-
Update credential references:
- Open the imported workflow
- For each MySQL node, select your MySQL credential
- Save the workflow
-
Activate the workflow to start hourly exports
API Reference
List Entries
GET api.php?action=list&page=1&limit=25&search=term&country=GB
Get Single Entry
GET api.php?action=get&id=123
Create Entry
POST api.php?action=create
Content-Type: application/json
{
"ip_prefix": "192.168.1.0/24",
"country_code": "GB",
"region_code": "GB-ENG",
"city": "London",
"postal_code": "EC1A 1BB",
"notes": "Main office",
"csrf_token": "..."
}
Update Entry
POST api.php?action=update
Content-Type: application/json
{
"id": 123,
"ip_prefix": "192.168.1.0/24",
"country_code": "GB",
"region_code": "GB-ENG",
"city": "Manchester",
"postal_code": "M1 1AA",
"csrf_token": "..."
}
Delete Entry
POST api.php?action=delete
Content-Type: application/json
{
"id": 123,
"csrf_token": "..."
}
Export CSV
GET api.php?action=export&format=download
Get Statistics
GET api.php?action=stats
Geofeed Format (RFC 8805)
Each line in the exported CSV follows this format:
ip_prefix,country_code,region_code,city,postal_code
Example:
# Geofeed - Generated by Geofeed Manager
# Format: ip_prefix,country_code,region_code,city,postal_code
192.168.1.0/24,GB,GB-ENG,London,EC1A 1BB
10.0.0.0/8,US,US-CA,San Francisco,94105
2001:db8::/32,DE,DE-BY,Munich,80331
BunnyCDN Setup
- Create a Storage Zone in BunnyCDN
- Get your Storage API key from the FTP & API Access section
- The workflow uploads to:
https://storage.bunnycdn.com/{zone}/geofeed.csv - Your public URL will be:
https://{zone}.b-cdn.net/geofeed.csv
Security Considerations
- Always use HTTPS in production
- Keep your database credentials secure
- Consider adding authentication to the web interface
- The CSRF token helps prevent cross-site attacks
- Input validation is performed on all fields
Troubleshooting
Import fails with "Invalid IP prefix"
Ensure your IP prefixes are in valid CIDR notation (e.g., 192.168.1.0/24)
n8n workflow fails
- Check that environment variables are set correctly
- Verify MySQL credentials are configured
- Check BunnyCDN API key permissions
Web interface shows database error
- Verify database credentials in config.php
- Ensure the database and tables exist
- Check MySQL/MariaDB is running
License
MIT License - Feel free to use and modify as needed.
Description
Languages
PHP
77.2%
JavaScript
18.3%
CSS
4.5%