Comments on Putting Varnish In Front Of Apache On Ubuntu/Debian
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.
19 Comment(s)
Comments
This HowTo works like a charm on Debian Lenny. Thank you VERY much for the effort you have put into it!
Best Regards
Torsten
If you ever get a memory locked error like the one below and varnish won't start, have a look at the mysite.vcl file:
myservername:/etc/varnish$ sudo /etc/init.d/varnish restart
Starting HTTP accelerator: varnishd failed!
Running VCC-compiler failed, exit 1
VCL compilation failed
storage_file: filename: /var/lib/varnish/myservername/varnish_storage.bin size 1024 MB.
Message from VCC-compiler:
Variable 'obj.http.Server' not accessible in method 'vcl_fetch'.
At: (input Line 10 Pos 7)
unset obj.http.Server;
------###############-
uncommenting line 10 and 12 in /etc/varnish/mysite.vcl solved the problem for me. Hope that helps
Best Regards
Torsten Zenk
In Addition to the comment before if you still get an Error like this:
Error 503 Service Unavailable
Service Unavailable
Guru Meditation:
XID: XXXXXXX
Varnish cache server
try to add this in mysite.vcl on line 5:
.connect_timeout = 1s;
.first_byte_timeout = 5s;
.between_bytes_timeout = 2s;
This lets you controll the amount of time untill an varnish timeout happens.
It also works perfectly on Debian Squeeze using apache2.2 with multiple sites.
~azz
This would be the correct syntax for removing / adding http headers:
## Unset http header
unset beresp.http.Server;
## Set new http header
set beresp.http.Server = "My Server xxxx";
If you get varnish failing silently (or saying "Not starting Varnish...[OK]" try starting it with less memory. On my Ubuntu VM this was causing me a problem, I started in debug mode from varnishd like this;
/etc/varnish# varnishd -f /etc/varnish/local.vcl -s malloc,1G -T 127.0.0.1:2000 -a 0.0.0.0:80 -d
by default varnish was trying to allocate 5G which my box took exception to
Since Varnish 3.0 is out you might want to consider to use it on Ubuntu or Debian. The installation instructions are here:
Installation on Debian: https://www.varnish-cache.org/installation/debian
Installation on Ubuntu: https://www.varnish-cache.org/installation/ubuntu
and you can then use the ongoing information provided here.
I have a centos 5.5 installation with directadmin apache and such.
I tryed using varnish infront of apache but all my websites got the message:
Apache is functioning normally
So is it possible to forward more domains because I sell hosting to customers and it would be bad to have to configure each website through the config.
But I would like to use varnish.
What can I do?
If nobody knows your IP address they will not be able to connect to your varnish server - so your request makes no sense.
If you do not want people to view your website then place a firewall in front of it, to deny incoming connections. If you do want visitors to your site then they need to lookup the IP address to connect.
Use Cloudflare.com to hide your ip address.
Your question has actually no meaning. If you want to hide your ip , then no request come to your server. One solution ( but may be you don't mean it) using www.cloudflare.com/ . It actually used for speeding up your website.
Any point in using apache mod_pagespeed on this setup?
I spent over a month trying to get a production server running in EC2 with Varnish and CloudFlare CDN working properly with remote client IP behind a load balancer, until I found this AMI: https://aws.amazon.com/marketplace/pp/B00KSGVT9C, it has everything pre-installed and configured, and it help me get everything up and running in a hour!
I have a website with a database of >2 Gb. my site is just like youtube etc. but i am not hosting any video rather it is sharing youtube videos. my video pages are most surfed one. I have installed varnish on it. I find that many time varnish gives me guru mediation error. I am not able to understand how to solve this problem. Please let me know. what to do?
I'm migriting from Debian Wheezy to Jessie. Currently gtmetrix com site (checking form London location) shows 94/91 points for my ebinxdom pl site. I am curently using APC, memcache, but I wonder if varnish could help to achive better performance. I'm after faster server response time which I've been struggling for sometime now (e.g. now I only get 0.30-0.40ms resonse time)
Hello,
thank you for this tutorial,that's exactly what I'm looking for.
I juste have 22 questions :
what if we use both http and https queries on our website should we add 443 port too ? (I'm using debian6 with ispconfig).
will varnish work if we use external CDN to serve static content (css, javascript and images)
than you
Hello,
thank you for this tutorial,that's exactly what I'm looking for.
I juste have 22 questions :
what if we use both http and https queries on our website should we add 443 port too ? (I'm using debian6 with ispconfig).
will varnish work if we use external CDN to serve static content (css, javascript and images)
than you
Hello,
thank you for this tutorial,that's exactly what I'm looking for.
I juste have 22 questions :
what if we use both http and https queries on our website should we add 443 port too ? (I'm using debian6 with ispconfig).
will varnish work if we use external CDN to serve static content (css, javascript and images)
than you