Varnish installation and configuration on Debian 9.4

Varnish reverse HTTP proxy, as a high-performance HTTP accelerator, can greatly improve the speed and concurrency of accessing websites

1. Install varnish stable version 6.0.0 under Debian 9.4:

http://varnish-cache.org/releases/index.html

http://varnish-cache.org/_downloads/varnish-6.0.0.tgz

 

2. Source installation:

refer to:

http://varnish-cache.org/docs/6.0/installation/install.html#debian-ubuntu

apt-get install        \
    make            \
    automake        \
    autotools-dev    \
    libedit-dev        \
    libjemalloc-dev    \
    libncurses-dev    \
    libpcre3-dev    \
    libtool            \
    pkg-config        \
    python-docutils \
    python-sphinx    \
    graphviz        \
    autoconf-archive

 

CentOS/RedHat :

yum install make automake autoconf libtool libedit-devel jemalloc-devel ncurses-devel python-docutils pcre-devel openssl-devel zlib-devel bzip2-devel 

 

tar xf varnish-6.0.0.tgz
cd  varnish-6.0.0/
sh autogen.sh
sh configure
make
make install

 

Or it can be installed with apt-get: 

apt-get install varnish

 

3. Configuration

Nginx is used as the http server, and the http port is port 80

Copy all the *.vcl files under varnish-6.0.0/etc/ to the /etc/varnish/ directory:

cp -rf ./varnish-6.0.0/etc/* /etc/varnish/

Then copy example.vcl to default.vcl

cp example.vcl default.vcl

Modify default.vcl as follows:
backend default {
    .host = "192.168.0.112";
    #.host = "127.0.0.1";
    .port = "80";
}

Direct .host = "127.0.0.1"; also works

Run the following command to view varnishd help information:

varnishd -?  

 

run:

varnishd -a :6801 -f /etc/varnish/default.vcl -s malloc -l 512M

 

Access under Debian browser:

 

Access under windows:

 

4. Check the working status of Varnish

The varnishstat command can check the working status of varnish, cache hit rate and other information

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325120199&siteId=291194637