Apache2's mod_deflate logging seems broken

Bug #44975 reported by Nick Jenkins
12
Affects Status Importance Assigned to Milestone
apache2 (Ubuntu)
Invalid
Medium
Soren Hansen

Bug Description

Binary package hint: apache2-mpm-prefork

Apache 2's mod_deflate is not logging, despite giving it directives to do so.

Distro Version information:
Ubuntu Dapper Drake 6.06 Flight 7, AMD64 edition.

Also happens on Debian (see: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=306024 ).

Steps for setting up Apache content compression and reproducing the problem:

# enable the required compression module; mod_deflate is now used instead of libapache-mod-gzip for content compression:
a2enmod deflate

# Load the headers module:
a2enmod headers

# Reload apache:
/etc/init.d/apache2 force-reload

Then "nano /etc/apache2/apache2.conf", and add this to the end of the file to enable mod_deflate, and turn on logging for it.

# ---------------------------------------------------
# -------------- Enabling Mod_Deflate ---------------
<IfModule mod_deflate.c>
  # Compress all content, manually excluding specified file types
  # 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

  # properly handle requests coming from behind proxies
  <IfModule mod_headers.c>
      Header append Vary User-Agent env=!dont-vary
  </IfModule>

  # Keep a log of compression ratio on each request
  DeflateFilterNote Input instream
  DeflateFilterNote Output outstream
  DeflateFilterNote Ratio ratio
  LogFormat '"%r" %{outstream}n/%{instream}n (%{ratio}n%%)' deflate
  CustomLog /var/log/apache2/deflate.log deflate

  # Properly handle old browsers that do not support compression
  BrowserMatch ^Mozilla/4 gzip-only-text/html
  BrowserMatch ^Mozilla/4\.0[678] no-gzip
  BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
</IfModule>
# ---------------------------------------------------

# Then check above syntax is OK:
apache2ctl -t

# Then restart apache:
/etc/init.d/apache2 force-reload

Result is that the "/var/log/apache2/deflate.log" file is created, but it is empty. Additionally, checking the headers returned on requesting a web page from apache, they contain this:

==============================
HTTP/1.1 200 OK
Date: Tue, 16 May 2006 07:28:02 GMT
Server: Apache
Last-Modified: Tue, 16 May 2006 06:53:34 GMT
ETag: "770259-46a8-413e242f91780"
Accept-Ranges: bytes
Vary: Accept-Encoding,User-Agent
Content-Encoding: gzip
Content-Length: 4851
Content-Type: text/html; charset=UTF-8
==============================

Note the "Content-Encoding: gzip" header, indicating that the content has apparently been compressed.

Therefore it appears that mod_deflate functionality is working, but that the logging for mod_deflate is not working.

Package version and dependencies:
root@bling:/var/www/bling# dpkg --list apache2-mpm-prefork
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Installed/Config-files/Unpacked/Failed-config/Half-installed
|/ Err?=(none)/Hold/Reinst-required/X=both-problems (Status,Err: uppercase=bad)
||/ Name Version Description
+++-=====================-=====================-==========================================================
ii apache2-mpm-prefork 2.0.55-4 traditional model for Apache2

root@bling:/var/www/bling# grep-available -P -X -s Package,Depends apache2-mpm-prefork
Package: apache2-mpm-prefork
Depends: libapr0 (>= 2.0.55), libc6 (>= 2.3.4-1), libdb4.3 (>= 4.3.28-1), libexpat1 (>= 1.95.8), libldap2 (>= 2.1.17-1), libpcre3 (>= 4.5), libssl0.9.8 (>= 0.9.8a-1), zlib1g (>= 1:1.2.1), apache2-common (= 2.0.55-4)

All the best,
Nick.

Revision history for this message
Soren Hansen (soren) wrote :

Could you please retest this on a Feisty system? Thank you!

Changed in apache2:
assignee: nobody → shawarma
status: Unconfirmed → Needs Info
Revision history for this message
sammael (davej-ad) wrote :

i have tested this in Kubuntu FF 7.04. i've setup mod_deflate EXACTLY as in post above, content is gzipped
http://www.whatsmyip.org/mod_gzip_test/?url=aHR0cDovL3NhbW1hZWwuaG9tZWxpbnV4Lm5ldC90YWhha3lldS9pbmRleC5waHA=

but file /var/log/apache2/deflate.log is just created and stays empty

Revision history for this message
Soren Hansen (soren) wrote :

Could you please check the permissions of /var/log/apache2/deflate.log? I.e. provide the full output of the command "ls -l /var/log/apache2/deflate.log".

Revision history for this message
sammael (davej-ad) wrote : Re: [Bug 44975] Re: Apache2's mod_deflate logging seems broken

$ ls -l /var/log/apache2/deflate.log
-rw-r--r-- 1 root root 340 2007-06-12 03:50 /var/log/apache2/deflate.log

also i noticed the logfile is no longer empty but is not filled with
relevant data either:
$ cat /var/log/apache2/deflate.log
"GET / HTTP/1.0" -/- (-%)
"GET / HTTP/1.0" -/- (-%)
"GET / HTTP/1.0" -/- (-%)
"GET / HTTP/1.0" -/- (-%)
"GET / HTTP/1.0" -/- (-%)
"GET / HTTP/1.0" -/- (-%)
"GET / HTTP/1.0" -/- (-%)
"GET / HTTP/1.0" -/- (-%)

i am using exact configuration as in first post here... maybe there's a
typo...

DeflateFilterNote Input instream
DeflateFilterNote Output outstream
DeflateFilterNote Ratio ratio
LogFormat '"%r" %{outstream}n/%{instream}n (%{ratio}n%%)' deflate
CustomLog /var/log/apache2/deflate.log deflate

On 12/06/07, Soren Hansen <email address hidden> wrote:
>
> Could you please check the permissions of /var/log/apache2/deflate.log?
> I.e. provide the full output of the command "ls -l
> /var/log/apache2/deflate.log".
>
> --
> Apache2's mod_deflate logging seems broken
> https://bugs.launchpad.net/bugs/44975
> You received this bug notification because you are a direct subscriber
> of the bug.
>

--
kill me again, or take me as i am,
for i shall not change - NEVER !

Revision history for this message
Soren Hansen (soren) wrote :

I've looked over the documentation for Apache and may have found the reason why you're having problems. It *is* indeed possible to define multiple log files, so it's not because your deflate.log gets overridden later, *but* http://httpd.apache.org/docs/2.0/logs.html#virtualhost says that "If CustomLog or ErrorLog directives are placed inside a <VirtualHost> section, all requests or errors for that virtual host will be logged only to the specified file. Any virtual host which does not have logging directives will still have its requests sent to the main server logs."

Does that perhaps apply to your setup?

Revision history for this message
sammael (davej-ad) wrote :

thanks for pointing me in right direction. i've just moved

    # place filter 'DEFLATE' on all outgoing content
    SetOutputFilter DEFLATE
    # exclude uncompressible content via file type
    SetEnvIfNoCase Request_URI \.(?:exe|t?gz|jpg|zip|bz2|sit|rar)$ no-gzip
dont-vary
    # Keep a log of compression ratio on each request
    DeflateFilterNote Input instream
    DeflateFilterNote Output outstream
    DeflateFilterNote Ratio ratio
    LogFormat '"%r" %{outstream}n/%{instream}n (%{ratio}n%%)' deflate
    CustomLog /var/log/apache2/deflate.log deflate
    # Properly handle old browsers that do not support compression
    BrowserMatch ^Mozilla/4 gzip-only-text/html
    BrowserMatch ^Mozilla/4\.0[678] no-gzip
    BrowserMatch \bMSIE !no-gzip !gzip-only-text/html

from apache2.conf to /etc/apache2/sites-available/default

and logging now works:

"GET /tahakyeu/asp/asp_cvic_dod_odb.zip HTTP/1.1" -/- (-%)
"GET /tahakyeu/fotoalbum.php?odkial= HTTP/1.1" 2124/6133 (34%)
"GET /tahakyeu/foto_start.php HTTP/1.1" 694/1251 (55%)
"GET /tahakyeu/_fotke/krajinky/page_01.php?kolko=90&kolko2=90 HTTP/1.1"
921/4584 (20%)
"GET /tahakyeu/_fotke/krajinky/picview.php?obr=072.jpg&kolko=90&kolko2=90HTTP/1.1"
501/963 (52%)
"GET /tahakyeu/_fotke/krajinky/072.jpg HTTP/1.1" -/- (-%)
"GET /tahakyeu/_fotke/krajinky/page_01.php?kolko=90&kolko2=90 HTTP/1.1"
921/4584 (20%)

thank you very much!

On 12/06/07, Soren Hansen <email address hidden> wrote:
>
> I've looked over the documentation for Apache and may have found the
> reason why you're having problems. It *is* indeed possible to define
> multiple log files, so it's not because your deflate.log gets overridden
> later, *but* http://httpd.apache.org/docs/2.0/logs.html#virtualhost says
> that "If CustomLog or ErrorLog directives are placed inside a
> <VirtualHost> section, all requests or errors for that virtual host
> will be logged only to the specified file. Any virtual host which does
> not have logging directives will still have its requests sent to the
> main server logs."
>
> Does that perhaps apply to your setup?
>
> --
> Apache2's mod_deflate logging seems broken
> https://bugs.launchpad.net/bugs/44975
> You received this bug notification because you are a direct subscriber
> of the bug.
>

--
kill me again, or take me as i am,
for i shall not change - NEVER !

Revision history for this message
Soren Hansen (soren) wrote :

On Tue, Jun 12, 2007 at 12:47:38PM -0000, sammael wrote:
> thank you very much!

I'm only glad to help. :)

 status rejected

Changed in apache2:
status: Needs Info → Rejected
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.