Overview
OSINT Hub uses environment variables for configuration management via the.env file. This approach keeps sensitive credentials and environment-specific settings out of version control.
Configuration File
Create a.env file in the project root directory:
Core Variables
SECRET_KEY
Required: YesDefault: None
Description: Django’s secret key for cryptographic signing. Used for session management, CSRF protection, and password reset tokens. Example:
osint_hub/settings.py:10-12
DEBUG
Required: NoDefault:
TrueType: Boolean
Description: Enables Django debug mode. Shows detailed error pages with stack traces and SQL queries. Example:
True- Enable debug mode (development only)False- Disable debug mode (production)
osint_hub/settings.py:13
ALLOWED_HOSTS
Required: Yes (whenDEBUG=False)Default:
localhost,127.0.0.1Type: Comma-separated string
Description: List of domain names and IP addresses that can serve the application. Django will refuse requests with
Host headers not in this list.
Example:
- No spaces between hostnames
- Separate multiple hosts with commas
- Include both www and non-www versions if applicable
- Can include IP addresses
osint_hub/settings.py:16-20
CSRF_TRUSTED_ORIGINS
Required: Yes (whenDEBUG=False)Default: Empty
Type: Comma-separated string of URLs
Description: List of trusted origins for unsafe requests (POST, PUT, DELETE). Required for CSRF protection when your app is behind a proxy or uses HTTPS. Example:
- Must include the full URL scheme (
http://orhttps://) - No trailing slashes
- Separate multiple origins with commas
- Use HTTPS in production
osint_hub/settings.py:153-157
DATABASE_URL
Required: NoDefault:
sqlite:///db.sqlite3Type: Database URL string
Description: Database connection URL. Supports SQLite, PostgreSQL, MySQL, and other databases via the
dj-database-url library.
Examples:
scheme://username:password@host:port/database
Schemes:
sqlite- SQLite database (local file)postgresorpostgresql- PostgreSQLmysql- MySQL or MariaDB
DATABASE_URL is defined in .env.example, the current settings.py implementation uses a hardcoded SQLite configuration. To use DATABASE_URL, modify osint_hub/settings.py:75-80 to:
Optional Variables
SEARCH_RESULTS_DIR
Required: NoDefault:
~/.local/share/osint_hub/search_resultsType: Absolute file path
Description: Directory where username search results (Sherlock) are stored. Should be persistent across deployments. Example:
osint_hub/settings.py:135-138
CELERY_BROKER_URL
Required: Only if using CeleryDefault:
redis://localhost:6379/0Type: URL string
Description: Message broker URL for Celery task queue. Typically Redis or RabbitMQ. Example:
osint_hub/settings.py:172. To make it configurable, add:
CELERY_RESULT_BACKEND
Required: Only if using Celery with result storageDefault:
redis://localhost:6379/0Type: URL string
Description: Backend for storing Celery task results. Example:
osint_hub/settings.py:173.
EXIFTOOL_PATH
Required: Only if ExifTool is in a non-standard locationDefault:
/usr/bin/exiftool or /usr/local/bin/exiftoolType: Absolute file path
Description: Path to the ExifTool binary for metadata extraction. Example:
osint_hub/settings.py:164-168.
Environment-Specific Examples
Development (.env)
Production (.env)
PythonAnywhere (.env)
Docker (.env)
Security Best Practices
Use different keys per environment
Never reuse SECRET_KEY across development, staging, and production.
Troubleshooting
”SECRET_KEY” setting must not be empty
Cause:.env file missing or SECRET_KEY not set.
Solution:
DisallowedHost at /
Cause: Current hostname not inALLOWED_HOSTS.
Solution:
Add your hostname to ALLOWED_HOSTS in .env:
CSRF verification failed
Cause: Origin not inCSRF_TRUSTED_ORIGINS or wrong protocol.
Solution:
Ensure CSRF_TRUSTED_ORIGINS matches your full URL:
https:// protocol and no trailing slash.
Database connection errors
Cause: InvalidDATABASE_URL or database not running.
Solution:
-
Verify database is running:
-
Test connection manually:
-
Verify
DATABASE_URLformat:
Environment variables not loading
Cause:.env file in wrong location or permissions issue.
Solution:
- Ensure
.envis in project root (same directory asmanage.py) - Check file permissions:
- Verify
python-decoupleis installed:
Loading Variables in Different Contexts
Django Management Commands
Variables are automatically loaded viapython-decouple when running:
Gunicorn (Production)
UseEnvironmentFile in systemd service:
PythonAnywhere
Variables are loaded from.env via the configured WSGI file.
Docker
Pass viadocker-compose.yml:
docker run:
Shell Scripts
Source the file:Validation Checklist
Before deploying, verify:-
SECRET_KEYis set and unique -
DEBUG=Falsein production -
ALLOWED_HOSTSincludes your domain -
CSRF_TRUSTED_ORIGINSincludes your full HTTPS URL -
DATABASE_URLpoints to production database (if used) -
.envfile has restricted permissions (600) -
.envis in.gitignore - All required services (Redis, PostgreSQL) are running
- Run
python manage.py check --deployto catch issues
Next Steps
- Production Deployment Guide
- PythonAnywhere Deployment
- Review Django’s deployment checklist: https://docs.djangoproject.com/en/5.2/howto/deployment/checklist/
