vcl 4.0;
import std;
backend default {
.host = "127.0.0.1";
.port = "8090";
}
acl purge {
"127.0.0.1";
}
sub vcl_recv {
if(req.method == "PURGE"){
if (!client.ip ~ purge) {
return(synth(405,"Not allowed."));
}
return (purge);
}
return (hash);
}
sub vcl_backend_response {
if (bereq.url ~ "m3u8") {
# assuming chunks are 2 seconds long
set beresp.ttl = 1s;
set beresp.grace = 0s;
} else {
set beresp.ttl = 10m;
set beresp.grace = 5m;
}
}
Varnish
Varnish daemon not listening on configured port – Hack for Debian or Ubuntu
If you’re already troubled with varnish on changing listening ports from default. Here’s a little hack that worked on my Debian and Ubuntu distribution.
sudo apt remove varnish
sudo apt-get purge varnish
# I manually remove the 3 files in created in /etc/systemd/system/*
sudo apt install varnish
sudo nano /lib/systemd/system/varnish.service # put the rigth conf
sudo nano /etc/varnish/default.vcl #put the rigth conf
sudo systemctl daemon-reload
sudo service varnish restart
Install Varnish on Debian 8
We are going to install the latest version of varnish which is 5.2 at the time of writing. In order to install the latest version, we have to download the source and compile it. You have to install some dependencies to compile the Varnish:
apt-get install make automake autotools-dev libedit-dev libjemalloc-dev libncurses-dev libpcre3-dev libtool pkg-config python-docutils python-sphinx
Now you can download the Varnish from the repository:
wget https://varnish-cache.org/_downloads/varnish-5.2.1.tgz
You can also download and install other release from here:
https://varnish-cache.org/releases/index.html
Extract the “tar.gz” file with the command below:
tar xvzf varnish-5.*.tar.gz
Switch to the extracted directory and start compiling:
Install And Configure Varnish Cache With Apache On Debian 7
Varnish Cache is a web accelerator, sometimes referred to as a HTTP accelerator or a reverse HTTP proxy, that will significantly enhance your web performance.
Varnish speeds up a website by storing a copy of the page served by the web server the first time a user visits that page. The next time a user requests the same page, Varnish will serve the copy instead of requesting the page from the web server.
This means that your web server needs to handle less traffic and your website’s performance and scalability go through the roof. Varnish cache will increase the delivery of your web content by 80 % or more, depending on your architecture.
Install Varnish Cache On Debian 7
Normally Varnish Cache is available on Debian default repositories. But i suggest you to use Varnish Cache repositories to get latest version of Varnish Cache.
Run the following commands as root user to install Varnish Cache.
# curl http://repo.varnish-cache.org/debian/GPG-key.txt | apt-key add - # echo "deb http://repo.varnish-cache.org/debian/ wheezy varnish-3.0" >> /etc/apt/sources.list # apt-get update # apt-get install varnish
Configure Varnish
Open up the file ‘/etc/default/varnish’ in any editor.
Varnish Nagios Plugin
Install
To use this plugin you need to have varnishstat installed which is installed by default when you install varnish.
Perl is also required for this plugin. If you don’t have Perl installed you can install in by running the command below
sudo apt-get install perl
or
sudo yum install perl
Now you can download the file above and extract it:
wget <a href="http://www.toms-blog.com/wp-content/uploads/2013/07/check_varnish-v1.0.tar.gz">http://www.toms-blog.com/wp-content/uploads/2013/07/check_varnish-v1.0.tar.gz</a>
tar -xzf check_varnish-v1.0.tar.gz
pressflow varnish installation and configuration
Installation
Varnish is the key software that speeds up your web site.
It is Open Source, built on industry standards and requires very few resources.
Varnish is distributed in the EPEL (Extra Packages for Enterprise Linux) package repositories. However, while EPEL allows new versions to be distributed, it does not allow for backwards-incompatible changes.
Therefore, new major versions will not hit EPEL and it is therefore not necessarily up to date.
If you require a newer major version than what is available in EPEL, you should use the repository provided by varnish-cache.org. To use the varnish-cache.org repository,
Mercury on Ubuntu 10.04 (Lucid)
This high performance Drupal system is based on the work of Project Mercury. Project Mercury aims to increase the performance and ability of Drupal powered websites to respond to increased load. This document leverages the same collection of popular open source tools including the Varnish Accelerating Proxy, the APC bytecode cache for PHP, Memcached for accelerating database operations, and the Solr search engine. These instructions modify the Drupal community instructions for Project Mercury for use with the Linode Platform and the 10.04 release of the Ubuntu Distribution.
You may also choose to deploy your high performance Drupal stack with Linode's StackScript. Simply click on the "Deploy using StackScripts" link on the "Deploy a Linux Distribution" page. When the new Linode boots your system will be running Pantheon Project Mercury. Note that both the StackScript edition and the version of Mercury described in this document require substantial system resources; ensure your system has at least 512 megabytes of RAM. Additionally, at the time of initial publication, be aware that many Drupal Modules may not be fully compatible with PHP version 5.3 that ships with Lucid. Prior to beginning this guide for installing the high performance stack based on Project Mercury, we assume that you have completed our getting started guide. If you're new to Linux systems administration we recommend engaging the guides in our using Linux guide series, particularly the administration basics guide.
Set the Hostname
Before you begin installing and configuring the components described in this guide, please make sure you've followed our instructions for setting your hostname. Issue the following commands to make sure it is set properly:
hostname hostname -f
The first command should show your short hostname, and the second should show your fully qualified domain name (FQDN).
Install Varnish on CentOS/RedHat/SL 5 or 6
Varnish Cache is a web application accelerator also known as a caching HTTP reverse proxy. It is installed in front of the web application and it speeds up the web application significantly.
Since varnish is not available in CentOS repo, you have to add the EPEL repo. However Varnish suggests you to add its own repo to always get the latest version.
rpm –nosignature -i http://repo.varnish-cache.org/redhat/varnish-3.0/el5/noarch/varnish-release-3.0-1.noarch.rpm
The –no-signature is only needed on initial installation, since the Varnish GPG key is not yet in the yum keyring
Now lets install varnish
# yum install varnish
Make sure it can handle server reboots 🙂
# chkconfig varnish on
Lets change some parameters to suit our enviornment.
Putting Varnish In Front Of Apache On Ubuntu/Debian
Varnish is an open source "web accelerator" which you can use to speed up your website.
It can cache certain static elements, such as images or javascript but you can also use it for other purposes such as Loadbalancing or some additional security.
In this tutorial we will focus on the latter one.
In this mode, Varnish will stop incomplete HTTP requests from reaching your Apache webserver.
This tutorial is built on Ubuntu, but will probably also work on Debian.
First of all, make sure you are running Apache2 and have it configured.