Not too long ago, during a server migration, I decided to move from Apache to Nginx, mostly because I think it’s a fun weekend project and maybe a little bit because I was looking to save some memory on my VPS. After a few hiccups, Nginx was running smoothly, serving the blog and a few other things.
Hearing Steve Sounders (@Souders) and Ilya Grigorik (@igrigorik) from Google talk about PageSpeed at Velocity Conference made me think about it again. I had the PageSpeed module configured on Apache, but didn’t bother to set it up on Nginx after the migration.
From the PageSpeed website:
A complete list of filters that can be used with PageSpeed can be found at:
Some are safer than others, but generally speaking, they work really well.
I really don’t wan’t to go into install details, because they are really well described in the README file on GitHub.
The only detail I would like to bring up is regarding other Nginx binaries on the same server. Since the install process involves downloading and compiling Nginx, not downloading a binary from a repository, I will probably end up with multiple copies on your server. To avoid confusion, I prefer to remove repository versions before starting the setup.
After compiling and installing a new Nginx with PageSpeed, you will also need to update your nginx.conf and vhosts. Again, everything is described in detail in the README file.
Besides CoreFilters, I also enabled a few “optional” filters:
The names are pretty self-explanatory, but a complete definition of the filters can be found in the config_filters page.
Another detail worth mentioning is that since Nginx is not coming from a repository, there’s no Init Script. I used the following example for CentOS:
And the full Init Script for CentOS:
After everything is done, you can test your installation simply by issuing a curl request:
$ curl -I ‘http://localhost:8050/some_page/’ | grep X-Page-Speed X-Page-Speed: 188.8.131.52-…
For more extensive tests, check: