0 Comments

To optimize the performance of our discoverize portals we decided to try out the PageSpeed Module. Since we already have a little experience with NGINX, we decided to install NGINX(version 1.8.0) with the PageSpeed Module (version 1.9.32.10) on our CentOS 6 and CentOS 7 servers.

Installation:

  1. use guide: https://developers.google.com/speed/pagespeed/module/build_ngx_pagespeed_from_source
    1. ngx_pagespeed was not saved as .zip file, but without file extension – adjust the unzip command accordingly
    2. if needed add other modules to the NGINX configuration before installing NGINX, for instance the ngx_http_ssl_module:
        ./configure --add-module=$HOME/ngx_pagespeed-release-${NPS_VERSION}-beta --with-http_ssl_module
    3. If you install with the http_ssl_module you may have to install OpenSSL libraries first. yum install openssl will probably not suffice, yum install openssl-devel will be needed (you may wonder why ./configure states that OpenSSL is not available even though it is installed – what it really needs is openssl-devel).
    4. if only over-installing nginx, do not forget to restart the nginx service (reload will do nothing)
  2. create NGINX init script: https://www.nginx.com/resources/wiki/start/topics/examples/redhatnginxinit/
    1. adjust folder paths in that script:
      1. nginx="/usr/local/nginx/sbin/nginx" (line 22)
      2. NGINX_CONF_FILE="/usr/local/nginx/conf/nginx.conf" (line 25)
    2. give init script sufficient rights: rwxr-xr-x
  3. create log rotation script: http://www.scalescale.com/tips/nginx/how-to-rotate-nginx-logs/

Uninstall:

There is no uninstall parameter in make for NGINX. Just remove the folders and files: sudo rm -f -R /usr/local/nginx && rm -f /usr/local/sbin/nginx && rm -rf /etc/init.d/nginx

Configuration:

  1. configure NGINX as proxy for web site
    1. there are many guides out there, for instance: https://www.nginx.com/resources/admin-guide/reverse-proxy/
    2. proxy_set_header has to be set, so backend server knows which application should reply
    3. proxy_http_version has to be set to 1.1 – otherwise only parts of page may be transferred
  2. enable the module: https://developers.google.com/speed/pagespeed/module/configuration
    1. use tmpfs for the caching folder: https://developers.google.com/speed/pagespeed/module/faq#tmpfs 
  3. configure filters for PageSpeed Module: https://developers.google.com/speed/pagespeed/module/config_filters
    1. let PageSpeed take care of compressing the response: do not activate gzip, PageSpeed will automatically configure it

    2. try out the filters which are not automatically enabled with the RewriteLevel CoreFilters

All in all it is not an easy task to get the PageSpeed Module working, but in the end it is surely easier and faster to let it optimize your web site responses instead of implementing all the different optimizations.

Since our backend server are Windows server we briefly considered using the IISpeed wrapper for the PageSpeed Module, but went with NGINX. Maybe IISpeed is easier to install and to configure. If you have experience using IISpeed, I would like to read a comment about ist usability.