Project

General

Profile

[Solved] Cant get compress to work on virtual domains

Added by fher98 almost 8 years ago

Hello everyone,

Well, I have been using lighty for some long years, last week I notice my pages were not being gzipped, so I went and check the config.

The compression works on the default site, but with my virtual domains it just wont served the pages zipped.

Im using lighty 1.4.35 on Linux Debian 8, more precise info next.

Ok so here we go,

Linux 3.2.0-4-amd64 #1 SMP Debian 3.2.68-1+deb7u3 x86_64 GNU/Linux
cat /etc/debian_version 
8.4
lighttpd/1.4.35 (ssl) (Nov  2 2014 03:47:15) - a light and fast webserver

Im using magnet because my blog works with wordpress and some long time ago i found out that with my permalinks that was the solution.

 cat /etc/lighttpd/lighttpd.conf
server.modules = ( 
        "mod_access",
        "mod_alias",
        "mod_compress",
        "mod_redirect",
        "mod_magnet",
 )
server.document-root        = "/var/www" 
server.upload-dirs          = ( "/var/cache/lighttpd/uploads" )
server.errorlog             = "/var/log/lighttpd/error.log" 
server.pid-file             = "/var/run/lighttpd.pid" 
server.username             = "www-data" 
server.groupname            = "www-data" 
server.port                 = 80

index-file.names            = ( "index.php", "index.html", "index.lighttpd.html" )
url.access-deny             = ( "~", ".inc" )
static-file.exclude-extensions = ( ".php", ".pl", ".fcgi" )

#### compress module
compress.allowed-encodings = ("bzip2", "gzip", "deflate")
compress.cache-dir          = "/var/cache/lighttpd/compress/" 
compress.filetype           = ( "application/javascript", "text/css", "text/html", "text/plain" )

# default listening port for IPv6 falls back to the IPv4 port
include_shell "/usr/share/lighttpd/use-ipv6.pl " + server.port
include_shell "/usr/share/lighttpd/create-mime.assign.pl" 
include_shell "/usr/share/lighttpd/include-conf-enabled.pl" 

cgi.assign = ( ".pl" => "/usr/bin/perl",
".cgi" => "/usr/bin/perl" )

$HTTP["remoteip"] == "127.0.0.1" {
status.status-url          = "/server-status" 
}

server.tag ="Apache/2.2.3 (Ubuntu) PHP/5.2.1" 
####### Enable dir listing for all directories
dir-listing.activate = "disable" 
#Errores 500 server error
fastcgi.debug = 1

# Requires FAM or Gamin to be installed, default = simple-- agregado
server.stat-cache-engine = "fam" 
#### expire module
expire.url               = ( "" => "access plus 20 days" )

#### mod_evasive
evasive.max-conns-per-ip = 250

#############################################
# OpenSSL
#############################################

$SERVER["socket"] == ":443" {
  ssl.engine = "enable" 
  ssl.pemfile = "/etc/lighttpd/certs/lighttpd.pem" 
}

#############################################
# BLOG 3
#############################################

    $HTTP["host"] =~ "(^|\.)blog\.com$" {

    compress.cache-dir         = "/tmp/compress.tmp/" 
    setenv.add-response-header = (
        "Access-Control-Allow-Origin" => "*" 
    )
    compress.allowed-encodings = ("bzip2", "gzip", "deflate")
    compress.filetype          = ("text/plain", "text/html", "application/x-javascript", "text/css", "text/javascript", "text/xml")
    server.document-root = "/home/blog/site" 
    server.errorlog = "/var/log/lighttpd/blog/error.log" 
    accesslog.filename = "/var/log/lighttpd/blog/access.log" 
    server.error-handler-404 = "/e404.php" 

    magnet.attract-physical-path-to = ( server.document-root + "/rewrite.lua" )

    }

As you see on my tests I added the compress config again for the domain, also the "/tmp/compress.tmp/" gets auto created on restart.

The default document root does works with gzip, but no the virtuals, what im I doing wrong?

Please help!


Replies (3)

RE: Cant get compress to work on virtual domains - Added by gstrauss almost 8 years ago

Im using magnet because my blog works with wordpress and some long time ago i found out that with my permalinks that was the solution.

You say this so matter-of-factly as if it is common knowledge for those who do not run wordpress. Would you please provide more details?

More than likely, your lua script is taking control of handling the request before mod_compress has a chance to do so.

Is your lua code handling every single request? Or does it decline to handle some requests? Does compression work when your lua code does not handle the request? (What are the return values from your lua code? 1? 99? > 99?)

RE: Cant get compress to work on virtual domains - Added by fher98 almost 8 years ago

gstrauss wrote:

Im using magnet because my blog works with wordpress and some long time ago i found out that with my permalinks that was the solution.

You say this so matter-of-factly as if it is common knowledge for those who do not run wordpress. Would you please provide more details?

More than likely, your lua script is taking control of handling the request before mod_compress has a chance to do so.

Hi, thanks for the response. Mmmm Ill get rid of the lua and try maybe mod_rewrite. Thanks

RE: Cant get compress to work on virtual domains - Added by gstrauss almost 8 years ago

You can run lua code, make modifications to the request, and have lua code return value 1 for the lighttpd processing to continue to other modules. However, if you have the lua code return a value > 99, then the lua code has handled the request and generated the response.

    (1-3/3)