A Pterodactyl Egg for running Rust web applications with Cloudflare Tunnel support, automatic updates, and log management.
- Features
- Docker Images
- Installation
- Environment Variables
- Auto-Update System
- Cloudflared Tunnel Tutorial
- Log Cleaner Module
- Project Structure
- Notes
- License
- π¦ Rust Toolchain: Pre-installed Rust with cargo, clippy, and rustfmt
- π Auto-Update: Automatically checks for and applies updates via Tavuru API
- π§Ή LogCleaner: Cleans
/tmpand old logs on startup - π Cloudflare Tunnel: Secure tunnel with token validation
| Image | Description |
|---|---|
ghcr.io/ym0t/pterodactyl-rust-web-egg:stable |
Recommended - Stable Rust toolchain. Well-tested, reliable, 6-week release cycle. Best for production. |
ghcr.io/ym0t/pterodactyl-rust-web-egg:nightly |
Bleeding-edge Rust with latest features. Updated daily. Use for experimental features like unstable APIs. |
- You need features behind
#![feature(...)]flags - You want the latest performance improvements
- You're developing libraries that need to test against nightly
- You're experimenting with upcoming Rust features
For most production use cases, stable is recommended.
- Download the egg file (
pterodactyl-egg-rust-web.json) - In your Pterodactyl panel, navigate to Nests in the sidebar
- Import the egg under Import Egg
- Create a new server and select the Rust Web Application egg
- Choose the Docker image matching your desired Rust version (stable/nightly)
- Fill in all required variables, including your startup command
| Variable | Default | Description |
|---|---|---|
STARTUP_CMD |
cargo run --release |
Command to start your Rust application |
GIT_REPO |
`` | Git repository URL to clone (optional) |
| Variable | Default | Description |
|---|---|---|
AUTOUPDATE_STATUS |
1 |
Enable auto-update checking |
AUTOUPDATE_FORCE |
1 |
Apply updates automatically (enabled by default) |
CLOUDFLARED_STATUS |
0 |
Enable Cloudflare Tunnel |
CLOUDFLARED_TOKEN |
`` | Cloudflare Tunnel token |
LOGCLEANER_STATUS |
1 |
Enable log cleanup |
RUST_LOG |
info |
Rust logging level (error, warn, info, debug, trace) |
Pterodactyl provides the allocated port via the SERVER_PORT environment variable. Your Rust application must read this variable to use the correct port.
Example Implementation:
let port = std::env::var("SERVER_PORT")
.unwrap_or_else(|_| "3000".to_string())
.parse::<u16>()
.expect("SERVER_PORT must be a valid port number");
let addr = format!("0.0.0.0:{}", port);With Axum:
use axum::Router;
use tokio::net::TcpListener;
#[tokio::main]
async fn main() {
let port = std::env::var("SERVER_PORT").unwrap_or_else(|_| "3000".into());
let addr = format!("0.0.0.0:{}", port);
let app = Router::new();
let listener = TcpListener::bind(&addr).await.unwrap();
axum::serve(listener, app).await.unwrap();
}With Actix-web:
use actix_web::{App, HttpServer};
#[actix_web::main]
async fn main() -> std::io::Result<()> {
let port: u16 = std::env::var("SERVER_PORT")
.unwrap_or_else(|_| "3000".into())
.parse()
.expect("Invalid port");
HttpServer::new(|| App::new())
.bind(("0.0.0.0", port))?
.run()
.await
}The egg includes an intelligent auto-update system that keeps your installation current with the latest features and security updates.
- Automatic Version Checking: Uses the Tavuru API to check for new releases
- Smart Differential Updates: Downloads only changed files, not the entire codebase
- Selective Updates: Only updates core system files (modules, scripts)
- User Data Protection: Never touches your application code or user data
- Self-Update Capability: Can safely update its own update mechanism
AUTOUPDATE_STATUS=1,AUTOUPDATE_FORCE=1- Automatically downloads and applies updates on startup
- Shows detailed progress during updates
- Creates backups before applying changes
AUTOUPDATE_STATUS=1,AUTOUPDATE_FORCE=0- Checks for updates and shows availability
- Shows version information and changelog
- Updates must be manually approved
AUTOUPDATE_STATUS=0- Skips all update operations
- Useful for production environments requiring manual updates
[AutoUpdate] Current version: v1.0.0
[AutoUpdate] Latest version: v1.1.0
[AutoUpdate] Update available: v1.0.0 -> v1.1.0
[AutoUpdate] Update summary:
Total changes: 8
Files added: 2
Files modified: 5
Files removed: 1
[AutoUpdate] Update completed successfully- β Module scripts (modules/)
- β Core scripts (start-modules.sh)
- β Documentation (README.md, LICENSE)
- β Your Rust application (app/, src/, Cargo.toml)
- β User data (logs, data, databases)
With Cloudflared, you can create a secure tunnel to your server, making it accessible over the internet without complicated port forwarding! Cloudflared | Create a remotely-managed tunnel
- A Cloudflare account
- πΉ Step 1: Log in to Zero Trust and go to Networks > Tunnel
- πΉ Step 2: Select Create a tunnel.
- πΉ Step 3: Choose Cloudflared for the connector type and select Next.
- πΉ Step 4: Enter a name for your tunnel.
- πΉ Step 5: Select Save tunnel.
- πΉ Step 6: Save the token. (The token is very long)
- πΉ Step 7: In Pterodactyl, set
CLOUDFLARED_STATUSto1 - πΉ Step 8: Add your token to
CLOUDFLARED_TOKEN - πΉ Step 9: In Cloudflare, add public hostname
- πΉ Step 10: Select http and URL "localhost" + your application port (e.g.,
localhost:8080) - πΉ Step 11: Restart your server
Your Rust application is now accessible via your Cloudflare domain!
The LogCleaner module automatically cleans up temporary files and old logs on container startup.
| Variable | Default | Description |
|---|---|---|
LOGCLEANER_STATUS |
1 |
Enable (1) or disable (0) log cleanup |
MAX_SIZE_MB |
10 |
Delete logs larger than this size (MB) |
MAX_AGE_DAYS |
30 |
Delete logs older than this many days |
/home/container/tmp/*- All temporary files/home/container/logs/*.log- Logs exceeding size limit/home/container/logs/*.log- Logs older than age limit
/home/container/
βββ modules/
β βββ autoupdate/ # Auto-update module
β βββ cloudflared/ # Cloudflare Tunnel module
β βββ logcleaner/ # Log cleanup module
βββ scripts/ # Custom scripts
βββ logs/ # Application logs
βββ tmp/ # Temporary files
βββ data/ # Persistent data
βββ bin/ # Custom binaries
βββ app/ # Your Rust application (if cloned via GIT_REPO)
βββ .cargo/ # Cargo registry and cache
βββ start-modules.sh # Module orchestrator
βββ VERSION # Current version file
Note: Rust toolchain binaries (cargo, rustc, rustup) are installed in /opt/rust/ and available system-wide.
- Rust toolchain is pre-installed in the container at
/opt/rust/ - Cargo cache and registry are stored in
/home/container/.cargo/ - First build may take longer as dependencies are compiled
- Use
RUST_LOGenvironment variable to control logging verbosity - Auto-updates are powered by the Tavuru API for reliable version management
- For production, consider using pre-compiled binaries instead of
cargo run