Skip to content

Commit

Permalink
Add basic varnish support
Browse files Browse the repository at this point in the history
  • Loading branch information
C.Lee Taylor committed Apr 13, 2015
1 parent a357e10 commit 9cfb192
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 0 deletions.
11 changes: 11 additions & 0 deletions Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ laravel_root_folder = "/vagrant/laravel" # Where to install Laravel. Will `com
laravel_version = "latest-stable" # If you need a specific version of Laravel, set it here
symfony_root_folder = "/vagrant/symfony" # Where to install Symfony.

# HTTP Reverse Proxy
varnish_version = "4" # Options: 3 | 4
varnish_port_update = "true" # Update varnish port to 80 and apache/nginx to port 8080

nodejs_version = "latest" # By default "latest" will equal the latest stable version
nodejs_packages = [ # List any global NodeJS packages that you want to install
#"grunt-cli",
Expand Down Expand Up @@ -200,6 +204,13 @@ Vagrant.configure("2") do |config|
# Provision Nginx Base
# config.vm.provision "shell", path: "#{github_url}/scripts/nginx.sh", args: [server_ip, public_folder, hostname, github_url]

####
# Reverse Proxy Servers
##########

# Provision Varnish
# config.vm.provision "shell", path: "#{github_url}/scripts/varnish.sh", args: [varnish_version, varnish_port_update]


####
# Databases
Expand Down
2 changes: 2 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ Here's a quickstart screencast!
* Apache
* HHVM
* Nginx
* HTTP Reverse Proxy / Web Application Accelerator
* Varnish
* Databases
* Couchbase
* CouchDB
Expand Down
68 changes: 68 additions & 0 deletions scripts/varnish.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
#!/usr/bin/env bash

echo ">>> Installing Varnish Server $1 ..."

# Check if varnish source list
if [ -e /etc/apt/sources.list.d/varnish-cache.list ]; then
echo "Varnish repo already installed"

else
echo "Installing Varnish repo ..."
curl https://repo.varnish-cache.org/GPG-key.txt | sudo apt-key add -

# Could use Distro Release?
cat << EOF | sudo tee /etc/apt/sources.list.d/varnish-cache.list
# https://www.varnish-cache.org/installation/ubuntu
deb https://repo.varnish-cache.org/ubuntu/ trusty varnish-$1.0
EOF

sudo apt-get -qq install apt-transport-https
# Update Again
sudo apt-get update

fi

# Install varnish Server
# -qq implies -y --force-yes
sudo apt-get -qq install varnish

# ToDo - Check dependencies / Change ports for Web Server

# Update Web server and Varnish link
if [ $2 == "true" ]; then

nginx -v > /dev/null 2>&1
NGINX_IS_INSTALLED=$?

apache2 -v > /dev/null 2>&1
APACHE_IS_INSTALLED=$?

# Set and enable configuration for Apache
if [ $APACHE_IS_INSTALLED -eq 0 ]; then
# Change the port Apache listens on from 80 to 8080
sudo sed -i 's/^Listen\ 80$/Listen\ 8080/' /etc/apache2/ports.conf

# Reload Apache to load in configuration
sudo service apache2 reload
fi

# Set and enable configuration for Nginx
if [ $NGINX_IS_INSTALLED -eq 0 ]; then
# Change the port Nginx listens on from 80 to 8080 for all enabled sites
sudo sed -i 's/listen\ 80;$/listen\ 8080;/' /etc/nginx/sites-enabled/*

# Reload Nginx to load in configuration
sudo service nginx reload
fi

# Set Varnish to listen on port 80
# DAEMON_OPTS="-a :6081 \
# -T localhost:6082 \
# -f /etc/varnish/default.vcl \
# -S /etc/varnish/secret \
# -s malloc,256m"
sudo sed -i.ssk 's/^DAEMON_OPTS=\"-a\ :6081\ \\$/DAEMON_OPTS=\"-a\ :80\ \\/' /etc/default/varnish
sudo service varnish restart
fi

echo ">>> Installed Varnish Server $1 <<<"

1 comment on commit 9cfb192

@LeeNX
Copy link

@LeeNX LeeNX commented on 9cfb192 Apr 13, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, not sure if this is now part of the Percona pull request?

This is a start for #440

Can update Apache an Nginx basic ports to 8080 and have varnish listening on port 80.

Debugging VCL might be work adding for basic usage or beginners.

Please sign in to comment.