Home / Linux / Varnish

Varnish


Installation on CentOS 7.3:
  1. yum -y update
  2. yum install pygpgme yum-utils

Add repository information:

  1. vim /etc/yum.repos.d/varnishcache_varnish5.repo

Add the following to the file:

  1. [varnishcache_varnish5]
    name=varnishcache_varnish5
    baseurl=https://packagecloud.io/varnishcache/varnish5/el/7/$basearch
    repo_gpgcheck=1
    gpgcheck=0
    enabled=1
    gpgkey=https://packagecloud.io/varnishcache/varnish5/gpgkey
    sslverify=1
    sslcacert=/etc/pki/tls/certs/ca-bundle.crt
    metadata_expire=300
    [varnishcache_varnish5-source]
    name=varnishcache_varnish5-source
    baseurl=https://packagecloud.io/varnishcache/varnish5/el/7/SRPMS
    repo_gpgcheck=1
    gpgcheck=0
    enabled=1
    gpgkey=https://packagecloud.io/varnishcache/varnish5/gpgkey
    sslverify=1
    sslcacert=/etc/pki/tls/certs/ca-bundle.crt
    metadata_expire=300

Enable the repo and install package:

  1. yum -q makecache -y --disablerepo='*' --enablerepo='varnishcache_varnish5'
  2. yum install varnish

Varnish executables will be available at:

  1. /usr/sbin/varnishd

Varnish config files:

  1. /etc/varnish/varnish.params - Varnish environment config files
  2. /etc/varnish/default.vcl - main Varnish config file
  3. /etc/varnish/secret - Varnish secret file

Using Varnish with Nginx:

To use Varnish with Nginx, modify Nginx configuration to listen on port 8080.

Edit file /etc/varnish/varnish.params to set:

  1. VARNISH_LISTEN_PORT = 80

Identify Nginx as back-end server by modify file /etc/varnish/default.vcl with the following section:

  1. backend default {
        .host = "127.0.0.1";
        .port = "8080";
    }

Restart Nginx and Varnish.

  1. systemctl restart varnish

To enable Varnish on restart:

  1. systemctl enable varnish

To confirm that Varnish is caching, check the headers.

To confirm that ports have been successfully changed use:

  1. sudo netstat -pan | grep ":80"

Additional Config Changes:

Update DAEMON_OPTS in /etc/varnish/varnish.params to reflect the following additional parameters:

  1. -p cli_buffer=16384
  2. -p feature=+esi_disable_xml_check,+esi_ignore_other_elements
  3. -p vcc_allow_inline_c=on

Restart Varnish for changes to take effect.

Turpentine extension does not support Varnish 5 yet, so create a file /etc/yum.repos.d/varnishcache_varnish41.repo with the following content:

  1. [varnishcache_varnish41]
    name=varnishcache_varnish41
    baseurl=https://packagecloud.io/varnishcache/varnish41/el/6/$basearch
    repo_gpgcheck=1
    gpgcheck=0
    enabled=1
    gpgkey=https://packagecloud.io/varnishcache/varnish41/gpgkey
    sslverify=1
    sslcacert=/etc/pki/tls/certs/ca-bundle.crt
    metadata_expire=300

    [varnishcache_varnish41-source]
    name=varnishcache_varnish41-source
    baseurl=https://packagecloud.io/varnishcache/varnish41/el/6/SRPMS
    repo_gpgcheck=1
    gpgcheck=0
    enabled=1
    gpgkey=https://packagecloud.io/varnishcache/varnish41/gpgkey
    sslverify=1
    sslcacert=/etc/pki/tls/certs/ca-bundle.crt
    metadata_expire=300

Enable the repo as above.


    Post a comment

    Your Name or E-mail ID (mandatory)

    Note: Your comment will be published after approval of the owner.




     RSS of this page