35 Comments

  1. Robin

    Tomaz, thanks for this guide. One question, is the SSL and Pound for SPDY? or ….

    ok two questions… why not redis instead of varnish?

    Report

  2. Michael

    PageSpeed does amazing things and well however I think it’s not suitable for small VPS because of the CPU consumption required. In many cases, optimizing once for good the assets with plugins or not is more suitable. However on big VPS it really doe an impressive job.

    Why choosing Pound over an SSL offload on nginx, then you could have added the SPDY support to it?

    Report

  3. Tim Nash (@tnash)

    Why use Pound? If you are already using Nginx then you can use it as the end point, so: Browser -> Nginx (listen 443, proxy to Varnish) -> Varnish -> Nginx (proxy to PHP-FPM)

    Adding Pound is simply adding another point of failure, and rather misses the point of what Nginx does :)

    It’s probably also worth making sure to emphasis that people understand Varnish is one of those things that can completely screw things up if you don’t understand what is going on so before following any tutorial like this it’s really important to have a read, and a play on a non critical site.

    Report

    • Tim Nash (@tnash)

      Just to follow up on my original comment, another big advantage to using Nginx instead of Pound, is that a lot of the bit’s done by mod_pagespeed are on a per client basis, such as image substitution for example so you can do these on the front nginx end point, and then reuse mod_pagespeed on the back for concatenation and minfying.

      Report

    • nel

      Using Pound in front is because Varnish don’t recognize the SSL request. So. It’s kind like a encode module for Varnish.

      Report

      • Tim Nash (@tnash)

        Hi Nel, As I mentioned above Pound is NOT needed in this scenario, Nginx can used where Pound is used and then used after varnish as well.

        So: Nginx -> Varnish -> Nginx -> PHP

        From a site performance point of view this is a no brainer, you can enable SPDY out of the box, you can make full use of mod_pagespeed rather then just its non user specific aspects.

        From a security stand point it’s also more useful as you can utilise Naxsi or similar WAF on the front end, you also can route unwated traffic through to things like Fail2Ban. (you can do some of these with the above setup but not as effectively)

        From a management point of view Pound is an extra thing to worry about and maintain.

        Report

  4. derkuechenmeister

    Why use varnish/pound instead of nginx’ fastcgi_cache?

    Report

  5. Mark Gavalda (@MarkGavalda)

    This is an excellent write-up in the “advanced” category, I’m glad to see articles like this on the Tavern!
    Tomaž, at my company we use a similar configuration sans Varnish and Pound. Nginx has all the functionality that Pound has when it comes to SSL and it’s built-in FastCGI cache can substitute Varnish. I believe in keeping it simple and I also think that less software means faster response time and fewer points of failure, not to mention hardware resource requirements :)

    Report

  6. Ryan Hellyer

    Bjørn Johansen’s site is an excellent resource for learning about this stuff too:
    https://bjornjohansen.no/

    Report

  7. tiagocc0

    Does this setup works with HHVM instead of PHP-FPM? I’m already using Nginx.

    Report

    • Robin

      I’m not sure about this exact setup, but yes, HHVM and Nginx work extremely well together for an incredible amount of performance. As others in the comments have mentioned, if you use Nginx’s built in capabilities you don’t really need Pound or Varnish. There may be some issues with some plugins but core and the vast majority of plugins will run well on HHVM and Nginx.

      Report

  8. Graphic Design Inspiration

    i will try this after.. moving my site to VPS :D thanks for sharing :D

    Report

  9. Nestor C. Pool

    Hi!

    Can I know with website have this setup, so I can run a couple of test with pagespeed insight and also gtmetrix and see the speed and perfomance of the setup running… ??

    Regards…

    Report

    • Ryan Hellyer

      Those tools are for measuring on page speed improvements. They are not very useful for measuring the types of performance increases obtained through this sort of setup.

      Something like Apache Bench would be more helpful, but I don’t think anyone’s going to want you testing that out on their website.

      Report

  10. Mario

    If you set up your Varnish correctly, webp images are not an issue, see the pagespeed docs for more info:

    https://developers.google.com/speed/pagespeed/module/downstream-caching

    Report

  11. rahul286

    Nice article. I think pound and varnish are not required. Nginx has built-in support for SPDY.

    Also, on fresh VPS, whole thing can be automated in 3 commands using EasyEngine – http://github.com/rtCamp/easyengine

    1. install easyengine

    wget -qO ee rt.cx/ee && sudo bash ee

    2. install nginx, php, mysql, postfix, etc

    ee stack install

    3. setup wordpress at example.com with nginx fastcgi_cache

    ee site create example.com --wpfc

    Report

  12. Michael

    Thanks Rahul, That’s some precious info there. I haven’t heard about this ESI module before.

    Report

  13. Andrew J T

    Would this set up work with wp multisite and domain mapping?

    Report

  14. Eve

    Excellent article! I’ve recently been experimenting using Digital Ocean to run Litespeed and MariaDB. DO is such a great platform for learning new tools. Nginx is next on the list…so, thanks!

    Report

  15. Fernandp

    Hi!

    This is a very helpful and straightforward article, and the first one that advise to use nginx (instead of apache) and wordpress together.

    Regarding to the caveat…

    You may enable convert_jpeg_to_webp filter. To avoid having problems with varnish cache you should add the next lines to vcl_fetch:

    if ( req.http.X-Accept ) {
    hash_data (req.http.X-Accept);
    }

    And, in vcl_recv:

    if ( req.http.Accept ~ “.*image/webp.*” ) {
    set req.http.X-Accept = “GoogleImageFormat”;
    }
    if ( req.http.Accept !~ “.*image/webp.*” ) {
    set req.http.X-Accept = “other”;
    }

    With that code, varnish will make a difference between Chrome a firefox browsers.

    Report

  16. cbunting99

    If you are wanting to use Nginx or switch to Nginx, check out http://tengine.taobao.org/index.html

    Report

  17. Mandy K.

    Hi Tomaž! What do think about using a database optimizer like WP Optimize(https://wordpress.org/plugins/wp-optimize/ )? I was reading an article (http://www.giftofspeed.com/speed-up-wordpress/ ) and it was recommended there. Thanks!

    Report

  18. Akshay

    My vote goes to mod_pagespeed. I’m using it with my VPS server and it works like a charm!

    Report

  19. sushil

    Hello ,

    I am using pound>varnish+turpentine>nginx, but when i did curl to my test domain, i didnt get the headers of varnish or turpentine, any suggestion would be appriciated

    [root@localhost conf.d]# curl -I varnish.zeondemo.com
    HTTP/1.1 200 OK
    Content-Type: text/html; charset=UTF-8
    P3p: CP=”CAO PSA OUR”
    LOCAL: varnish-emedco
    Date: Thu, 13 Aug 2015 17:47:02 GMT
    Age: 7
    Connection: keep-alive

    Report

Comments are closed.

%d bloggers like this: