Sign inSign up

amirtq/pyradius

By amirtq

•Updated 10 months ago

A lightweight Django-based RADIUS server, with auth, accounting, session limits, account expiration

Image
Networking
Security
0

867

amirtq/pyradius repository overview

⁠PyRadius

PyRadius is a modern, lightweight RADIUS server with a web-based administration interface. This Docker image (amirtq/pyradius:latest) bundles:

  • Django Backend: Handles the web dashboard, API, and core RADIUS logic.
  • Nginx: Serves the frontend React app and proxies backend requests.
  • RADIUS Server: Listens on UDP ports 1812 (Auth) and 1813 (Acct).

It includes a built-in SSL generator that automatically creates self-signed certificates on first run, customized via environment variables.


⁠Quick Start with Docker Compose

Create a docker-compose.yml file and a .env file in your directory.

⁠1. docker-compose.yml
services:
  pyradius:
    image: amirtq/pyradius:latest
    container_name: pyradius
    restart: always
    ports:
      # Web Interface
      - "80:80"
      - "443:443"
      # RADIUS Protocol
      - "1812:1812/udp"
      - "1813:1813/udp"
    volumes:
      # Persist the SQLite database
      # Change './pyradius_data' to your preferred host path or named volume
      - ./pyradius_data/db.sqlite3:/app/db.sqlite3
      - ./pyradius_data/ssl:/etc/nginx/ssl
    env_file:
      - .env
⁠2. .env Configuration

Create a .env file with these settings. Important: Change the SECRET_KEY for production environments.

# Security
SECRET_KEY=change-this-to-a-secure-random-string
DEBUG=False

# RADIUS Configuration
AUTH_PORT=1812
ACCT_PORT=1813
BIND_ADDRESS=0.0.0.0
LOG_LEVEL=INFO
ACCT_INTERIM_INTERVAL=180
RADIUS_INACTIVE_SESSION_DB_RETENTION_LIMIT=20
RADIUS_LOG_RETENTION=1000000
RADIUS_STALE_SESSION_MULTIPLIER=2

# SSL Certificate Generation (Used on first run)
SSL_DOMAIN=localhost
SSL_DAYS=3650
SSL_COUNTRY=US
SSL_STATE=State
SSL_CITY=City
SSL_ORGANIZATION=PyRadius

# Statistics (Intervals in seconds)
STATS_SERVER_SESSIONS_INTERVAL=300
STATS_SERVER_TRAFFIC_INTERVAL=300
STATS_USERS_SESSIONS_INTERVAL=300
STATS_USERS_TRAFFIC_INTERVAL=300

⁠Running the Container

  1. Create db file:

    touch db.sqlite3
    chmod 664 db.sqlite3
    
  2. Start the service:

    docker-compose up -d
    
  3. Create an Admin User: You need to access the container to create your initial superuser.

    docker exec -it pyradius python manage.py users add --admin-user admin password123
    
  4. Access the Dashboard: Open your browser and navigate to https://localhost (or your server's IP) with admin/password123 as username/password.

    Note: If using the generated self-signed certs (default), your browser will warn about the security certificate requiring manual acceptance. This is expected.

⁠Volumes

  • /app/db.sqlite3: Stores the SQLite database. Crucial: Mount this to a local file or volume to persist users, logs, and settings across restarts.
  • /etc/nginx/ssl: Stores the SSL certificates (server.crt and server.key).

⁠Ports

  • 80/tcp: HTTP (Redirects to HTTPS)
  • 443/tcp: HTTPS Web Dashboard
  • 1812/udp: RADIUS Authentication
  • 1813/udp: RADIUS Accounting

Tag summary

Content type

Image

Digest

sha256:bc3463c4f…

Size

177.6 MB

Last updated

10 months ago

docker pull amirtq/pyradius