Apache 2.4.2版本无需升级如何禁用HTTP压缩或SSL压缩
Hey there, I’ve dealt with this exact scenario for Apache 2.4.2 before—no upgrade needed. Let’s break down how to disable both HTTP compression and SSL compression step by step:
禁用HTTP压缩
Apache 2.4.2 uses mod_deflate for HTTP compression, so we’ll target that module and its configurations:
- Locate your main Apache config file (usually
httpd.conf) or the specific virtual host config you want to modify. - If you want to fully disable the module, comment out the
mod_deflateload line (if present):# LoadModule deflate_module modules/mod_deflate.so - If you prefer to keep the module loaded but turn off compression globally, add these lines to your config:
SetEnv no-gzip 1 SetEnv dont-vary 1 - For virtual host-specific disablement, place the above two
SetEnvlines inside the<VirtualHost>block of your target domain. - Double-check for any existing
AddOutputFilterByType DEFLATE ...directives in your configs and comment them out—these might override global disablement for specific content types.
禁用SSL压缩
For SSL compression, we’ll use the SSLCompression directive supported in Apache 2.4.2 via mod_ssl:
- Open your SSL-related config (either in
httpd.conf,ssl.conf, or your SSL virtual host block). - Add or modify this line to turn off SSL compression:
SSLCompression off - Make sure
mod_sslis loaded (you’ll see a line likeLoadModule ssl_module modules/mod_ssl.so—leave this uncommented, as we need the module to apply the directive).
验证配置是否生效
After making changes, restart your Apache service:
# For most Linux systems apachectl restart # Or service httpd restart
- Test HTTP compression: Run this curl command and check that the response does NOT include a
Content-Encoding: gzipheader:curl -I -H "Accept-Encoding: gzip, deflate" http://your-domain.com - Test SSL compression: Use openssl to connect and verify compression is set to
NULL:
Look for the lineopenssl s_client -connect your-domain.com:443 -tls1_2Compression: NULLin the output—this confirms SSL compression is disabled.
内容的提问来源于stack exchange,提问作者shriyash Lakhe
相关产品推荐
相关产品推荐

