Skip to content

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:

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
└── .dockerignore

Creating the Dockerfile

Create a Dockerfile in the root of your repository:

FROM misterunknown/ifm:latest
# Set environment variables for configuration
ENV 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 permissions
ENV 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 directory
RUN mkdir -p /var/www/html/data
# Set permissions for www-data
RUN chown -R www-data:www-data /var/www/html
# Expose port 80
EXPOSE 80
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=10s --retries=3 \
CMD wget --no-verbose --tries=1 --spider http://localhost:80/ || exit 1

Dockerfile with Authentication

For a secured deployment with authentication:

FROM misterunknown/ifm:latest
# Enable authentication
ENV IFM_AUTH=1
ENV IFM_AUTH_SOURCE=.htusers.php
# Set the root directory for file management
ENV IFM_ROOT_DIR=/var/www/html/data
# Enable all file operations
ENV IFM_UPLOAD=1
ENV IFM_DOWNLOAD=1
ENV IFM_DELETE=1
ENV IFM_RENAME=1
ENV IFM_EDIT=1
ENV IFM_CREATEDIR=1
ENV IFM_CREATEFILE=1
ENV IFM_ZIPDOWNLOAD=1
ENV IFM_EXTRACT=1
# Set maximum upload size
ENV IFM_MAXUPLOADSIZE=1073741824
# Create directories
RUN 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 permissions
RUN 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 1

Environment Variables Reference

IFM is highly configurable through environment variables:

VariableRequiredDefaultDescription
IFM_AUTHNo0Enable authentication (0=disabled, 1=enabled)
IFM_AUTH_SOURCENo-Path to authentication file
IFM_ROOT_DIRNo/var/www/htmlRoot directory for file management
IFM_UPLOADNo1Enable file uploads
IFM_DOWNLOADNo1Enable file downloads
IFM_DELETENo1Enable file deletion
IFM_RENAMENo1Enable renaming files
IFM_EDITNo1Enable file editing
IFM_CREATEDIRNo1Enable directory creation
IFM_CREATEFILENo1Enable file creation
IFM_ZIPDOWNLOADNo1Enable ZIP downloads
IFM_EXTRACTNo1Enable archive extraction
IFM_MAXUPLOADSIZENo2147483648Maximum upload size in bytes

Deploying IFM on Klutch.sh

Once your repository is prepared, follow these steps to deploy IFM:

    Push Your Repository to GitHub

    Initialize your repository and push to GitHub:

    Terminal window
    git init
    git add Dockerfile .dockerignore
    git commit -m "Initial IFM deployment configuration"
    git remote add origin https://github.com/yourusername/ifm-deploy.git
    git push -u origin main

    Create 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:

    • Select HTTP as the traffic type
    • Set the internal port to 80

    Set Environment Variables

    In the environment variables section, configure your instance:

    VariableValue
    IFM_AUTH1 (recommended for security)
    IFM_ROOT_DIR/var/www/html/data
    IFM_MAXUPLOADSIZE1073741824 (1 GB)

    Attach Persistent Volumes

    Persistent storage is essential for your files. Add the following volume:

    Mount PathRecommended SizePurpose
    /var/www/html/data10+ GBFile storage

    Deploy Your Application

    Click Deploy to start the build process. Klutch.sh will:

    • Detect your Dockerfile automatically
    • Build the container image
    • Attach the persistent volumes
    • Start the IFM container
    • Provision an HTTPS certificate

    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:

  1. Click the edit icon on any text file
  2. Make your changes in the editor
  3. 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:

  1. Set IFM_AUTH=1
  2. Create a secure .htusers.php file with hashed passwords
  3. Use strong, unique passwords

Permission Control

Disable unnecessary features for added security:

# Restrict to read-only access
ENV IFM_UPLOAD=0
ENV IFM_DELETE=0
ENV IFM_RENAME=0
ENV IFM_EDIT=0
ENV IFM_CREATEDIR=0
ENV IFM_CREATEFILE=0

File Access Restrictions

Limit the accessible directory:

# Restrict to specific subdirectory
ENV IFM_ROOT_DIR=/var/www/html/data/public

Troubleshooting 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.php file syntax
  • Ensure IFM_AUTH_SOURCE points 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.