Configuration
Configure PasarGuard Panel with environment variables and settings
Configuration Overview
PasarGuard Panel is configured through environment variables stored in the .env
file located at /opt/pasarguard/.env
.
Environment Variables
Admin Configuration
Variable | Type | Default | Description |
---|---|---|---|
SUDO_USERNAME | string | - | Superuser's username for initial admin account |
SUDO_PASSWORD | string | - | Superuser's password for initial admin account |
SUDO_USERNAME
and SUDO_PASSWORD
only work when DEBUG
mode is enabled. For production, create admin users using the TUI: pasarguard tui
Database Configuration
Variable | Type | Default | Description |
---|---|---|---|
SQLALCHEMY_DATABASE_URL | string | - | Database connection string (SQLite, MySQL, MariaDB, PostgreSQL, TimescaleDB) |
Database URL Examples:
# TimescaleDB/PostgreSQL (default)
SQLALCHEMY_DATABASE_URL = "postgresql+asyncpg://user:password@localhost/pasarguard"
# MySQL/MariaDB
SQLALCHEMY_DATABASE_URL = "mysql+asyncmy://user:password@localhost/pasarguard"
# SQLite
SQLALCHEMY_DATABASE_URL = "sqlite+aiosqlite:////var/lib/pasarguard/db.sqlite3"
UVICORN Web Server
Variable | Type | Default | Description |
---|---|---|---|
UVICORN_HOST | string | 0.0.0.0 | Host address to bind the web server |
UVICORN_PORT | int | 8000 | Port number for the web server |
UVICORN_SSL_CERTFILE | string | - | Path to SSL certificate file |
UVICORN_SSL_KEYFILE | string | - | Path to SSL private key file |
Example:
UVICORN_HOST = "0.0.0.0"
UVICORN_PORT = 8000
UVICORN_SSL_CERTFILE = "/var/lib/pasarguard/cert.pem"
UVICORN_SSL_KEYFILE = "/var/lib/pasarguard/key.pem"
Authentication & Security
Variable | Type | Default | Description |
---|---|---|---|
JWT_ACCESS_TOKEN_EXPIRE_MINUTES | int | 1440 | JWT token expiration time in minutes (default: 24 hours) |
Example:
# Token expires after 24 hours
JWT_ACCESS_TOKEN_EXPIRE_MINUTES = 1440
# Token expires after 7 days
JWT_ACCESS_TOKEN_EXPIRE_MINUTES = 10080
Panel Settings
Variable | Type | Default | Description |
---|---|---|---|
DOCS | bool | false | Enable/disable API documentation endpoint |
DEBUG | bool | false | Enable debug mode for verbose logging |
Example:
DOCS = true
DEBUG = false
Complete Configuration Example
Production Setup
# Admin Configuration
SUDO_USERNAME = "admin"
SUDO_PASSWORD = "your-secure-password"
# Database (TimescaleDB recommended)
SQLALCHEMY_DATABASE_URL = "postgresql+asyncpg://pasarguard:password@localhost/pasarguard"
# Web Server
UVICORN_HOST = "0.0.0.0"
UVICORN_PORT = 8000
UVICORN_SSL_CERTFILE = "/var/lib/pasarguard/cert.pem"
UVICORN_SSL_KEYFILE = "/var/lib/pasarguard/key.pem"
# Security
JWT_ACCESS_TOKEN_EXPIRE_MINUTES = 1440
# Panel Settings
DOCS = false
DEBUG = false
Development/Testing Setup
# Admin Configuration
SUDO_USERNAME = "admin"
SUDO_PASSWORD = "admin123"
# Database (SQLite for testing)
SQLALCHEMY_DATABASE_URL = "sqlite+aiosqlite:////var/lib/pasarguard/db.sqlite3"
# Web Server
UVICORN_HOST = "127.0.0.1"
UVICORN_PORT = 8000
# Security
JWT_ACCESS_TOKEN_EXPIRE_MINUTES = 1440
# Panel Settings
DOCS = true
DEBUG = true
Configuration Management
View Current Configuration
cat /opt/pasarguard/.env
Edit Configuration
sudo nano /opt/pasarguard/.env
Apply Changes
After modifying configuration, restart the panel:
pasarguard restart
Verify Configuration
Check if the service is running correctly:
pasarguard status
View logs to troubleshoot issues:
pasarguard logs
Multi-Node Setup
To configure multiple nodes:
-
Install and configure PasarGuard Node on each server (see Node Installation)
-
Configure node API credentials on each node server
-
Add nodes in the panel interface:
- Navigate to the Nodes section in the dashboard
- Click "Add Node"
- Enter node connection details (address, port, API key, etc.)
- Check the connection
Security Best Practices
Secure Database Credentials
Use strong passwords for database connections:
# Generate secure password
openssl rand -base64 32
Use SSL Certificates
Always use valid SSL certificates in production:
# Using Let's Encrypt
sudo certbot certonly --standalone -d your-domain.com
# Update .env
UVICORN_SSL_CERTFILE = "/etc/letsencrypt/live/your-domain.com/fullchain.pem"
UVICORN_SSL_KEYFILE = "/etc/letsencrypt/live/your-domain.com/privkey.pem"
Disable Debug Mode in Production
DEBUG = false
DOCS = false