Documentação ComusThumbz
Login de Admin

Storage Servers

Overview

The Storage Servers page allows administrators to configure and manage individual storage servers within a storage group. This includes CDN providers (Bunny.net, Vultr, DigitalOcean, Cloudflare R2, KeyCDN, CDN77), FTP servers, and local storage. The page also features integrated CDN provider information cards with setup guides and a heartbeat monitoring system for server health checks.

Key capabilities include:

  • Add and configure storage servers (6 CDN providers + FTP + Local)
  • View server health status and storage usage
  • Configure heartbeat monitoring for FTP/local servers
  • Test server connectivity
  • Access CDN provider information and signup links
  • Quick access to CDN Cost Calculator

 

System Requirements

PHP Requirements

Requirement Minimum Recommended
PHP Version 7.4+ 8.0+
Memory Limit 64M 128M

PHP Extensions Required

  • mysqli - Database connectivity
  • json - JSON encoding/decoding for server configs
  • curl - Heartbeat testing (AJAX handler)
  • ftp - FTP server deployment
  • session - Session management

PHP Settings

session.autostart = Off
date.timezone = Your/Timezone
allowurlfopen = On

Server Type Reference

Type Description Credentials Required
local Local filesystem Path only
ftp FTP server Host, port, username, password, path
sftp SFTP server Host, port, username, password, path
bunnycdn Bunny.net Storage Zone name, API key, region
vultr Vultr Object Storage Access key, secret key, bucket, endpoint
digitaloceanspaces DigitalOcean Spaces Access key, secret key, space name, region
cloudflarer2 Cloudflare R2 Account ID, access key, secret key, bucket
keycdn KeyCDN Zone ID, zone URL, API key, origin URL
cdn77 CDN77 Resource ID, CDN URL, API key, origin URL

Health Status Reference

Status Color Description
healthy Green Server responding normally
warning Yellow Degraded performance or high usage
critical Red Server unresponsive or error
unknown Gray Not monitored or never checked

File Dependencies

  • ct/admin/adminauth.php - Admin authentication
  • ct/dat/config.inc.php - Configuration
  • ct/includes/header.php - Admin header
  • ct/includes/annotateftr.php - Admin footer
  • ct/admin/heartbeat.php - Heartbeat script template
  • Font Awesome 6+ - Icon library

Features & UI Elements

Page Header

[Screenshot: storage-servers-header]

The page header displays:

  • Title: "Storage Servers"
  • Icon: fa-server
  • Breadcrumb: Dashboard / Storage Groups / [Group Name]
  • Subtitle: "Choose from our recommended CDN providers for fast, reliable content delivery OR add your own server!"

Alert Messages

[Screenshot: storage-servers-alerts]

Success and error alerts for:

  • Server added successfully
  • Server updated successfully
  • Server deleted successfully
  • Heartbeat deployment status
  • Connection test results

Action Card

[Screenshot: storage-servers-actions]

Primary action buttons:

Add New Server (green) - Opens configuration modal

  • Back to Groups (gray) - Returns to storagegroups.php

CDN Provider Cards

[Screenshot: storage-servers-cdn-cards]

Six compact provider cards with quick info:

Provider Color Icon Key Feature
Bunny.net Orange Carrot Best value, 114 PoPs
Vultr Blue Bolt Global infrastructure
DigitalOcean Blue DO logo Built-in CDN
Cloudflare R2 Orange Cloudflare Zero egress
KeyCDN Teal Key Simple pull CDN
CDN77 Purple Rocket Adult-friendly

Card Elements:

  • Provider icon
  • Provider name
  • Price per GB
  • Quick info line
  • Tag badges (POPULAR, NEW, ADULT OK, ZERO EGRESS)

Clicking a card opens the provider details modal.

Cost Calculator Button

[Screenshot: storage-servers-calculator-btn]

A prominent button linking to the CDN Cost Calculator:

  • Label: "Compare CDN Costs - Interactive Calculator"
  • Icon: fa-calculator
  • Opens cdncostcalculator.php in new tab

Servers Table

[Screenshot: storage-servers-table]

The main data table showing configured servers:

Column Description
Server Name Name of the storage server
Type Server type (BUNNYCDN, FTP, LOCAL, etc.)
Storage Usage Current/Max GB with capacity type
Files Number of file location records
Health Health status badge (if monitored)
Status Enabled/Disabled badge
Actions Edit, Test, Delete buttons

Storage Display Variations:

Server Type Display Format
CDN providers "X / Y GB of Unlimited"
Local "X / Y GB of ZTB" (actual disk space)
FTP "X / Y GB allocated"

Action Buttons:

Button Color Action
Edit Yellow Open edit modal with config
Test Green Test heartbeat (if enabled)
Test Gray Test connection (if no heartbeat)
Delete Red Delete server and file records

Provider Details Modal

[Screenshot: storage-servers-provider-modal]

Detailed information modal for each CDN provider:

Sections:

  • Overview (pricing, best use cases)
  • Key Features (bullet list)
  • Quick Setup (numbered steps)
  • Pro Tips (info boxes)
  • Action Buttons:
  • "Sign Up Now" (external link with referral)
  • "Configure Server" (opens add modal)

Server Configuration Modal

[Screenshot: storage-servers-config-modal]

The main configuration form with dynamic fields:

Common Fields:

Field Type Required Description
Server Name Text Yes Display name for the server
Server Type Select Yes Provider or storage type
Base URL Text Yes Public access URL
Max Storage Number Yes Maximum storage in GB
Status Select No Enabled/Disabled


Dynamic Fields by Server Type:

Bunny.net:

  • Storage Zone Name
  • Storage API Key
  • Region (de, ny, la, sg, syd, uk)

Vultr:

  • Access Key
  • Secret Key
  • Bucket Name
  • Endpoint/Region

DigitalOcean Spaces:

  • Access Key
  • Secret Key
  • Space Name
  • Region (nyc3, ams3, sgp1, sfo3)

Cloudflare R2:

  • Account ID
  • Access Key ID
  • Secret Access Key
  • Bucket Name
  • Custom Domain (optional)

KeyCDN:

  • Zone ID
  • Zone URL
  • API Key
  • Origin URL

CDN77:

  • CDN Resource ID
  • CDN URL
  • API Key
  • Origin URL

FTP/SFTP:

  • FTP Host
  • Port (21 for FTP, 22 for SFTP)
  • Username
  • Password
  • Upload Path

Local:

  • Storage Path

Heartbeat Monitoring Section

[Screenshot: storage-servers-heartbeat]

For FTP/Local servers, a heartbeat monitoring configuration:

Fields:

Field Type Description
Enable Heartbeat Checkbox Toggle monitoring on/off
Heartbeat Secret Key Text + Generate 32-character security key
Path to Monitor Text Filesystem path to check


Deployment Info:

  • FTP/Local: Auto-deploy available
  • CDN providers: Heartbeat not supported

Manual Download:

  • "Download heartbeat.php" button
  • Pre-configured with secret key

Step-by-Step Usage

Adding a CDN Server (Bunny.net Example)

  1. Navigate to Admin Panel → Storage → Groups
  2. Click Servers on your target group
  3. Click Add New Server button
  4. Select Server Type: Bunny.net CDN
  5. Fill in the configuration:
  • Server Name: "Bunny CDN - Main"
  • Storage Zone Name: Your Bunny zone name
  • Storage API Key: From Bunny dashboard
  • Region: Select closest region
  • Base URL: https://yourzone.b-cdn.net/
  • Max Storage: 1000 (GB)
  1. Click Save Server
Tip: Get your Bunny.net Storage API Key from: Dashboard → Storage Zone → FTP & API Access

Adding an FTP Server with Heartbeat

  1. Navigate to Admin Panel → Storage → Groups → [Group] → Servers
  2. Click Add New Server
  3. Select Server Type: FTP Server
  4. Fill in FTP configuration:
  • Server Name: "CDN Server 1"
  • FTP Host: cdn.example.com
  • Port: 21
  • Username: yourftpuser
  • Password: yourftppassword
  • Upload Path: /publichtml/videos/
  1. Configure Base URL:
  • Base URL: https://cdn.example.com/videos/
  1. Configure Heartbeat:
  • Check Enable Heartbeat Monitoring
  • Secret Key: Auto-generated (keep it)
  • Path to Monitor: /publichtml/videos/
  1. Click Save Server
Note: The heartbeat script will be automatically deployed to your FTP server. If deployment fails, use the "Download heartbeat.php" button and upload manually.

Testing Server Heartbeat

  1. Find the server in the table
  2. Click the Test button (green with heartbeat icon)
  3. Wait for the test to complete
  4. Review the results:
  • Server status
  • Health status
  • Disk space (total, used, free, percentage)
  • Server info (hostname, PHP version, OS)
  • Load average (if Linux)
  • Warnings (if any)

Editing Server Configuration

  1. Find the server in the table
  2. Click Edit button (yellow with pencil icon)
  3. Modify the desired fields
  4. Click Save Server
Warning: Changing server credentials while files exist may cause access issues. Ensure new credentials have access to existing files.

Deleting a Server

  1. Find the server in the table
  2. Click Delete button (red with trash icon)
  3. If server has files:
  • A warning shows file count
  • Confirm deletion (files remain on storage, only records deleted)
  1. If no files:
  • Confirm deletion
Error: Deleting a server removes all file location records but NOT the actual files on the storage server. Clean up manually if needed.

Using CDN Provider Information

  1. Click on any CDN provider card
  2. Review the provider details:
  • Pricing information
  • Key features
  • Setup instructions
  1. Click Sign Up Now to create an account
  2. Click Configure Server to add to your platform

CDN Provider Setup Guides

Bunny.net Setup

  1. Create account at bunny.net
  2. Go to StorageAdd Storage Zone
  3. Enter zone name (e.g., "my-videos")
  4. Select region closest to your users
  5. Click Add Storage Zone
  6. Go to zone settings → FTP & API Access
  7. Copy the Storage API Key
  8. Note your Zone Name and Region

Configuration Values:

Field Value
Zone Name Your zone name
API Key Storage API Key from settings
Region de, ny, la, sg, syd, or uk
Base URL https://[zone].b-cdn.net/

Vultr Setup

  1. Create account at vultr.com
  2. Go to ProductsObject Storage
  3. Click Add Object Storage
  4. Select location and label
  5. After creation, click on the storage
  6. Create a Bucket
  7. Go to S3 Credentials tab
  8. Copy Access Key and Secret Key

Configuration Values:

Field Value
Access Key S3 Access Key
Secret Key S3 Secret Key
Bucket Your bucket name
Endpoint e.g., ewr1.vultrobjects.com
Base URL https://[bucket].[region].vultrobjects.com/

Cloudflare R2 Setup

  1. Login to Cloudflare Dashboard
  2. Go to R2Create Bucket
  3. Enter bucket name
  4. Go to R2Manage R2 API Tokens
  5. Create token with Admin Read & Write
  6. Copy Access Key ID and Secret Access Key
  7. Note your Account ID from dashboard URL

Configuration Values:

Field Value
Account ID From dashboard URL
Access Key R2 token Access Key
Secret Key R2 token Secret Key
Bucket Your bucket name
Custom Domain cdn.yourdomain.com (configure in Cloudflare)
Note: Cloudflare R2 requires a custom domain for public access. Set this up in your Cloudflare dashboard under the bucket settings.

Heartbeat Monitoring System

How It Works

  1. Heartbeat Script: A PHP file deployed to FTP/Local servers
  2. Secret Key: Authentication to prevent unauthorized access
  3. Health Check: AJAX call from admin panel to heartbeat URL
  4. Response: JSON with disk space, load, status

Heartbeat Response Format

{
    "status": "ok",
    "health": "healthy",
    "datetime": "2025-01-02 12:00:00",
    "disk": {
        "totalgb": 500,
        "totaltb": 0.49,
        "usedgb": 250,
        "usedpercent": 50,
        "freegb": 250
    },
    "server": {
        "hostname": "cdn1.example.com",
        "phpversion": "8.2.10",
        "os": "Linux"
    },
    "load": {
        "1min": 0.5,
        "5min": 0.8,
        "15min": 0.6
    },
    "warnings": []
}

Manual Heartbeat Deployment

If auto-deploy fails:

Click Download heartbeat.php buttonUpload file to your server's web-accessible directoryEnsure file is accessible at: https://yourdomain.com/path/heartbeat.php

  1. Verify with: https://yourdomain.com/path/heartbeat.php?key=YOURSECRETKEY

Heartbeat Troubleshooting

Issue Solution
Test times out Check server is accessible, firewall allows HTTP
Invalid JSON Check PHP errors on remote server
Unauthorized Verify secret key matches
File not found Re-upload heartbeat.php, check path

Best Practices

Server Naming Conventions

Pattern Example Use Case
Provider - Region "Bunny CDN - NYC" Regional distribution
Provider - Tier "Vultr - Premium" Performance tiers
Type - Number "FTP Server 1" Multiple same-type servers
Content Type "Video CDN" Content-specific servers

Storage Allocation

Configuration Required: Set maxstoragegb appropriately:
Server Type Recommendation
CDN (unlimited) Set to expected usage + 50% buffer
FTP Match actual disk quota
Local Match partition size

Health Monitoring Schedule

Tip: Set up cron jobs to regularly check server health:
# Check all server heartbeats every 5 minutes
/5     php /path/to/ct/admin/cron/checkstoragehealth.php

Security Best Practices

  1. Use unique secret keys for each server
  2. Store keys securely in database (encrypted recommended)
  3. Rotate keys periodically (update both sides)
  4. Use HTTPS for all heartbeat URLs
  5. Restrict heartbeat access to admin IPs if possible

Troubleshooting

Common Issues

Server Connection Failed

Cause: Incorrect credentials or network issue

Solutions:

  1. Verify credentials are correct
  2. Test connection manually (FTP client, S3 browser)
  3. Check firewall allows outbound connections
  4. Verify endpoint URL is correct

Heartbeat Returns HTML

Cause: PHP not processing on remote server

Solutions:

  1. Ensure PHP is installed on remote server
  2. Check file has .php extension
  3. Verify web server is configured for PHP
  4. Check for .htaccess blocking

Files Not Syncing

Cause: Storage server manager not finding server

Solutions:

Verify server status is "enabled"

  1. Check group has autosyncnewcontent enabled
  2. Verify baseurl is accessible
  3. Check storage server logs

Cannot Delete Server with Files

Note: This is expected behavior

Process:

  1. Warning shows file count
  2. Confirm deletion to proceed
  3. File location records deleted
  4. Physical files remain on storage
  5. Clean up files manually if needed

Debug Queries

-- Check server configuration
SELECT serverid, servername, servertype, connectionconfig
FROM tblStorageServers
WHERE groupid = {groupid};

-- Check file counts per server

SELECT s.serverid, s.servername, COUNT(f.locationid) as filecount
FROM tblStorageServers s
LEFT JOIN tblStorageFileLocations f ON s.serverid = f.serverid
WHERE s.groupid = {groupid}
GROUP BY s.serverid;

-- Check failed syncs

SELECT FROM tblStorageFileLocations
WHERE syncstatus = 'error'
ORDER BY updatedat DESC
LIMIT 20;

Security Considerations

Credential Storage

Warning: Server credentials are stored in the database. Ensure proper database security:
  • Use encrypted connection (SSL/TLS)
  • Limit database user permissions
  • Regular backup with encryption
  • Consider credential vault for production

API Key Protection

  • Never expose API keys in frontend code
  • Use environment variables when possible
  • Rotate keys if compromised
  • Monitor API usage for anomalies

Heartbeat Security

  • Secret keys prevent unauthorized health checks
  • Use HTTPS to prevent key interception
  • Consider IP whitelisting on remote server
  • Regular key rotation recommended

Translatable Strings

{
    "storageserverstitle": "Storage Servers",
    "storageserversbreadcrumb": "Dashboard / Storage Groups / {groupname}",
    "storageserverssubtitle": "Choose from our recommended CDN providers for fast, reliable content delivery OR add your own server!",
    "storageserversaddbtn": "Add New Server",
    "storageserversbackbtn": "Back to Groups",
    "storageserverscdntitle": "Available CDN Providers",
    "storageserverscdnsubtitle": "Click any provider to see detailed information and setup instructions",
    "storageserverscalculatorbtn": "Compare CDN Costs - Interactive Calculator",
    "storageserverstabletitle": "Your Configured Servers",
    "storageserverstablename": "Server Name",
    "storageserverstabletype": "Type",
    "storageserverstablestorage": "Storage Usage",
    "storageserverstablefiles": "Files",
    "storageserverstablehealth": "Health",
    "storageserverstablestatus": "Status",
    "storageserverstableactions": "Actions",
    "storageserversmodaladdtitle": "Configure Storage Server",
    "storageserversmodaledittitle": "Edit Storage Server",
    "storageserversformname": "Server Name",
    "storageserversformtype": "Server Type",
    "storageserversformbaseurl": "Base URL (Public Access URL)",
    "storageserversformmaxstorage": "Max Storage (GB)",
    "storageserversformstatus": "Status",
    "storageserversheartbeattitle": "Heartbeat Monitoring",
    "storageserversheartbeatenable": "Enable Heartbeat Monitoring",
    "storageserversheartbeatkey": "Heartbeat Secret Key",
    "storageserversheartbeatpath": "Path to Monitor",
    "storageserversheartbeatregenerate": "Regenerate",
    "storageserversheartbeatdownload": "Download heartbeat.php",
    "storageserversheartbeatdeployftp": "Auto-Deploy Available",
    "storageserversheartbeatdeploycdn": "Heartbeat not available for CDN providers",
    "storageserversbtnsave": "Save Server",
    "storageserversbtncancel": "Cancel",
    "storageserversbtnedit": "Edit",
    "storageserversbtntest": "Test",
    "storageserversbtndelete": "Delete",
    "storageserversstatusenabled": "Enabled",
    "storageserversstatusdisabled": "Disabled",
    "storageservershealthhealthy": "Healthy",
    "storageservershealthwarning": "Warning",
    "storageservershealthcritical": "Critical",
    "storageservershealthunknown": "Unknown",
    "storageservershealthnotmonitored": "Not Monitored",
    "storageserverssuccessadded": "Server added successfully!",
    "storageserverssuccessupdated": "Server updated successfully!",
    "storageserverssuccessdeleted": "Server deleted successfully!",
    "storageserverssuccessheartbeat": "Heartbeat deployed successfully!",
    "storageserverserrorheartbeat": "Heartbeat deployment failed",
    "storageserversconfirmdelete": "Are you sure you want to delete this server?",
    "storageserversconfirmdeletefiles": "This server has {count} files. Deleting will remove file records but physical files remain. Continue?",
    "storageserversprovideroverview": "Overview",
    "storageserversproviderfeatures": "Key Features",
    "storageserversprovidersetup": "Quick Setup",
    "storageserversprovidersignup": "Sign Up Now",
    "storageserversproviderconfigure": "Configure Server"
}


Version History

Version Date Changes
1.0.0 2025-10-20 Initial storage servers management
1.1.0 2025-11-01 Added CDN provider cards
1.2.0 2025-11-15 Added heartbeat monitoring
1.3.0 2025-12-01 Added provider detail modals
1.4.0 2025-12-15 Modern UI with green theme
1.5.0 2025-12-20 Added auto-deploy for heartbeat
1.6.0 2025-01-02 Added manual heartbeat download