Git Product home page Git Product logo

varnish-wordpress's Introduction

VCL for Varnish Enterprise 6.0 in AWS

99.9% robbed from https://github.com/admingeekz/varnish-wordpress

Best used in Cloudformation

You will need an AMI running Varnish Enterprise 6. This comes with vmod_goto, which will allow your Varnish cache to connect to a dynamic backend, such as an Application Load Balancer. You can use this to front an auto-scaling group stuffed with (stateless) Wordpress servers.

You'll also need a Launch Configuration which replaces the string {{ALB_HOSTNAME}} with the DNS name of the load balancer fronting your Wordpress ASG.

Consider the following architecture:

          +------------------------------+
0         |   Application load balancer  |
          +------------------------------+
                         |
          +------------------------------+
1         |  Varnish auto-scaling group  |
          +------------------------------+
                         |
          +------------------------------+
2         |   Application load balancer  |
          +------------------------------+
                         |
          +------------------------------+
3         | Wordpress auto-scaling group |
          +------------------------------+

The Varnish auto-scaling group will need to be configured to accept traffic from the listener at 0, and to forward traffic to the listener at 2, so each instance will need to launch with a configuration like the following:

"VarnishLaunchConfig": {
  "Type" : "AWS::AutoScaling::LaunchConfiguration",
  "Metadata" : {
    "AWS::CloudFormation::Init" : {
      "configSets" : {
        "varnish_install" : ["configure_varnish"]
      },
      "configure_varnish" : {
        "files" : {
          "/etc/varnish/default.vcl" : {
            "source"  : "https://raw.githubusercontent.com/porcospino/varnish-wordpress/master/default.vcl",
            "context" : { "ALB_HOSTNAME"  :  { "Fn::GetAtt" : [ "PrivateLoadBalancer", "DNSName" ] } },
          }
        },
        "commands" : {
          "01enable_varnish" : {
            "command" : "systemctl enable varnish.service"
          },
          "02restart_varnish" : {
            "command" : "systemctl restart varnish.service"
          }
        }
      }
    }
  }
},
"PrivateLoadBalancer" : {
  "Type" : "AWS::ElasticLoadBalancingV2::LoadBalancer",
  "Properties" : {
    "Scheme": "internal"
    [ ... ]

varnish-wordpress's People

Contributors

scott-mc avatar admingeekz avatar scottmci avatar

Watchers

James Cloos avatar Chris Fryer avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.