DirectAdmin is a popular lightweight alternative to cPanel and Plesk. It uses Apache or Apache+nginx via CustomBuild, both of which support security header injection. This guide walks through every fix our Security Audit raises on a DirectAdmin server: HTTP headers via .htaccess (per-account) or CustomBuild custom HTTPD includes (server-wide), TLS via CustomBuild options, and publishing security.txt. Tested against DirectAdmin 1.66 on AlmaLinux 9. For raw Apache configuration, see the Apache variant; for the full finding catalogue, see Security Audit Fixes.
If you only need headers for one or two accounts, the .htaccess approach is fastest.
domains/yourdomain.com/public_html. Toggle Show hidden files if .htaccess is invisible..htaccess and add: <IfModule mod_headers.c> Header always set Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" Header always set X-Frame-Options "SAMEORIGIN" Header always set X-Content-Type-Options "nosniff" Header always set Referrer-Policy "strict-origin-when-cross-origin" Header always set Permissions-Policy "geolocation=(), microphone=(), camera=()" Header always set Content-Security-Policy "default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' data: https:; frame-ancestors 'self'" </IfModule>
For a server-wide policy that applies to every domain without editing each .htaccess, use DirectAdmin's CustomBuild custom HTTPD includes. This requires root SSH access.
mkdir -p /usr/local/directadmin/custombuild/custom/ap2/conf/extra nano /usr/local/directadmin/custombuild/custom/ap2/conf/extra/httpd-includes.confPaste the six
Header always set directives (same syntax as the .htaccess version, no IfModule wrapper needed at server level).cd /usr/local/directadmin/custombuild ./build rewrite_confsThe custom include is now applied to every Apache vhost on the server.
cd /usr/local/directadmin/custombuild ./build set http2 yes ./build set tls13 yes ./build rewrite_confsThis enables TLSv1.2 and TLSv1.3, disables older protocols, and switches on HTTP/2.
public_html โ create .well-known/security.txt with: Contact: mailto:security@yourdomain.com Expires: 2027-05-18T00:00:00.000Z Preferred-Languages: en Canonical: https://yourdomain.com/.well-known/security.txt
.htaccess: <Files "security.txt"> ForceType text/plain </Files>
curl -sI https://yourdomain.com/ | grep -iE "strict-transport|x-frame|x-content|referrer|permissions|content-security"All six should appear. Re-run the Security Audit.
Verify every header, TLS protocol and security.txt with a fresh scan.
Run Security Audit โ