Category: Direct Admin

  • How to Make /cpanel Work on All Domains in DirectAdmin

    By default, DirectAdmin runs on port 2222, which means users need to log in via a URL like:

    http://server.example.com:2222/
    

    The problem? Many firewalls block non-standard ports, making it inconvenient for clients. A cleaner solution is to let users access their control panel from any hosted domain using:

    https://domain.com/cpanel
    

    This guide explains how to configure /cpanel as a proxy frontend for DirectAdmin across all domains, whether you’re running Nginx, Apache, or LiteSpeed.


    Step 1: Why /cpanel?

    Most clients are used to cPanel-style login URLs. Instead of teaching them a new port, /cpanel makes things familiar and professional. Plus, it avoids firewall restrictions and gives you a clean, SSL-secured path.


    Step 2: Configure Nginx (All Domains)

    If your DirectAdmin server is using Nginx:

    1. Open the DirectAdmin Nginx template:
    nano /usr/local/directadmin/data/templates/nginx_server.conf
    
    1. Inside the server { ... } block, add:
    location /cpanel {
        proxy_pass http://127.0.0.1:2222/;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_redirect off;
    }
    
    1. Apply changes:
    cd /usr/local/directadmin/custombuild
    ./build rewrite_confs
    service nginx restart
    

    ✅ Now every domain will serve DirectAdmin at /cpanel.


    Step 3: Configure Apache (All Domains)

    For Apache-based DirectAdmin servers:

    1. Edit the Apache template:
    nano /usr/local/directadmin/data/templates/custom/httpd.conf
    
    1. Add the following inside each <VirtualHost> block:
    ProxyRequests off
    SSLProxyEngine on
    
    <Location "/cpanel">
        ProxyPass "https://127.0.0.1:2222/"
        ProxyPassReverse "https://127.0.0.1:2222/"
    </Location>
    
    1. Rebuild configs and restart Apache:
    cd /usr/local/directadmin/custombuild
    ./build rewrite_confs
    service httpd restart
    

    ✅ Now /cpanel works on all hosted domains.


    Step 4: LiteSpeed / OpenLiteSpeed

    Since LiteSpeed is Apache-compatible, you can reuse the same <Location "/cpanel"> directives in its vhost config. Restart LiteSpeed after making changes.


    Best Practices & Notes

    • Always use 127.0.0.1:2222 for proxying — it avoids DNS resolution loops.
    • Exclude conflicting paths like /roundcube or /phpmyadmin if needed.
    • You can still set up cp.example.com as a dedicated login domain for branding, while keeping /cpanel as a fallback.

    Final Result

    With this setup:

    • https://domain1.com/cpanel
    • https://domain2.com/cpanel
    • https://domain3.com/cpanel

    …all point to DirectAdmin securely — no more confusing ports!


  • How to Use cp.example.com (or Any Subdomain) as a Proxy Frontend for DirectAdmin


    How to Use cp.example.com (or Any Subdomain) as a Proxy Frontend for DirectAdmin

    By default, DirectAdmin runs on port 2222, meaning you need to access your panel at:

    http://server.example.com:2222/
    

    However, some firewalls and networks block custom ports. A better option is to use a subdomain such as cp.example.com and configure it to proxy requests to DirectAdmin. This way, your clients can log in at a clean URL like:

    https://cp.example.com
    

    In this guide, we’ll show you how to set up cp.example.com (or any other subdomain) as a frontend proxy for DirectAdmin using Apache, Nginx, or LiteSpeed.


    Step 1: Create the Subdomain

    1. Log into DirectAdmin at Admin Level → DNS Administration.
    2. Add a DNS record for cp.example.com pointing to your server IP.
    3. Wait for DNS propagation or update your local hosts file for instant testing.

    Step 2: Configure Apache Proxy (if you’re using Apache)

    1. Create a user-level domain cp.example.com under DirectAdmin.
    2. Go to Admin Level → Custom HTTPD Configurations → cp.example.com.
    3. Add the following under the |CUSTOM| section:
    ProxyRequests off
    SSLProxyEngine on
    
    ProxyPass /phpmyadmin !
    ProxyPass /phpMyAdmin !
    ProxyPass /webmail !
    ProxyPass /roundcube !
    
    ProxyPass / "https://server.example.com:2222/"
    ProxyPassReverse / "https://server.example.com:2222/"
    
    1. Restart Apache:
    service httpd restart
    

    Step 3: Configure Nginx Proxy (if you’re using Nginx)

    Edit /etc/nginx/nginx-includes.conf and add:

    server {
       listen 80;
       server_name cp.example.com;
    
       location / {
           proxy_pass http://server.example.com:2222/;
           proxy_set_header Host $host;
           proxy_set_header X-Real-IP $remote_addr;
           proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
       }
    }
    

    Then restart Nginx:

    service nginx restart
    

    Step 4: Configure LiteSpeed Proxy (if you’re using LiteSpeed)

    In Admin → Configuration → Server → External App → Add:

    • Add an external web server pointing to https://cp.example.com:2222.
    • Then, under your virtual host config, add:
    RewriteEngine On
    RewriteRule ^(.*)$ https://cp.example.com:2222/$1 [P,L]
    

    Restart LiteSpeed after changes.


    Step 5: Enable SSL (Recommended)

    Since your panel login contains sensitive information, always enable SSL on your cp.example.com subdomain.

    • In DirectAdmin, enable Free SSL via Let’s Encrypt.
    • Once installed, access your panel securely at:
    https://cp.example.com
    

    Troubleshooting

    • If you see proxy errors, ensure firewall rules allow port 2222.
    • Check logs in /var/log/httpd/ (Apache), /var/log/nginx/, or LiteSpeed logs.
    • If login fails, verify that the X-Forwarded-For IP setting is enabled in DirectAdmin:
    cd /usr/local/directadmin
    ./directadmin set x_forwarded_from_ip 1
    service directadmin restart
    

    ✅ That’s it! Now your users can access DirectAdmin at a friendly URL like https://cp.example.com instead of remembering port numbers.


  • How to Access the DirectAdmin Panel


    How to Access the DirectAdmin Panel (Port 2222, Apache/Nginx/LiteSpeed Proxy Setup)

    DirectAdmin is a powerful and lightweight web hosting control panel. By default, it runs on port 2222, which can sometimes cause accessibility issues for users behind strict firewalls or proxies that block uncommon ports.

    This article explains:

    • How to access DirectAdmin via its default port.
    • How to set up Apache, LiteSpeed, or Nginx to serve DirectAdmin on port 80 or a custom subdomain.
    • How to troubleshoot and test DirectAdmin connectivity.

    Default DirectAdmin Access (Port 2222)

    When installed, DirectAdmin listens on port 2222. You can access it via either the server IP or hostname:

    http://12.34.56.78:2222/
    

    or

    http://hostname.yourdomain.com:2222/
    

    If your ISP or firewall blocks port 2222, you’ll need to set up a reverse proxy through Apache, LiteSpeed, or Nginx to make DirectAdmin accessible via standard ports (80/443).


    Running DirectAdmin Through Apache (Proxy Setup)

    For users unable to connect on port 2222, you can configure Apache to proxy requests through a domain such as cp.example.com.

    Steps:

    1. Create a new domain in DirectAdmin at the User level (e.g., cp.example.com).
      • This makes it easy to enable SSL via Let’s Encrypt.
    2. Go to:
      Admin Level → Custom HTTPD Configuration → cp.example.com
    3. Insert this snippet into the top |CUSTOM| token field:
    |*if SSL_TEMPLATE="1"|
    |?HAVE_PHP1_FCGI=0|
    |?HAVE_PHP2_FCGI=0|
    |?HAVE_PHP1_FPM=0|
    |?HAVE_PHP2_FPM=0|
    |?CLI=0|
    |?HAVE_PHP1_CLI=0|
    |?HAVE_PHP2_CLI=0|
    |?SUPHP=0|
    |?HAVE_PHP1_SUPHP=0|
    |?HAVE_PHP2_SUPHP=0|
           ProxyRequests off
           SSLProxyEngine on
    
           ProxyPass /phpmyadmin !
           ProxyPass /phpMyAdmin !
           ProxyPass /webmail !
           ProxyPass /roundcube !
    
           ProxyPass / "https://server.example.com:2222/"
           ProxyPassReverse / "https://server.example.com:2222/"
           #ProxyPreserveHost On
    |*else|
           RewriteEngine On
           RewriteCond %{HTTPS} off
           RewriteCond %{REQUEST_URI} !^/.well-known
           RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
    |*endif|
    

    Set proper client IP logging:

    cd /usr/local/directadmin
    ./directadmin set x_forwarded_from_ip "12.34.56.78"
    service directadmin restart
    

    🔑 Note: Ensure SSL is enabled for your hostname so the proxy can securely connect to DirectAdmin on port 2222.


    Running DirectAdmin Through LiteSpeed

    LiteSpeed works differently and uses rewrite rules instead of ProxyPass.

    In the custom template for cp.example.com, add:

    |*if SSL_TEMPLATE="1"|
    |?HAVE_PHP1_FCGI=0|
    |?HAVE_PHP2_FCGI=0|
    |?HAVE_PHP1_FPM=0|
    |?HAVE_PHP2_FPM=0|
    |?CLI=0|
    |?HAVE_PHP1_CLI=0|
    |?HAVE_PHP2_CLI=0|
    |?SUPHP=0|
    |?HAVE_PHP1_SUPHP=0|
    |?HAVE_PHP2_SUPHP=0|
          RewriteEngine On
          RewriteRule ^(.*)$ https://cp.|DOMAIN|:2222/$1 [P,L]
    |*else|
          RewriteEngine On
          RewriteCond %{HTTPS} off
          RewriteCond %{REQUEST_URI} !^/.well-known
          RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
    |*endif|
    

    ⚠️ If you see an error like:

    [REWRITE] Proxy target is not defined on external application list
    

    you’ll need to add the proxy target in LiteSpeed Admin:
    Configuration → Server → External App → Add → define a Web Server entry for your DirectAdmin host. Then perform a graceful reload.


    Running DirectAdmin Through Nginx

    If your server runs Nginx, edit /etc/nginx/nginx-includes.conf and add:

    server {
       listen 12.34.56.78:80;
       server_name cp.example.com;
    
       include /etc/nginx/webapps.conf;
    
       location / {
           proxy_pass       http://server.example.com:2222/;
           proxy_set_header Host $host;
           proxy_set_header X-Real-IP $remote_addr;
           proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
           proxy_redirect http://cp.example.com:2222/ http://cp.example.com/;
       }
    }
    

    Restart Nginx:

    service nginx restart
    

    Troubleshooting Access Issues

    1. Referer mismatch errors
      If you see logs like: Referer port (443) does not match DA's (2222) Disable referer checks: DirectAdmin feature #2194.
    2. Debugging DirectAdmin
      Run DirectAdmin in debug mode (level 2000) to see detailed connection logs.

    Actively Testing DirectAdmin Connectivity

    To ensure DirectAdmin is running and logins work, create a login key and a test script.

    1. In DirectAdmin, create a Login Key (Admin → Login Keys) with:
      • Allowed Command: CMD_API_LOGIN_TEST
      • Allowed IP: 127.0.0.1
    2. Save the login key string.
    3. Create a script /home/username/da_test.sh:
    #!/bin/sh
    DEBUG=0
    USER="username"
    PASSWORD="loginkey"
    
    CONFIG=curl_config.txt
    echo -n '' > ${CONFIG}
    echo "user = \"${USER}:${PASSWORD}\"" >> ${CONFIG}
    
    RUN="curl --config ${CONFIG} --silent --show-error http://127.0.0.1:2222/CMD_API_LOGIN_TEST"
    
    RESULT=`eval $RUN 2>&1`
    COUNT=`echo "$RESULT" | grep -c 'error=0'`
    if [ "${COUNT}" -gt 0 ]; then
       echo "DirectAdmin is running correctly."
       exit 0
    else
       echo "DirectAdmin login test failed."
       exit 1
    fi
    
    1. Make it executable:
    chmod 700 /home/username/da_test.sh
    
    1. Run manually:
    /home/username/da_test.sh; echo $?
    

    If you see 0, the test succeeded.

    1. (Optional) Schedule it with Cron under DirectAdmin’s User Level → Cron Jobs to monitor DirectAdmin automatically.

    Conclusion

    By default, DirectAdmin is only accessible via port 2222, but you can easily make it available through Apache, LiteSpeed, or Nginx on port 80/443 using reverse proxies.

    • Use cp.example.com or another subdomain as the proxy frontend.
    • Ensure SSL certificates are installed.
    • Test connectivity using DirectAdmin’s login key API.

    This setup improves accessibility for users behind firewalls and makes your hosting control panel look more professional.


  • How to Migrate All cPanel Accounts to DirectAdmin


    How to Migrate All cPanel Accounts to DirectAdmin

    With cPanel license costs rising, many hosting providers are migrating to DirectAdmin as a lightweight and cost-effective alternative. DirectAdmin provides migration tools that make it possible to transfer all cPanel accounts without losing websites, databases, or emails.

    In this guide, we’ll walk through the exact steps to move all accounts from cPanel to DirectAdmin.


    Prerequisites

    Before you begin:

    • Root SSH access to both the cPanel server and the DirectAdmin server.
    • Enough free disk space to store temporary backups.
    • rsync installed (usually preinstalled on Linux).

    Step 1: Create Backups of All cPanel Accounts

    On the cPanel server, create a directory for backups:

    mkdir -p /home/all_backups
    

    Now generate backups for every cPanel user account:

    for user in `ls /var/cpanel/users/`; do { /scripts/pkgacct ${user} /home/all_backups; }; done
    

    This will create a set of backup files in /home/all_backups/, one for each cPanel account.
    Each backup will look like:

    /home/all_backups/cpmove-USERNAME.tar.gz
    

    Step 2: Transfer Backups to DirectAdmin Server

    Next, transfer all backups to the DirectAdmin server. Replace your_directadmin_server.com with your server hostname or IP:

    rsync -avt --delete /home/all_backups/ root@your_directadmin_server.com:/home/admin/all_backups/
    

    Now you can disconnect from the cPanel server — we’re done with it.


    Step 3: Fix File Ownership on DirectAdmin

    On the DirectAdmin server, make sure all transferred backups belong to the admin user:

    chown -R admin. /home/admin/all_backups
    

    Step 4: Restore Accounts in DirectAdmin

    Now restore all accounts through DirectAdmin’s admin panel:

    1. Log in as admin.
    2. Go to Admin Level → Admin Backup/Transfer → Restore.
    3. Set the path to: /home/admin/all_backups
    4. Select the accounts and click Restore.

    DirectAdmin will now restore all websites, databases, emails, and DNS settings from the converted backups.


    Step 5: Keep Backups for Safety

    It’s a good idea to leave /home/admin/all_backups on the DirectAdmin server for a few weeks or months.
    If something was missed during migration, you can easily extract it from the backup.


    Alternative Method: Limited Disk Space on cPanel Server

    If your cPanel server does not have enough space to generate all backups at once, you can migrate account by account and transfer directly to the DirectAdmin server.

    First, set up passwordless SSH access between servers:

    1. On the cPanel server, generate an SSH key: ssh-keygen (Press Enter to accept defaults).
    2. Copy the contents of /root/.ssh/id_rsa.pub to the DirectAdmin server’s file: /root/.ssh/authorized_keys (Create the /root/.ssh/ directory if it does not exist).

    Now you can loop through accounts one by one, transferring immediately after backup:

    for user in `ls /var/cpanel/users/`; do { 
        /scripts/pkgacct ${user} /home/all_backups; 
        rsync -avt /home/all_backups/cpmove-${user}.tar.gz root@your_directadmin_server.com:/home/admin/all_backups/cpmove-${user}.tar.gz; 
        rm -f /home/all_backups/cpmove-${user}.tar.gz; 
    }; done
    

    This method ensures only one backup exists at a time, saving disk space.


    Verification

    After migration, test:

    • Websites load correctly.
    • Databases are intact.
    • Email accounts are working.
    • DNS records are correct.

    Conclusion

    Migrating all accounts from cPanel to DirectAdmin is straightforward with the pkgacct tool and DirectAdmin’s built-in migration system.

    • If you have enough space, back up all accounts, transfer them, and restore in bulk.
    • If not, migrate accounts one by one using rsync with SSH keys.

    This approach ensures a smooth transition from cPanel to DirectAdmin without downtime.


  • How to Migrate a Single cPanel Account to DirectAdmin


    How to Migrate a Single cPanel Account to DirectAdmin

    Switching from cPanel to DirectAdmin is becoming more common due to rising cPanel licensing costs. DirectAdmin provides a lightweight, cost-effective alternative, but migrating accounts between the two control panels requires some manual work.

    In this guide, we’ll cover how to migrate a single cPanel user account to DirectAdmin using the built-in migration tools.


    Prerequisites

    Before starting, ensure you have:

    • Root SSH access to both the cPanel server and the DirectAdmin server.
    • Enough disk space on both servers to create and transfer backups.
    • rsync or scp installed (usually preinstalled).

    Step 1: Create a cPanel Backup

    On the cPanel server, we need to generate a full account backup using cPanel’s pkgacct tool.

    Run this command (replace USERNAME with the actual cPanel username):

    /scripts/pkgacct USERNAME /home/user_backups
    

    This will create a backup file in the /home/user_backups directory.
    The backup file will look like:

    /home/user_backups/cpmove-USERNAME.tar.gz
    

    Step 2: Transfer the Backup to DirectAdmin Server

    Once the backup is ready, copy it to your DirectAdmin server. You can use rsync or scp.

    Example with rsync:

    rsync -avt /home/user_backups/cpmove-USERNAME.tar.gz root@your_directadmin_server.com:/home/admin/
    

    🔑 Make sure you replace your_directadmin_server.com with your server’s hostname or IP.

    Now the cPanel backup is on the DirectAdmin server in /home/admin/.


    Step 3: Convert the Backup for DirectAdmin

    DirectAdmin cannot restore a raw cPanel backup directly. We need to convert it first using the built-in cpanel_to_da tool.

    On the DirectAdmin server, run:

    /usr/local/directadmin/shared/cpanel_to_da/cpanel_to_da.sh /home/admin/cpmove-USERNAME.tar.gz /home/admin/converted_user_backup/
    

    This command will extract and convert the backup into a format that DirectAdmin can import.


    Step 4: Fix Ownership of the Converted Backup

    Ensure the converted files belong to the admin user, otherwise DirectAdmin won’t see them.

    Run:

    chown -R admin:admin /home/admin/converted_user_backup
    

    Step 5: Restore the Account in DirectAdmin

    Now we’re ready to restore the converted account from inside DirectAdmin.

    1. Log in to DirectAdmin as admin.
    2. Go to:
      Admin Level → Admin Backup/Transfer → Restore
    3. Set the backup path to: /home/admin/converted_user_backup
    4. Select the backup and click Restore.

    DirectAdmin will now import the account, including:

    • Website files
    • Databases
    • Emails
    • DNS settings

    Step 6: Verify the Migration

    After restoration:

    • Log in as the migrated user to check the website files.
    • Verify MySQL databases are working correctly.
    • Test email accounts.
    • Confirm DNS and domains are properly configured.

    Common Issues

    • Database errors: Sometimes MySQL versions differ between servers. Export and import databases manually if needed.
    • Email issues: Check email paths and adjust if the user had custom mail setups.
    • Disk space: Ensure your /home/admin/ directory has enough space before transferring large accounts.

    Conclusion

    Migrating a single cPanel account to DirectAdmin is straightforward with the pkgacct tool and DirectAdmin’s cpanel_to_da converter.

    The process can be summarized as:

    1. Create a cPanel backup with pkgacct.
    2. Transfer the backup to DirectAdmin.
    3. Convert it with cpanel_to_da.sh.
    4. Restore it via the DirectAdmin admin panel.

    This ensures websites, databases, and emails move smoothly during your cPanel to DirectAdmin migration.


  • Redirect cPanel Ports (2083 & 2087) to DirectAdmin Port 2222 – Migration Guide


    How to Redirect cPanel Ports (2083 & 2087) to DirectAdmin Port 2222

    Migrating from cPanel to DirectAdmin can be confusing for end-users, especially when it comes to login ports.

    • In cPanel, customers log in to their hosting account at https://domain.com:2083 and WHM at https://domain.com:2087.
    • In DirectAdmin, the login panel runs on port 2222 by default.

    This change often leads to support tickets from customers who still try to access :2083 or :2087. The good news is, you can easily redirect ports 2083 and 2087 to 2222, so old bookmarks and habits continue to work.


    Why Redirect cPanel Ports to DirectAdmin?

    • Seamless migration – Users don’t have to learn a new port right away.
    • Lower support load – Reduce “I can’t log in” tickets after migration.
    • Professional experience – Makes DirectAdmin feel like a drop-in replacement for cPanel.

    Method 1: Redirect with iptables (Recommended)

    If your Linux server uses iptables, add NAT rules to forward requests.

    Redirect port 2083 to 2222

    iptables -t nat -A PREROUTING -p tcp --dport 2083 -j REDIRECT --to-ports 2222
    

    Redirect port 2087 to 2222

    iptables -t nat -A PREROUTING -p tcp --dport 2087 -j REDIRECT --to-ports 2222
    

    Save the Rules

    These rules disappear after a reboot unless saved:

    • On CentOS / AlmaLinux / RHEL:
    service iptables save
    # or
    iptables-save > /etc/sysconfig/iptables
    
    • On Ubuntu / Debian:
    apt install iptables-persistent -y
    iptables-save > /etc/iptables/rules.v4
    

    Method 2: Redirect with firewalld (Alternative)

    If your server runs firewalld, use this instead:

    firewall-cmd --permanent --add-forward-port=port=2083:proto=tcp:toport=2222
    firewall-cmd --permanent --add-forward-port=port=2087:proto=tcp:toport=2222
    firewall-cmd --reload
    

    Testing the Redirect

    Once rules are applied:

    • https://yourdomain.com:2083 → loads DirectAdmin login.
    • https://yourdomain.com:2087 → loads DirectAdmin login.
    • https://yourdomain.com:2222 → continues to work normally.

    Final Thoughts

    When performing a cPanel to DirectAdmin migration, handling ports properly makes a huge difference for end-users. By forwarding ports 2083 and 2087 to 2222, you:

    • Improve the customer experience.
    • Prevent confusion and login errors.
    • Smoothly transition away from cPanel without disruption.

    This is a quick fix that takes only a few minutes but saves hours of support work later.