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.


Comments

Leave a Reply

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