This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

A cookie will be stored in your browser regardless of choice to prevent you being asked this question again. You will be able to change your cookie settings at any time using the link in the footer.

Setup Varnish 4.x for CentOS 6.x
Setup Varnish 4.x for CentOS 6.x
This tutorial is strictly for Varnish 4.x, Sentora 1.0.x, and CentOS 6.x.


Log into your server via ssh gaining root access.

IMPORTANT - Make a backup of of your vhosts file.

cp /etc/zpanel/configs/apache/httpd-vhosts.conf /etc/zpanel/configs/apache/httpd-vhosts.bak.conf

Get the latest version of Varnish from their repositories:

cat << EOF >> /etc/yum.repos.d/varnish.repo
name=Varnish for Enterprise Linux 6

Then install Varnish

yum install -y varnish

Configure Varnish

Using your favorite editor open /etc/sysconfig/varnish and change "VARNISH_LISTEN_PORT" to


Using your favorite editor open /etc/varnish/default.vcl and make sure line 16-18 states

backend default {
   .host = "";
   .port = "8080";

Configure Sentora

set your apache port

setso --set apache_port 8080

set your sentora port

setso --set sentora_port 8080

Go to your sentora administration panel to admin --> Module Admin --> Apache Config and set "Apache Port" to "8080".  Tick the "Force Update" box and click on "Save Changes"

restart the apache server

service httpd restart

start / restart Varnish

service varnish restart

If all goes well both should restart with no issue and Varnish is running in the front of your apache server.

If for some reason the varnish service is not starting try to start it again. If it still does not start and you think there my be a syntax error somewhere you can run the varnish debug command to see where your error is.

varnishd -C -f /etc/varnish/default.vcl

To verify Varnish is working correctly

Going back to you root login via ssh type in the command below replacing with one of your websites.

curl -I

You should get back a response that looks similar to this:

HTTP/1.1 200 OK
Date: Tue, 29 Mar 2016 22:43:18 GMT
Server: Apache
Vary: Accept-Encoding,Cookie
Cache-Control: max-age=3, must-revalidate
WP-Super-Cache: Served supercache file from PHP
Content-Type: text/html; charset=UTF-8
X-Varnish: 65560
Age: 3
Via: 1.1 varnish-v4
Connection: keep-alive

Two flags  to that let you know Varnish is working correctly:

X-Varnish: 16
Via: 1.1 varnish-v4

In case something goes wrong

Remove Varnish completely

yum erase varnish

Restore your vhosts file

cp /etc/zpanel/configs/apache/httpd-vhosts.bak.conf /etc/zpanel/configs/apache/httpd-vhosts.conf

Set your apache port back to 80

setso --set apache_port 80

set your sentora port back to 80

setso --set sentora_port 80

Restart the apache server

service httpd restart
Thanks given by: Ron-e
RE: Setup Varnish 4.x for CentOS 6.x
If you have more than an IP you can set varnish side by side with sentora each on own IP. So customers can either for example use thru varnish ( with extensive and heavy caching ) or use direct access.

No support using PM (Auto adding to IGNORE list!), use the forum. 
How to ask
Freelance AWS Certified Architect & SysOps// DevOps

10$ free to start your VPS

Thanks given by:

Possibly Related Threads...
Thread Author Replies Views Last Post
Fail2ban for Sentora (Centos 7) bbspike 14 25 036 01-14-2020, 07:32 AM
Last Post: Vedran B
[How To] Update from PHP v5.4.16 to v5.6.31 (Includes suhosin patch) [CentOS] betatester3.0 5 6 945 03-18-2019, 01:23 AM
Last Post: BigBang
Proper CRON setup TGates 9 18 641 05-15-2018, 01:07 AM
Last Post: johnk42

Forum Jump:

Users browsing this thread: 1 Guest(s)