After a little digging and playing around with this, I've managed to figure it out and now have a working scenario for mod_pagespeed
to only work on specific domains (vhosts) on the same server.
My configuration is based on a CentOs 6 build Apache 2 that runs Parallels Plesk Panel.
Create a separate pagespeed conf file and store it in a location that won't be a) automatically overwrote or b) automatically loaded (i.e in the existing conf
or conf.d
directories). In my instance, I created /etc/httpd/myconf
and named the file vhosts-pagespeed.conf
.
This configuration file will contain themod_pagespeed
configuration you wish specific domains to use (you can create as many of these as you like). For example, mine is like:-
#https://developers.google.com/speed/pagespeed/module/configuration#virtual-hosts
<IfModule pagespeed_module>
ModPagespeed on
AddOutputFilterByType MOD_PAGESPEED_OUTPUT_FILTER text/html
ModPagespeedFileCachePath "/var/cache/mod_pagespeed/"
ModPagespeedFileCacheInodeLimit 500000
ModPagespeedAvoidRenamingIntrospectiveJavascript on
ModPagespeedLibrary 105527 ltVVzzYxo0 //ajax.googleapis.com/ajax/libs/prototype/1.6.1.0/prototype.js
ModPagespeedLibrary 92501 J8KF47pYOq //ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js
ModPagespeedLibrary 141547 GKjMUuF4PK //ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js
ModPagespeedLibrary 43 1o978_K0_L http://www.modpagespeed.com/rewrite_javascript.js
ModPagespeedEnableFilters extend_cache
ModPagespeedEnableFilters rewrite_javascript
ModPagespeedEnableFilters rewrite_css
ModPagespeedEnableFilters combine_javascript
ModPagespeedEnableFilters combine_css
ModPagespeedEnableFilters inline_javascript
ModPagespeedEnableFilters inline_css
ModPagespeedEnableFilters insert_img_dimensions
ModPagespeedEnableFilters move_css_to_head
ModPagespeedEnableFilters lazyload_images
ModPagespeedEnableFilters rewrite_images
ModPagespeedEnableFilters outline_css
ModPagespeedEnableFilters flatten_css_imports
ModPagespeedEnableFilters inline_import_to_link
ModPagespeedEnableFilters local_storage_cache
ModPagespeedEnableFilters collapse_whitespace
ModPagespeedEnableFilters elide_attributes
ModPagespeedEnableFilters remove_comments
ModPagespeedDisableFilters rewrite_javascript,combine_javascript
ModPagespeedModifyCachingHeaders off
ModPagespeedDomain *
<Location /mod_pagespeed_beacon>
SetHandler mod_pagespeed_beacon
</Location>
<Location /mod_pagespeed_statistics>
Order allow,deny
Allow from localhost
Allow from 127.0.0.1
SetHandler mod_pagespeed_statistics
</Location>
<Location /mod_pagespeed_console>
Order allow,deny
Allow from localhost
Allow from 127.0.0.1
SetHandler mod_pagespeed_console
</Location>
<Location /mod_pagespeed_message>
Allow from localhost
Allow from 127.0.0.1
SetHandler mod_pagespeed_message
</Location>
<Location /mod_pagespeed_referer_statistics>
Allow from localhost
Allow from 127.0.0.1
SetHandler mod_pagespeed_referer_statistics
</Location>
</IfModule>
You'll then need to disable the global mod_pagespeed
and only include the vhost specific pagespeed config on those domains which you wish to enable mod_pagespeed
.
Navigate to /var/www/vhosts/domain.com/conf
and create the file vhost.conf
with the include (this is all this file needs to contain):-
Include /etc/httpd/myconf/vhosts-pagespeed.conf
Disable global /etc/httpd/conf.d/pagespeed.conf
by modifying like so:-
ModPagespeed off
Then restart the server:-
service httpd restart
Now check that mod_pagespeed
is enabled on the domain.com
that you extended the vhost to include the custom pagespeed conf.
If that doesn't work, you may find you need to reconfigure the vhost for domain.com
with something like:-
/usr/local/psa/admin/sbin/websrvmng --reconfigure-vhost --vhost-name=domain.com