Problem with mod_deflate - compressing executable file

517 views Asked by At

When trying to download file with.EXE extension in the site, the files are coming as .GZ Environment Centos 7 64 Apache 2.4.6

Changing the file in /etc/httpd/conf/httpd.conf I have already tried using each of these forms below, however, to no avail (I restarted apache and deleted the browser cache on each attempt):

1:

SetEnvIfNoCase Request_URI \.exe$ no-gzip dont-vary

2:

 <FilesMatch \.exe$>
        SetEnv no-gzip 1
    </FilesMatch>

3:

SetEnv mod_deflate off

4:

SetEnv no-gzip off

5: In the file /etc/httpd/conf.modules.d/00-base.conf I commented:

LoadModule deflate_module modules/mod_deflate.so

6: I tried to delete the file, but it did not work.

/usr/lib64/httpd/modules/mod_deflate.so
1

There are 1 answers

3
Mylon On

I was reviewing httpd.conf and when I removed the addtype directive (AddType application / x-gzip .tgz .rar .zip .exe .dll) the EXE file was no longer compressed.

I had put this because the browser was taking too long to start the download EXE, in addition, RAR file instead of downloading, was being displayed as a binary in the browser.

So I did the following to solve (I do not know if it was the indicated output, but my knowledge is not enough, I'm new in this area):

<IfModule mod_deflate.c>
# compress text, html, javascript, css, xml...:
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/atom_xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript
AddOutputFilterByType DEFLATE application/x-httpd-php
AddOutputFilterByType DEFLATE application/x-httpd-fastphp
AddOutputFilterByType DEFLATE application/x-httpd-eruby
SetOutputFilter DEFLATE
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4.0[678] no-gzip
BrowserMatch ^HMSI[E] !no-gzip !gzip-only-text/html
SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png|zip|bz2|rar|exe|pdf|doc|dll|jpg|sit|mp4|mov|mp3|3gp|webm|rm|avi|ogv)$ no-gzip dont-vary
<FilesMatch \.exe$>
ForceType application/exe
Header set Content-Disposition attachment
</FilesMatch>
<FilesMatch \.rar$>
ForceType application/rar
Header set Content-Disposition attachment
</FilesMatch>
</IfModule>