Turning page speed off for certain virtual hosts

4,213 views
Skip to first unread message

Nitesh

unread,
Nov 7, 2010, 2:59:46 AM11/7/10
to mod-pagespeed-discuss
Hey Guys
I have like 20 different virtual hosts running on my dev box. I want
to switch mod_pagespeed on just for 2 of those hosts. How can I do
that?

Akhmad Fathonih

unread,
Nov 7, 2010, 4:31:29 AM11/7/10
to mod-pagesp...@googlegroups.com
You should copy mod-pagespeed config into vhost config part of those 2
vhost only. And remove mod-pagespeed config from default host config
(in ubuntu: default)

--
Sent from my mobile device

http://launchpad.navinot.com - Dukung Startup Lokal!
http://navinot.com - Slashing Web & Online Strategy

Akhmad Fathonih

unread,
Nov 7, 2010, 4:35:20 AM11/7/10
to mod-pagesp...@googlegroups.com
Err, let me rephrase it.

In ubuntu, the module is enabled site wide. You can turn that of by
editing the pagespeed.conf in /etc/apache2/mods-enabled/. The rest can
follow my prev email :)

On 11/7/10, Nitesh <nit...@wikinvest.com> wrote:

--

Joshua Marantz

unread,
Nov 7, 2010, 7:56:10 AM11/7/10
to mod-pagesp...@googlegroups.com
Thanks Akhmad,

Would you mind sharing a configuration file that enables mod_pagespeed for Virtual Host environments with some configurations enabled and some not?  Your explanation was very clear, but we'd love to add to the web site an example configuration that's been used on a real-world site.

-Josh

Akhmad Fathonih

unread,
Nov 7, 2010, 9:39:01 AM11/7/10
to mod-pagesp...@googlegroups.com

Ar first, I went with vanilla config. But I met some problem with my site. Image_rewrite failed for some image. The cache exist but in the wrong path (missing a "/"). And rewrite_javascript also hit an error when parsing js comment.

So I use PassThrough setting and enable features that work on my site.

I will share more tomorrow ;)

On 7 Nov 2010 19:56, "Joshua Marantz" <jmar...@google.com> wrote:

Thanks Akhmad,

Would you mind sharing a configuration file that enables mod_pagespeed for Virtual Host environments with some configurations enabled and some not?  Your explanation was very clear, but we'd love to add to the web site an example configuration that's been used on a real-world site.

-Josh



On Sun, Nov 7, 2010 at 4:35 AM, Akhmad Fathonih <akh...@gmail.com> wrote:
>

> Err, let me rephras...

Akhmad Fathonih

unread,
Nov 7, 2010, 8:09:26 PM11/7/10
to mod-pagesp...@googlegroups.com
Okay, this is my pagespeed in vhost:

<IfModule pagespeed_module>
    SetOutputFilter MOD_PAGESPEED_OUTPUT_FILTER
    ModPagespeed on

    
    ModPagespeedUrlPrefix                "http://myhost"

    
    ModPagespeedFileCachePath            "/var/mod_pagespeed/cache/"
    ModPagespeedGeneratedFilePrefix      "/var/mod_pagespeed/files/"

    
    #ModPagespeedRewriteLevel CoreFilters
    ModPagespeedRewriteLevel PassThrough

    
    ModPagespeedEnableFilters collapse_whitespace,elide_attributes,remove_comments,rewrite_css,move_css_to_head
</IfModule>
--

Nitesh

unread,
Nov 8, 2010, 12:00:36 AM11/8/10
to mod-pagespeed-discuss
Thanks Akhmad.
So this is inside the <VirtualHost> tag of the hosts I want this in?
Thanks
Actually what I was doing before I wrote the mail was I had the
default config included in all hosts with all the enable/disable
options, but with the option "ModPagespeed off". Then, in my VHost, I
just added:

<IfModule pagespeed_module>
ModPagespeed on
</IfModule>

That did not work.
Will try this.

On Nov 8, 9:09 am, Akhmad Fathonih <akhm...@gmail.com> wrote:
> Okay, this is my pagespeed in vhost:
>
> <IfModule pagespeed_module>
>     SetOutputFilter MOD_PAGESPEED_OUTPUT_FILTER
>     ModPagespeed on
>
>     ModPagespeedUrlPrefix                "http://myhost"
>
>     ModPagespeedFileCachePath            "/var/mod_pagespeed/cache/"
>     ModPagespeedGeneratedFilePrefix      "/var/mod_pagespeed/files/"
>
>     #ModPagespeedRewriteLevel CoreFilters
>     ModPagespeedRewriteLevel PassThrough
>
>     ModPagespeedEnableFilters
> collapse_whitespace,elide_attributes,remove_comments,rewrite_css,move_css_t o_head
> </IfModule>
>
>
>
>
>
> On Sun, Nov 7, 2010 at 7:56 PM, Joshua Marantz <jmara...@google.com> wrote:
> > Thanks Akhmad,
>
> > Would you mind sharing a configuration file that enables mod_pagespeed for
> > Virtual Host environments with some configurations enabled and some not?
> >  Your explanation was very clear, but we'd love to add to the web site an
> > example configuration that's been used on a real-world site.
>
> > -Josh
>
> > On Sun, Nov 7, 2010 at 4:35 AM, Akhmad Fathonih <akhm...@gmail.com> wrote:
>
> >> Err, let me rephrase it.
>
> >> In ubuntu, the module is enabled site wide. You can turn that of by
> >> editing the pagespeed.conf in /etc/apache2/mods-enabled/. The rest can
> >> follow my prev email :)
>
> >> On 11/7/10, Nitesh <nit...@wikinvest.com> wrote:
> >> > Hey Guys
> >> > I have like 20 different virtual hosts running on my dev box. I want
> >> > to switch mod_pagespeed on just for 2 of those hosts. How can I do
> >> > that?
>
> >> --
> >> Sent from my mobile device
>
> >>http://launchpad.navinot.com- Dukung Startup Lokal!
> >>http://navinot.com- Slashing Web & Online Strategy
>
> --http://launchpad.navinot.com- Dukung Startup Lokal!http://navinot.com- Slashing Web & Online Strategy

Akhmad Fathonih

unread,
Nov 8, 2010, 1:00:14 AM11/8/10
to mod-pagesp...@googlegroups.com
I put my config inside virtualhost directive. Just like what you did.
But I put a whole copy of pagespeed.conf.

http://launchpad.navinot.com - Dukung Startup Lokal!
http://navinot.com - Slashing Web & Online Strategy

Quinn Comendant

unread,
Nov 9, 2010, 5:10:14 AM11/9/10
to mod-pagespeed-discuss
I've got the same issue, though I'm trying to *enable* pagespeed for
only some vhosts. As with Nitesh, I discovered adding `ModPagespeed
on` to a vhost doesn't work (apache won't start, and displays
"Configuration Failed" on its own line in the error_log).

Akhmad, you copied the entire contents of pagespeed.conf into each
vhost which you needed to enable? Ok, but not a clean solution - it
excludes easily managing global parameters such as the cache size
limit configs.

Is mod_pagespeed officially incompatible with apache virtual hosting?

Quinn

Joshua Marantz

unread,
Nov 9, 2010, 9:03:50 AM11/9/10
to mod-pagesp...@googlegroups.com
Hi Quinn,

We'd love to support users who want to use apache virtual hosting.  You can use Include files to avoid duplicating the cache settings:

Put the common configuration parameters in one file:
     pagespeed_common.conf
In the scope of your virtual hosts where you want to enable mod_pagespeed, add
    Include pagespeed_common.conf
plus any host-specific settings such as ModPagespeedDomain or enabling/disabling specific filters.  This way you can put all the cache settings in one place, but still customize each host.

Please let us know how this works for you,
-Josh

Nick Weavers

unread,
Nov 10, 2010, 5:54:47 PM11/10/10
to mod-pagespeed-discuss
Can this be placed in a .htaccess file like other mod configs such as
deflate/expires?

On Nov 8, 1:09 am, Akhmad Fathonih <akhm...@gmail.com> wrote:
> Okay, this is my pagespeed in vhost:
>
> <IfModule pagespeed_module>
>     SetOutputFilter MOD_PAGESPEED_OUTPUT_FILTER
>     ModPagespeed on
>
>     ModPagespeedUrlPrefix                "http://myhost"
>
>     ModPagespeedFileCachePath            "/var/mod_pagespeed/cache/"
>     ModPagespeedGeneratedFilePrefix      "/var/mod_pagespeed/files/"
>
>     #ModPagespeedRewriteLevel CoreFilters
>     ModPagespeedRewriteLevel PassThrough
>
>     ModPagespeedEnableFilters
> collapse_whitespace,elide_attributes,remove_comments,rewrite_css,move_css_t o_head
> </IfModule>
>
>
>
>
>
>
>
>
>
> On Sun, Nov 7, 2010 at 7:56 PM, Joshua Marantz <jmara...@google.com> wrote:
> > Thanks Akhmad,
>
> > Would you mind sharing a configuration file that enables mod_pagespeed for
> > Virtual Host environments with some configurations enabled and some not?
> >  Your explanation was very clear, but we'd love to add to the web site an
> > example configuration that's been used on a real-world site.
>
> > -Josh
>
> > On Sun, Nov 7, 2010 at 4:35 AM, Akhmad Fathonih <akhm...@gmail.com> wrote:
>
> >> Err, let me rephrase it.
>
> >> In ubuntu, the module is enabled site wide. You can turn that of by
> >> editing the pagespeed.conf in /etc/apache2/mods-enabled/. The rest can
> >> follow my prev email :)
>
> >> On 11/7/10, Nitesh <nit...@wikinvest.com> wrote:
> >> > Hey Guys
> >> > I have like 20 different virtual hosts running on my dev box. I want
> >> > to switch mod_pagespeed on just for 2 of those hosts. How can I do
> >> > that?
>
> >> --
> >> Sent from my mobile device
>
> >>http://launchpad.navinot.com- Dukung Startup Lokal!
> >>http://navinot.com- Slashing Web & Online Strategy
>
> --http://launchpad.navinot.com- Dukung Startup Lokal!http://navinot.com- Slashing Web & Online Strategy

sk

unread,
Nov 11, 2010, 10:38:56 AM11/11/10
to mod-pagespeed-discuss
Joshua,

First of all thank you for your answers and your patience with us
I've tried to implement you suggestion. I basically had the module
load directives and the configuration directives included in one of
myvirtual hosts sections like this

LoadModule pagespeed_module /usr/lib/apache2/modules/mod_pagespeed.so
<IfModule !mod_deflate.c>
LoadModule deflate_module /usr/lib/apache2/modules/mod_deflate.so
</IfModule>
Include /etc/apache2/mods-available/pagespeed.conf


So just the vanilla configuration that comes with the ubuntu package.
But apache won't start and complains (in the error log) with
[error] mod_pagespeed is enabled. The following directives must not
be NULL\nModPagespeedUrlPrefix=\nModPagespeedFileCachePath=
\nModPagespeedGeneratedFilePrefix=\n

All these variables are set in the configuration file, so I cant;
explain why apache would complain about them.

Any thoughts? Has anyone else managed to implenet this?

Joshua Marantz

unread,
Oct 17, 2012, 11:13:04 AM10/17/12
to mod-pagespeed-discuss
What you have is fine, but you need to put the default file-cache path and generated file prefix in the root, even though mps is off.

-Josh



On Wed, Oct 17, 2012 at 10:58 AM, Nicolas Unterberger <unte...@gmail.com> wrote:
Hi.

Im trying also to implement this on my servers.
As far i know, i did:

-In /mods-avalaible:
         Modpagespeed off

-In the conf file of one of my virtual host (the one i want to get mod_pagespeed activated) ->
        #Mod_PageSpeed ONLY for this vhost
        Include pagespeed_common.conf
        <IfModule pagespeed_module>
                SetOutputFilter MOD_PAGESPEED_OUTPUT_FILTER
                ModPagespeed on
                ModPagespeedUrlPrefix                "http://dev.WEBSITE.COM"
                ModPagespeedFileCachePath            "/var/mod_pagespeed/cache/"
                ModPagespeedGeneratedFilePrefix      "/var/mod_pagespeed/files/"
                #ModPagespeedRewriteLevel CoreFilters
                ModPagespeedRewriteLevel PassThrough
                ModPagespeedEnableFilters collapse_whitespace,elide_attributes,remove_comments,rewrite_css,move_css_to_head
        </IfModule>
-Copied the pagespeed.conf to /etc/apache/sites-available and rename it as pagespeed_common.conf

In defaults there's nothing, because we dont use default vhost, only virtualhosts.
But i dont know if in the mods-enable should i activate it and then make another conf dile and point to it to make the config specific for a vhost.
Advice would be nice..
Reply all
Reply to author
Forward
0 new messages