DeveloperSide.NET Forums
July 24, 2019, 12:12:50 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1] 2
  Print  
Author Topic: Apache 2.0.49 - Broken mod_deflate, anyone?  (Read 45830 times)
0 Members and 1 Guest are viewing this topic.
mikeq
Guest
« on: March 21, 2004, 05:50:12 AM »

ever since i upgraded from 2.0.48 to 2.0.49 mod_deflate started
messing up all ".zip" files on my server. i have already set a rule to
exclude .zip from being gzipped (its the same rule i used for 2.0.48,
never had a problem) but apache 2.0.49 ignored this rule and caused
all .zip files to be corrupt after being downloaded.

i rolled back to 2.0.48 and everything's been working fine.
Logged
Anonymous
Guest
« Reply #1 on: March 21, 2004, 07:57:52 AM »

zlib 1.1.4 or 1.2.1 ?
Logged
mikeq
Guest
« Reply #2 on: March 21, 2004, 08:27:03 AM »

1.2.1

it works perfectly with 2.0.48.
Logged
Anonymous
Guest
« Reply #3 on: March 21, 2004, 06:54:42 PM »

Nothing yet on the Usenet groups about it....
Nothing on the httpd-users list...
Nothing on the Apache bug database...

post your httpd.conf (please use the code function to format) and we will take a look at it...
Logged
mikeq
Guest
« Reply #4 on: March 21, 2004, 07:32:12 PM »

the following options were used to compile apache (both 2.0.48 and 2.0.49)

Code:

CFLAGS="-I/usr/kerberos/include/ -L/usr/kerberos/lib" ./configure --prefix=/usr/local/apache --enable-so --enable-cgi --enable-info --enable-rewrite --enable-speling --enable-usertrack --with-z=/usr/local --enable-deflate --enable-mime-magic --enable-headers --enable-ssl


compilation returns no errors.

here's the mod_deflate configuration section from httpd.conf

Code:

<IfModule mod_deflate.c>
SetOutputFilter DEFLATE
DeflateCompressionLevel 6
SetEnvIfNoCase Request_URI \.(?:gif|jp?g|png|svg|js)$ no-gzip dont-vary
SetEnvIfNoCase Request_URI \.(?:exe|t?gz|z|zip|bz2|rar|mp3|swf)$ no-gzip dont-vary
SetEnvIfNoCase Request_URI \.pdf$ no-gzip dont-vary

AddOutputFilterByType DEFLATE text/*

BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html

<IfModule mod_headers.c>
Header append Vary User-Agent env=!dont-vary
</IfModule>

</IfModule>


now under apache 2.0.48 everything works fine. all extensions defined as exlustions are not gzipped and files can be downloaded without a problem.

under apache 2.0.49 all files in .zip format on the server are corrupt after being downloaded. the problem is solved by commenting out all mod_deflate directives in httpd.conf

there's definitely a problem with 2.0.49.
Logged
mikeq
Guest
« Reply #5 on: March 23, 2004, 10:10:36 PM »

i have noticed that devside.net has not updated the apache building section of the tutorials. i guess there's a reason for this...
Logged
admin
Administrator
Master of All Subjects
*****
Posts: 3272


View Profile WWW Email
« Reply #6 on: March 23, 2004, 11:12:44 PM »

Perhaps you should try method #1...

http://www.devside.net/web/config/compression

Code:

<Location />
  <IfModule mod_deflate.c>
    # compress content with type html, text, and css
    AddOutputFilterByType DEFLATE text/html text/plain text/css
    <IfModule mod_headers.c>
      # properly handle requests coming from behind proxies
      Header append Vary User-Agent
    </IfModule>
  </IfModule>
</Location>


<IfModule mod_deflate.c>
  BrowserMatch ^Mozilla/4 gzip-only-text/html
  BrowserMatch ^Mozilla/4\.0[678] no-gzip
  BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
</IfModule>


Actually, your original code has a problem...

Quote

Code:

SetOutputFilter DEFLATE
...
AddOutputFilterByType DEFLATE text/*


That does NOT seem correct.  You are setting the DEFLATE filter twice, and this might be the root of your problems.  It might have worked under 2.0.48, but under 2.0.49 this could cause problems.

Get rid of the first one (SetOutputFilter DEFLATE), and also define those "text/*", as I have found in the past that "text/*" has some problems.

Also, look at the httpd.conf section of...

http://www.devside.net/web/server/linux
Logged

DeveloperSide.NET
Advanced PHP and MySQL Solutions for your Web Design and Development needs with Web.Developer Server Suite.
mikeq
Guest
« Reply #7 on: March 24, 2004, 01:39:53 AM »

thanks admin. the problem was resolved by using method#1.

yes my original configuration has that problem u pointed out. however it was not the cause of the problem. apache 2.0.49 simply wont work with method#2. i have tried the standard method#2 by using ur directives

Code:

<IfModule mod_deflate.c>
  # place filter 'DEFLATE' on all outgoing content
  SetOutputFilter DEFLATE
  # exclude uncompressible content via file type
  SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png|rar|zip)$ no-gzip
  <IfModule mod_headers.c>
    # properly handle requests coming from behind proxies
    Header append Vary User-Agent
  </IfModule>
</IfModule>


and the result was .zip files were still corrupted even tho it was explicly excluded from being gzipped. i guess its 2.0.49's bug.

i have one more question tho regarding

Code:

Header append Vary User-Agent


this works fine with all .html, .htm and .css files as defined by

Code:

AddOutputFilterByType DEFLATE text/html text/plain text/css


however it wont append this User-Agent header for my .php files. my .php files were obviously seen as "text/html" and they were indeed being gzipped. (it returns vary: accept-encoding) however User-Agent is missing. i fear that this may cause problems for my visitors as most of my web pages are .php files.

i tried adding "application/x-httpd-php" in AddOutputFilterByType and got no luck. it works fine with method#1 tho. (appended after accept-encoding)

thanks again!
Logged
admin
Administrator
Master of All Subjects
*****
Posts: 3272


View Profile WWW Email
« Reply #8 on: March 24, 2004, 02:07:31 AM »

The only function of the 'Vary: User-Agent' header field is to tell Proxies that the browser that a client is using and the content received might depend on the "User-Agent" (the client browser type).

"Header append Vary User-Agent " has nothing to do with DEFLATE, php, or anything else for that matter.  It is a safety feature for clients that go thru proxies.  As a proxy might change the User-Agent string by itself and your server will think that the changed User-Agent string is the browser type of the client...

Quote

However it wont append this User-Agent header for my .php files.


Sure it will.  But you can NOT append/modify a header field ONCE data has been sent to the client or if "hardcoded" HTML code is present in the php file...

Enable "output_buffering = on" under php.ini and have NO html code outside <?php ... code ... ?>

You can read up about this on php.net for a better understanding.
Logged

DeveloperSide.NET
Advanced PHP and MySQL Solutions for your Web Design and Development needs with Web.Developer Server Suite.
Anonymous
Guest
« Reply #9 on: March 24, 2004, 02:16:03 AM »

thanks again admin. :)

Quote

Sure it will. But you can NOT append/modify a header field ONCE data has been sent to the client or if "hardcoded" HTML code is present in the php file...

Enable "output_buffering = on" under php.ini and have NO html code outside <?php ... code ... ?>


umm output_buffering is on and i tried it on a phpinfo.php file that contains only
Code:

<?php
phpinfo
&#40;&#41;;
?>



then i did a "HEAD (http://)mydomain.com/phpinfo.php" and still User-Agent is missing from the vary header. here's the output:

Code:


200 OK
Date: Wed, 24 Mar 2004 02:05:34 GMT
Server: Apache/2.0.49 (Unix) mod_ssl/2.0.49 OpenSSL/0.9.7d PHP/4.3.4
Vary: Accept-Encoding
Content-Type: text/html
Client-Date: Wed, 24 Mar 2004 02:05:34 GMT
Client-Response-Num: 1
X-Powered-By: PHP/4.3.4


actually when i did a 'HEAD http://www.devside.net/' it returns the same thing. -_- no User-Agent. however if its any other file say a .txt or .html then User-Agent will be present.
Logged
admin
Administrator
Master of All Subjects
*****
Posts: 3272


View Profile WWW Email
« Reply #10 on: March 24, 2004, 02:45:59 AM »

By any chance, under your php.ini, is...

zlib.output_compression = On
output_handler = ob_gzhandler

...any one of these set?
Logged

DeveloperSide.NET
Advanced PHP and MySQL Solutions for your Web Design and Development needs with Web.Developer Server Suite.
mike
Guest
« Reply #11 on: March 24, 2004, 03:01:04 AM »

nope. first one is off. 2nd one is empty.
output_buffering=4096

i do have zend optimizer 2.5.1 installed tho.
Logged
mikeq
Guest
« Reply #12 on: March 24, 2004, 03:03:33 AM »

btw if i use the "compress all" mode

SetOutputFilter DEFLATE

then all .php files will have user-agent appended in the Vary header.
Logged
admin
Administrator
Master of All Subjects
*****
Posts: 3272


View Profile WWW Email
« Reply #13 on: July 27, 2004, 02:22:38 AM »

There "was" a bug that caused PHP (at least back to v4.3.2) to replace the "Vary: User-Agent" Header when "adding" the "Accept-Encoding" part.

It looks like something is still wrong.
Logged

DeveloperSide.NET
Advanced PHP and MySQL Solutions for your Web Design and Development needs with Web.Developer Server Suite.
RetroWeb
Member
*
Posts: 8


View Profile
« Reply #14 on: September 09, 2004, 05:45:52 PM »

Hi,

I have a similar problem. I'm using Apache 1.3.31 and PHP 4.3.8. RAR and ZIP files are corrupt when downloaded.

The md5sum for the file on the server was the same as the md5sum on my client's PC, so the file is being corrupted by Apache. My client has tried testing it using Firefox and Internet Explorer on Windows XP. He's not using any download managers.

Any ideas would be gratefully appreciated! :)

Matt
RetroWeb.net
Logged
Pages: [1] 2
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.9 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!