Home
Softono

Axum Template

Open source Apache-2.0 Rust
17
Stars
0
Forks
1
Issues
1
Watchers
2 months
Last Commit

 About Axum Template

Axum template(with static templates) + SQLite + dockerization

Platforms

Web Self-hosted Docker

Languages

Rust

Links

Need Help Installing Axum Template?

We provide expert installation service for this software. Our team will install, configure, and secure Axum Template on your server. plans start at just $30.

Axum Template

View on GitHub

axum-template

!Image

Axum Template - Portfolio/blog website template

Overview

Portfolio/blog website template for a company that does software/games projects

This README was generated with cargo-readme from src/lib.rs.

This template provides:

  • Axum server with middleware
  • Askama templates
  • Containerization (with compose)
  • Portfolio projects management
  • Blog with markdown support
  • Admin panel with authentication
  • SQLite backend (default)
  • SurrealDB backend (optional, behind feature flag)
  • RBAC (User/Editor/Admin)
  • HttpOnly cookie support
  • Rate limiting on login
  • Enable HTTPS
  • Add login page template
  • Audit logging
  • Secure cookie flag
  • Password reset flow
  • Remember me checkbox with longer token TTL
  • Simple footer with socials

Quick start

Install cargo-generate and run:

cargo generate olekspickle/axum-template -n my-project

Running

# SQLite3 backend:
just run

# SurrealDB backend
just run-surreal

You can peek into justfile for build details

Configuration

Edit config.toml to configure:

  • Server host/port
  • Database path
  • Admin credentials (password is argon2 hashed)
  • Site name and tagline

Afterthoughts and issues

I found axum to be the most ergonomic web framework out there, and while there might be not enough examples at the moment, it is quite a breeze to use

  • static files was sure one noticeable pain in the rear to figure out
  • surrealdb sure adds complexity, I'm adding it under a feature because sqlite integration is so much less crates to compile(190+ vs 500+)

Deploy on Raspberry Pi via Cloudflare Tunnel (dockerless)

  1. Cross-compile for Pi (aarch64):

    Option A — native toolchain:

    rustup target add aarch64-unknown-linux-gnu
    sudo apt install gcc-aarch64-linux-gnu   # Debian/Ubuntu
    just build-pi
    

    Option B — Docker-based (no toolchain to install):

    cargo install cross
    just cross-build-pi
    
  2. Copy to Pi:

    rsync -avz target/aarch64-unknown-linux-gnu/release/axum-template \
               config.toml static/ templates/ systemd/ \
               pi@raspberrypi:~/deploy/
    
  3. Run automated setup on Pi:

    ssh pi@raspberrypi
    cd ~/deploy
    bash setup.sh
    

    The script downloads cloudflared to /opt/axum-template/cf/, creates symlinks at /usr/local/bin/cloudflared and /usr/local/bin/cf, sets up config directories, installs systemd services, and prompts for ADMIN_PASSWORD.

  4. Configure Cloudflare Tunnel (one-time):

    # Authenticate cloudflared as the dedicated user
    sudo -u cloudflared /opt/axum-template/cf/cloudflared tunnel login
    
    # Create tunnel and DNS route
    sudo -u cloudflared /opt/axum-template/cf/cloudflared tunnel create axum-template
    sudo -u cloudflared /opt/axum-template/cf/cloudflared tunnel route dns axum-template your-domain.com
    
    # Edit config with actual tunnel name and domain
    sudo $EDITOR /opt/axum-template/cf/config.yml
    
    # Start services
    sudo systemctl start axum-template.service
    sudo systemctl start cloudflared.service
    

Systemd service files are in systemd/

License: MIT OR Apache-2.0