Deploying IFM
Introduction
IFM (Improved File Manager) is a lightweight, web-based file manager that comes as a single PHP file solution. Using HTML5, CSS3, JavaScript, and PHP, IFM provides a clean, modern interface for managing files on your server without the complexity of traditional file management systems.
The beauty of IFM lies in its simplicity - a single PHP file that can be dropped into any directory to instantly provide file management capabilities. Despite its minimal footprint, IFM offers a comprehensive feature set including file upload, download, editing, and even a built-in code editor with syntax highlighting.
Key highlights of IFM:
- Single File Solution: The entire application is contained in one PHP file
- Modern Interface: Clean, responsive HTML5/CSS3 design
- File Operations: Upload, download, rename, move, copy, and delete files
- Directory Management: Create, rename, and navigate directories
- Built-in Editor: Edit text files with syntax highlighting support
- Archive Support: Create and extract ZIP archives
- Drag and Drop: Upload files by dragging them into the browser
- Multi-File Upload: Upload multiple files simultaneously
- Authentication: Optional password protection
- Configurable: Extensive configuration via environment variables
- No Database Required: Completely file-based operation
This guide walks through deploying IFM on Klutch.sh using Docker, providing you with a simple yet powerful web-based file manager.
Why Deploy IFM on Klutch.sh
Deploying IFM on Klutch.sh provides several advantages for web-based file management:
Simplified Deployment: Klutch.sh automatically detects your Dockerfile and builds IFM without manual server configuration. Push to GitHub and your file manager deploys automatically.
Persistent Storage: Attach persistent volumes for your file storage. Your files survive container restarts and redeployments.
HTTPS by Default: Klutch.sh provides automatic SSL certificates, ensuring secure file transfers without manual certificate management.
GitHub Integration: Connect your configuration repository directly from GitHub. Updates trigger automatic redeployments.
Lightweight Footprint: IFM’s minimal resource requirements mean cost-effective hosting on Klutch.sh.
Secure Access: Deploy behind Klutch.sh’s infrastructure with optional authentication for file access.
Prerequisites
Before deploying IFM on Klutch.sh, ensure you have:
- A Klutch.sh account
- A GitHub account with a repository for your IFM configuration
- Basic familiarity with Docker and containerization concepts
Understanding IFM Architecture
IFM is designed for maximum simplicity:
Single PHP File: The entire application is one PHP file that can be customized through environment variables.
Client-Side JavaScript: The interactive interface is powered by JavaScript running in the browser.
File-Based Storage: No database required - IFM operates directly on the filesystem.
Apache/Nginx Compatible: Runs on any PHP-enabled web server.
Preparing Your Repository
To deploy IFM on Klutch.sh, create a GitHub repository containing your Dockerfile.
Repository Structure
ifm-deploy/├── Dockerfile└── .dockerignoreCreating the Dockerfile
Create a Dockerfile in the root of your repository:
FROM misterunknown/ifm:latest
# Set environment variables for configurationENV IFM_AUTH=${IFM_AUTH:-0}ENV IFM_AUTH_SOURCE=${IFM_AUTH_SOURCE:-}ENV IFM_ROOT_DIR=${IFM_ROOT_DIR:-/var/www/html/data}
# File operation permissionsENV IFM_UPLOAD=${IFM_UPLOAD:-1}ENV IFM_DOWNLOAD=${IFM_DOWNLOAD:-1}ENV IFM_DELETE=${IFM_DELETE:-1}ENV IFM_RENAME=${IFM_RENAME:-1}ENV IFM_EDIT=${IFM_EDIT:-1}ENV IFM_CREATEDIR=${IFM_CREATEDIR:-1}ENV IFM_CREATEFILE=${IFM_CREATEFILE:-1}ENV IFM_ZIPDOWNLOAD=${IFM_ZIPDOWNLOAD:-1}ENV IFM_EXTRACT=${IFM_EXTRACT:-1}
# Create data directoryRUN mkdir -p /var/www/html/data
# Set permissions for www-dataRUN chown -R www-data:www-data /var/www/html
# Expose port 80EXPOSE 80
# Health checkHEALTHCHECK --interval=30s --timeout=10s --start-period=10s --retries=3 \ CMD wget --no-verbose --tries=1 --spider http://localhost:80/ || exit 1Dockerfile with Authentication
For a secured deployment with authentication:
FROM misterunknown/ifm:latest
# Enable authenticationENV IFM_AUTH=1ENV IFM_AUTH_SOURCE=.htusers.php
# Set the root directory for file managementENV IFM_ROOT_DIR=/var/www/html/data
# Enable all file operationsENV IFM_UPLOAD=1ENV IFM_DOWNLOAD=1ENV IFM_DELETE=1ENV IFM_RENAME=1ENV IFM_EDIT=1ENV IFM_CREATEDIR=1ENV IFM_CREATEFILE=1ENV IFM_ZIPDOWNLOAD=1ENV IFM_EXTRACT=1
# Set maximum upload sizeENV IFM_MAXUPLOADSIZE=1073741824
# Create directoriesRUN mkdir -p /var/www/html/data
# Create authentication file (username: admin, password: changeme)# Generate your own hash: php -r "echo password_hash('yourpassword', PASSWORD_DEFAULT);"RUN echo '<?php return array("admin" => "\$2y\$10\$somehashedpasswordhere");' > /var/www/html/.htusers.php
# Set permissionsRUN chown -R www-data:www-data /var/www/html
EXPOSE 80
HEALTHCHECK --interval=30s --timeout=10s --start-period=10s --retries=3 \ CMD wget --no-verbose --tries=1 --spider http://localhost:80/ || exit 1Environment Variables Reference
IFM is highly configurable through environment variables:
| Variable | Required | Default | Description |
|---|---|---|---|
IFM_AUTH | No | 0 | Enable authentication (0=disabled, 1=enabled) |
IFM_AUTH_SOURCE | No | - | Path to authentication file |
IFM_ROOT_DIR | No | /var/www/html | Root directory for file management |
IFM_UPLOAD | No | 1 | Enable file uploads |
IFM_DOWNLOAD | No | 1 | Enable file downloads |
IFM_DELETE | No | 1 | Enable file deletion |
IFM_RENAME | No | 1 | Enable renaming files |
IFM_EDIT | No | 1 | Enable file editing |
IFM_CREATEDIR | No | 1 | Enable directory creation |
IFM_CREATEFILE | No | 1 | Enable file creation |
IFM_ZIPDOWNLOAD | No | 1 | Enable ZIP downloads |
IFM_EXTRACT | No | 1 | Enable archive extraction |
IFM_MAXUPLOADSIZE | No | 2147483648 | Maximum upload size in bytes |
Deploying IFM on Klutch.sh
Once your repository is prepared, follow these steps to deploy IFM:
- Select HTTP as the traffic type
- Set the internal port to 80
- Detect your Dockerfile automatically
- Build the container image
- Attach the persistent volumes
- Start the IFM container
- Provision an HTTPS certificate
Push Your Repository to GitHub
Initialize your repository and push to GitHub:
git initgit add Dockerfile .dockerignoregit commit -m "Initial IFM deployment configuration"git remote add origin https://github.com/yourusername/ifm-deploy.gitgit push -u origin mainCreate a New Project on Klutch.sh
Navigate to the Klutch.sh dashboard and create a new project. Give it a descriptive name like “file-manager” or “ifm”.
Create a New App
Within your project, create a new app. Connect your GitHub account if you haven’t already, then select the repository containing your IFM Dockerfile.
Configure HTTP Traffic
IFM serves its web interface over HTTP. In the deployment settings:
Set Environment Variables
In the environment variables section, configure your instance:
| Variable | Value |
|---|---|
IFM_AUTH | 1 (recommended for security) |
IFM_ROOT_DIR | /var/www/html/data |
IFM_MAXUPLOADSIZE | 1073741824 (1 GB) |
Attach Persistent Volumes
Persistent storage is essential for your files. Add the following volume:
| Mount Path | Recommended Size | Purpose |
|---|---|---|
/var/www/html/data | 10+ GB | File storage |
Deploy Your Application
Click Deploy to start the build process. Klutch.sh will:
Access IFM
Once deployment completes, access your IFM instance at https://your-app-name.klutch.sh. If authentication is enabled, enter your credentials to access the file manager.
Using IFM
File Operations
IFM provides intuitive file management:
- Upload: Click the upload button or drag files into the browser
- Download: Click on a file to download, or select multiple for ZIP download
- Edit: Click the edit icon to modify text files in the built-in editor
- Delete: Select files and click delete
- Rename: Right-click or use the context menu to rename
Built-in Editor
IFM includes a code editor with syntax highlighting:
- Click the edit icon on any text file
- Make your changes in the editor
- Click save to persist changes
Supported file types include HTML, CSS, JavaScript, PHP, Python, and many more.
Archive Management
Create and extract archives:
- Create ZIP: Select files/folders and choose “Download as ZIP”
- Extract: Click on a ZIP file and choose “Extract here”
Directory Navigation
- Click folder names to navigate
- Use breadcrumbs at the top for quick navigation
- Create new folders with the “New Folder” button
Security Considerations
Authentication
For production use, always enable authentication:
- Set
IFM_AUTH=1 - Create a secure
.htusers.phpfile with hashed passwords - Use strong, unique passwords
Permission Control
Disable unnecessary features for added security:
# Restrict to read-only accessENV IFM_UPLOAD=0ENV IFM_DELETE=0ENV IFM_RENAME=0ENV IFM_EDIT=0ENV IFM_CREATEDIR=0ENV IFM_CREATEFILE=0File Access Restrictions
Limit the accessible directory:
# Restrict to specific subdirectoryENV IFM_ROOT_DIR=/var/www/html/data/publicTroubleshooting Common Issues
Cannot Upload Large Files
Symptoms: Upload fails for large files.
Solutions:
- Increase
IFM_MAXUPLOADSIZE - Check PHP settings in the container
- Verify volume has sufficient space
Permission Denied Errors
Symptoms: Cannot create or modify files.
Solutions:
- Ensure www-data owns the data directory
- Check file permissions (should be writable)
- Verify volume mount is correct
Authentication Not Working
Symptoms: Cannot log in despite correct credentials.
Solutions:
- Verify password hash is correctly formatted
- Check
.htusers.phpfile syntax - Ensure
IFM_AUTH_SOURCEpoints to correct file
Additional Resources
Conclusion
Deploying IFM on Klutch.sh gives you a lightweight, web-based file manager with automatic builds, persistent storage, and secure HTTPS access. The single-file architecture means minimal resource usage while still providing comprehensive file management capabilities.
Whether you need a simple way to manage files on a web server or want a backup method for accessing your data remotely, IFM on Klutch.sh provides an elegant, efficient solution.