How to Enable Gzip and Brotli Compression in DirectAdmin (Apache & Nginx)

Priya

Content Writer & Researcher

Last Updated: 27 August 2026
How to Enable Gzip and Brotli Compression in DirectAdmin (Apache & Nginx)
πŸ–₯️

Is Your DirectAdmin Server Compressing Assets Correctly?

CloudHouse's server management team configures Gzip and Brotli compression across your entire DirectAdmin server stack β€” Nginx, Apache, and all domains β€” so every page loads faster from day one.

πŸ–₯️12,400+PCs Fixed
⭐4.9β˜…Google Rating
⚑<15 minAvg. Response
πŸ›‘οΈISO 27001Certified

If your DirectAdmin server is delivering uncompressed HTML, CSS, and JavaScript to browsers, you're adding hundreds of milliseconds to every page load for every visitor. Compression reduces the size of text-based assets by 30–70%, cuts bandwidth costs, and directly improves Google Core Web Vitals scores β€” particularly Largest Contentful Paint (LCP) and Time to First Byte (TTFB).

DirectAdmin servers use Apache (managed via CustomBuild), Nginx (as a reverse proxy or standalone), or both in a combined stack. This guide covers enabling both Gzip and Brotli compression for each configuration.

Gzip vs Brotli: Which Should You Use?

  • Gzip β€” supported by all browsers and all server stacks; typical compression ratio of 60–70% for HTML/CSS/JS; very low CPU overhead.
  • Brotli β€” supported by all modern browsers (Chrome, Firefox, Safari, Edge); typical compression ratio of 70–80% (Brotli compresses HTML ~21% smaller than Gzip, JS ~14% smaller); requires HTTPS (Brotli is only served over HTTPS by design); slightly higher CPU overhead at high compression levels.

The best approach is to enable both: Brotli for clients that support it (served with Accept-Encoding: br), and Gzip as the fallback. Nginx and Apache will select the best encoding based on the browser's request headers automatically.

πŸ’‘ None of these worked? Skip the guesswork.

Get Expert Help β†’

Step 1: Enable Gzip Compression in Nginx (DirectAdmin)

On DirectAdmin servers with Nginx configured as a standalone server or reverse proxy, Gzip is typically available but disabled or minimally configured by default.

1Edit the Nginx global configuration
nano /etc/nginx/nginx.conf
2Add or update the Gzip block inside the http {} block
http {
    # Gzip compression
    gzip on;
    gzip_vary on;
    gzip_proxied any;
    gzip_comp_level 6;
    gzip_buffers 16 8k;
    gzip_http_version 1.1;
    gzip_min_length 256;
    gzip_types
        text/plain
        text/css
        text/xml
        text/javascript
        application/javascript
        application/x-javascript
        application/json
        application/xml
        application/rss+xml
        application/atom+xml
        image/svg+xml
        font/ttf
        font/otf
        font/woff
        font/woff2;
}

Key settings explained:

  • gzip_comp_level 6: good balance between compression ratio and CPU usage (range 1–9; 6 is the standard recommendation)
  • gzip_vary on: adds the Vary: Accept-Encoding header so CDNs and proxies cache both compressed and uncompressed versions
  • gzip_min_length 256: skips compression for very small files where the overhead isn't worthwhile
3Test and reload Nginx
nginx -t && systemctl reload nginx
1Verify mod_deflate is loaded
httpd -M 2>/dev/null | grep deflate
# or:
apachectl -M 2>/dev/null | grep deflate
# Expected output: deflate_module (shared)

If it's not listed, enable it via CustomBuild:

cd /usr/local/directadmin/custombuild
./build set deflate yes
./build apache
2Add the Gzip (mod_deflate) configuration

Create or edit /etc/httpd/conf.d/deflate.conf (AlmaLinux/RHEL) or /etc/apache2/conf-enabled/deflate.conf (Ubuntu/Debian):

<IfModule mod_deflate.c>
    AddOutputFilterByType DEFLATE text/html text/plain text/xml
    AddOutputFilterByType DEFLATE text/css text/javascript
    AddOutputFilterByType DEFLATE application/javascript application/x-javascript
    AddOutputFilterByType DEFLATE application/json application/xml
    AddOutputFilterByType DEFLATE application/rss+xml application/atom+xml
    AddOutputFilterByType DEFLATE image/svg+xml
    AddOutputFilterByType DEFLATE font/ttf font/otf font/woff font/woff2

    # Don't compress already-compressed formats
    SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png|rar|zip|exe|flv|mov|wma|mp3|mp4)$ no-gzip dont-vary

    # Add Vary header for correct CDN caching
    Header append Vary Accept-Encoding
</IfModule>
3Restart Apache
systemctl restart httpd   # AlmaLinux/RHEL
# or:
systemctl restart apache2  # Ubuntu/Debian

Step 4: Enable Brotli in Apache (DirectAdmin CustomBuild)

Apache 2.4.26+ supports mod_brotli. On DirectAdmin with CustomBuild, you can compile it in:

cd /usr/local/directadmin/custombuild
./build set brotli yes
./build apache

Then add the Brotli configuration alongside mod_deflate:

<IfModule mod_brotli.c>
    AddOutputFilterByType BROTLI_COMPRESS text/html text/plain text/xml
    AddOutputFilterByType BROTLI_COMPRESS text/css text/javascript
    AddOutputFilterByType BROTLI_COMPRESS application/javascript application/json
    AddOutputFilterByType BROTLI_COMPRESS application/xml application/rss+xml
    AddOutputFilterByType BROTLI_COMPRESS image/svg+xml font/woff font/woff2
    BrotliCompressionQuality 5
</IfModule>

Restart Apache after the change.

Step 5: Test That Compression Is Working

Always verify that compression is actually being applied β€” misconfigured MIME types or module load order can silently prevent it.

Test with curl from the server:

# Test Gzip
curl -H "Accept-Encoding: gzip" -I https://yourdomain.com/
# Look for: Content-Encoding: gzip in response headers

# Test Brotli
curl -H "Accept-Encoding: br" -I https://yourdomain.com/
# Look for: Content-Encoding: br in response headers

Test a specific CSS or JS file:

curl -H "Accept-Encoding: br,gzip" -s -o /dev/null -w "%{size_download} %{content_type}
" -D - https://yourdomain.com/wp-content/themes/yourtheme/style.css | grep -E "Content-Encoding|Content-Length"

Online tools:

  • GIDNetwork Compression Test β€” enter your URL and it reports whether Gzip/Brotli is active and the compression ratio
  • Google PageSpeed Insights β€” flags "Enable text compression" if assets are uncompressed
  • GTmetrix β€” shows compression status per asset under the Waterfall tab

Per-Domain and Per-Directory Configuration via .htaccess

If you want to enable compression only for specific domains without modifying the global server config, add this to the domain's .htaccess file:

<IfModule mod_deflate.c>
    AddOutputFilterByType DEFLATE text/html text/plain text/css application/javascript application/json
    Header append Vary Accept-Encoding
</IfModule>

Note: .htaccess-based compression only works for Apache. Nginx ignores .htaccess files β€” use the nginx.conf approach for Nginx vhosts.

Expected Performance Improvement

  • HTML files: 60–80% smaller (a 100 KB page becomes 20–40 KB)
  • CSS files: 50–70% smaller
  • JavaScript files: 50–65% smaller with Gzip; 60–70% with Brotli
  • JSON API responses: 60–80% smaller

For a typical WordPress site, enabling compression reduces total page weight from 500 KB to under 200 KB, cutting LCP times by 200–400ms on average connections. This can lift Google PageSpeed scores by 10–20 points.

If you're managing multiple DirectAdmin servers and want compression tuned correctly across every domain and stack, CloudHouse's managed server service handles Nginx and Apache performance configuration β€” including compression, caching, and HTTP/2 β€” as part of our ongoing server management plans.

Get the Free Linux Server Admin Cheatsheet (PDF)

Essential commands for server management, networking, and troubleshooting β€” all on one printable page.

Running Linux servers? Let us manage them for you.

Our Managed Linux Server plans cover updates, security hardening, monitoring, and 24/7 incident response β€” so your servers stay up and your team stays focused.

  • Proactive OS patching and security updates
  • 24Γ—7 monitoring with instant alerting
  • Backup configuration and disaster recovery
  • Dedicated Linux engineers on call
See Pricing Plans β†’

What our customers say

β€œOur production server went down at 2 AM. CloudHouse had it back online in under 20 minutes. Incredible response time.”

Arun S.

CTO, SaaS Startup

β€œThey migrated our entire infrastructure from Ubuntu 18 to 22 with zero downtime. Couldn't have asked for better.”

Deepak N.

DevOps Lead

Frequently Asked Questions

Not by default. Brotli requires the ngx_brotli module for Nginx or mod_brotli for Apache, which must be compiled in via DirectAdmin's CustomBuild. Run './build set nginx_brotli yes && ./build nginx' (for Nginx) or './build set brotli yes && ./build apache' (for Apache) in the /usr/local/directadmin/custombuild directory.

Need this done for you?

Server Management Service

Managed Linux and Windows servers: monitoring, patching, security and 24/7 support.

Learn more

Book your free 15-minute diagnosis

A certified technician will call you back within 15 minutes during business hours.

Share this article

Leave a Comment

Comments (0)

Loading comments...