cPanel is the most widely-deployed Linux hosting control panel. On cPanel servers, security headers are added via .htaccess at the account level — Apache's mod_headers is enabled by default on every cPanel install. This guide covers every fix our Security Audit raises on a cPanel-hosted site: HTTP security headers via .htaccess, modern TLS via WHM, and publishing security.txt. Tested against cPanel 116 on CloudLinux 8. For raw Apache (cPanel's underlying web server), see the Apache variant; for the full finding catalogue, see Security Audit Fixes.
Every cPanel account has a public_html directory. The .htaccess file lives at its root. If absent, you can create it from File Manager.
public_html. If .htaccess is not visible, click Settings (top right) and tick Show Hidden Files (dotfiles)..htaccess → Edit. If the file does not exist, click + File at the top, name it .htaccess, then edit.Paste the following block at the top of .htaccess. The IfModule wrapper prevents a 500 error on the rare cPanel server without mod_headers loaded.
<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>Save the file.
Header always set not Header set — the 'always' qualifier applies the header to error responses too, which is when an attacker is probing your server.cPanel servers expose TLS configuration through WHM (the root-level admin panel). If you only have cPanel access (not WHM), ask your host to apply these settings.
SSL/TLS Protocols. Set The list of SSL/TLS protocols for cPanel services to TLSv1.2 TLSv1.3. Save.all -SSLv3 -TLSv1 -TLSv1.1. Save and rebuild config (WHM prompts automatically).RFC 9116 standardises the /.well-known/security.txt path. cPanel makes this trivial via File Manager.
public_html → + Folder → name it .well-known. Inside that folder, + File → security.txt. Edit and paste: Contact: mailto:security@yourdomain.com Expires: 2027-05-18T00:00:00.000Z Preferred-Languages: en Canonical: https://yourdomain.com/.well-known/security.txt
.htaccess, add: <Files "security.txt"> ForceType text/plain </Files>
Test from outside the server:
curl -sI https://yourdomain.com/ | grep -iE "strict-transport|x-frame|x-content|referrer|permissions|content-security"All six headers should appear. Then re-run the Security Audit for full verification.
Verify every header, TLS protocol and security.txt with a fresh scan.
Run Security Audit →