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!


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *